Various updates to the manual from upstream (RHEL-108974)

Resolves: RHEL-108974
This commit is contained in:
Arjun Shankar 2025-08-14 11:21:59 +02:00
parent d19eb70013
commit ca8e2eea50
35 changed files with 4963 additions and 1 deletions

41
glibc-RHEL-108974-1.patch Normal file
View File

@ -0,0 +1,41 @@
commit 400bdb5c85af5a52b3f5653357c9fca87f036bd3
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue May 28 10:07:47 2024 -0700
Improve doc for time_t range (BZ 31808)
diff --git a/manual/time.texi b/manual/time.texi
index 7d9efc7c6f5b8a43..2e029975b952ac29 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -123,7 +123,7 @@ The number of clock ticks per second is system-specific.
@code{time_t} is the simplest data type used to represent simple
calendar time.
-In ISO C, @code{time_t} can be either an integer or a floating-point
+In ISO C, @code{time_t} can be either an integer or a real floating
type, and the meaning of @code{time_t} values is not specified. The
only things a strictly conforming program can do with @code{time_t}
values are: pass them to @code{difftime} to get the elapsed time
@@ -134,11 +134,21 @@ and pass them to the functions that convert them to broken-down time
On POSIX-conformant systems, @code{time_t} is an integer type and its
values represent the number of seconds elapsed since the @dfn{epoch},
which is 00:00:00 on January 1, 1970, Coordinated Universal Time.
+The count of seconds ignores leap seconds.
@Theglibc{} additionally guarantees that @code{time_t} is a signed
type, and that all of its functions operate correctly on negative
@code{time_t} values, which are interpreted as times before the epoch.
+Functions like @code{localtime} assume the Gregorian calendar even
+though this is historically inaccurate for timestamps before the
+calendar was introduced or after the calendar will become obsolete.
@cindex epoch
+@Theglibc{} also supports leap seconds as an option, in which case
+@code{time_t} counts leap seconds instead of ignoring them.
+Currently the @code{time_t} type is 64 bits wide on all platforms
+supported by @theglibc{}, except that it is 32 bits wide on a few
+older platforms unless you define @code{_TIME_BITS} to 64.
+@xref{Feature Test Macros}.
@end deftp
@deftp {Data Type} {struct timespec}

View File

@ -0,0 +1,70 @@
commit 7fe1fde499507126f7de10ebf12fecaf77ae6602
Author: Joseph Myers <josmyers@redhat.com>
Date: Mon Oct 28 22:22:26 2024 +0000
Document further requirement on mixing streams / file descriptors
The gilbc manual has some documentation in llio.texi of requirements
for moving between I/O on FILE * streams and file descriptors on the
same open file description.
The documentation of what must be done on a FILE * stream to move from
it to either a file descriptor or another FILE * for the same open
file description seems to match POSIX. However, there is an
additional requirement in POSIX on the *second* of the two handles
being moved between, which is not mentioned in the glibc manual: "If
any previous active handle has been used by a function that explicitly
changed the file offset, except as required above for the first
handle, the application shall perform an lseek() or fseek() (as
appropriate to the type of handle) to an appropriate location.".
Document this requirement on seeking in the glibc manual, limited to
the case that seems relevant to glibc (the new channel is a previously
active stream, on which the seeking previously occurred). Note that
I'm not sure what the "except as required above for the first handle"
is meant to be about, so I haven't documented anything for it. As far
as I can tell, nothing specified for moving from the first handle
actually list calling a seek function as one of the steps to be done.
(Current POSIX doesn't seem to have any relevant rationale for this
section. The rationale in the 1996 edition says "In requiring the
seek to an appropriate location for the new handle, the application is
required to know what it is doing if it is passing streams with seeks
involved. If the required seek is not done, the results are undefined
(and in fact the program probably will not work on many common
implementations)." - which also doesn't help in understanding the
purpose of "except as required above for the first handle".)
Tested with "make info" and "make pdf".
diff --git a/manual/llio.texi b/manual/llio.texi
index 850d09205a604589..7121a513a6d6d41b 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -1097,6 +1097,27 @@ streams persist in other processes, their file positions become
undefined as a result. To prevent this, you must clean up the streams
before destroying them.
+In addition to cleaning up a stream before doing I/O using another
+linked channel, additional precautions are needed to ensure a
+well-defined file position indicator in some cases. If both the
+following conditions hold, you must set the file position indicator on
+the new channel (a stream) using a function such as @code{fseek}.
+
+@itemize @bullet
+@item
+The new linked channel is a stream that was previously active.
+
+@item
+The file position indicator was previously set on that channel (while
+it was previously active) with a function such as @code{fseek}.
+@end itemize
+
+POSIX requires such precautions in more cases: if either the old or
+the new linked channel is a stream (whether or not previously active)
+and the file position indicator was previously set on any channel
+linked to those channels with a function such as @code{fseek} or
+@code{lseek}.
+
@node Independent Channels
@subsection Independent Channels
@cindex independent channels

146
glibc-RHEL-108974-11.patch Normal file
View File

@ -0,0 +1,146 @@
commit b7d4de086ce7fcc531cdd67a61dc27b5b3eff482
Author: Florian Weimer <fweimer@redhat.com>
Date: Mon Aug 5 16:01:12 2024 +0200
manual: Describe struct link_map, support link maps with dlinfo
This does not describe how to use RTLD_DI_ORIGIN and l_name
to reconstruct a full path for the an object. The reason
is that I think we should not recommend further use of
RTLD_DI_ORIGIN due to its buffer overflow potential (bug 24298).
This should be covered by another dlinfo extension. It would
also obsolete the need for the dladdr approach to obtain
the file name for the main executable.
Obtaining the lowest address from load segments in program
headers is quite clumsy and should be provided directly
via dlinfo.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/dynlink.texi b/manual/dynlink.texi
index d71f7a30d6f46808..ead5455e30c10a61 100644
--- a/manual/dynlink.texi
+++ b/manual/dynlink.texi
@@ -351,16 +351,119 @@ support the XGETBV instruction.
@node Dynamic Linker Introspection
@section Dynamic Linker Introspection
-@Theglibc{} provides various functions for querying information from the
+@Theglibc{} provides various facilities for querying information from the
dynamic linker.
+@deftp {Data Type} {struct link_map}
+
+@cindex link map
+A @dfn{link map} is associated with the main executable and each shared
+object. Some fields of the link map are accessible to applications and
+exposed through the @code{struct link_map}. Applications must not modify
+the link map directly.
+
+Pointers to link maps can be obtained from the @code{_r_debug} variable,
+from the @code{RTLD_DI_LINKMAP} request for @code{dlinfo}, and from the
+@code{_dl_find_object} function. See below for details.
+
+@table @code
+@item l_addr
+@cindex load address
+This field contains the @dfn{load address} of the object. This is the
+offset that needs to be applied to unrelocated addresses in the object
+image (as stored on disk) to form an address that can be used at run
+time for accessing data or running code. For position-dependent
+executables, the load address is typically zero, and no adjustment is
+required. For position-independent objects, the @code{l_addr} field
+usually contains the address of the object's ELF header in the process
+image. However, this correspondence is not guaranteed because the ELF
+header might not be mapped at all, and the ELF file as stored on disk
+might use zero as the lowest virtual address. Due to the second
+variable, values of the @code{l_addr} field do not necessarily uniquely
+identify a shared object.
+
+On Linux, to obtain the lowest loaded address of the main program, use
+@code{getauxval} to obtain the @code{AT_PHDR} and @code{AT_PHNUM} values
+for the current process. Alternatively, call
+@samp{dlinfo (_r_debug.r_map, &@var{phdr})}
+to obtain the number of program headers, and the address of the program
+header array will be stored in @var{phdr}
+(of type @code{const ElfW(Phdr) *}, as explained below).
+These values allow processing the array of program headers and the
+address information in the @code{PT_LOAD} entries among them.
+This works even when the program was started with an explicit loader
+invocation.
+
+@item l_name
+For a shared object, this field contains the file name that the
+@theglibc{} dynamic loader used when opening the object. This can be
+a relative path (relative to the current directory at process start,
+or if the object was loaded later, via @code{dlopen} or
+@code{dlmopen}). Symbolic links are not necessarily resolved.
+
+For the main executable, @code{l_name} is @samp{""} (the empty string).
+(The main executable is not loaded by @theglibc{}, so its file name is
+not available.) On Linux, the main executable is available as
+@file{/proc/self/exe} (unless an explicit loader invocation was used to
+start the program). The file name @file{/proc/self/exe} continues to
+resolve to the same file even if it is moved within or deleted from the
+file system. Its current location can be read using @code{readlink}.
+@xref{Symbolic Links}. (Although @file{/proc/self/exe} is not actually
+a symbol link, it is only presented as one.) Note that @file{/proc} may
+not be mounted, in which case @file{/proc/self/exe} is not available.
+
+If an explicit loader invocation is used (such as @samp{ld.so
+/usr/bin/emacs}), the @file{/proc/self/exe} approach does not work
+because the file name refers to the dynamic linker @code{ld.so}, and not
+the @code{/usr/bin/emacs} program. An approximation to the executable
+path is still available in the @code{@var{info}.dli_fname} member after
+calling @samp{dladdr (_r_debug.r_map->l_ld, &@var{info})}. Note that
+this could be a relative path, and it is supplied by the process that
+created the current process, not the kernel, so it could be inaccurate.
+
+@item l_ld
+This is a pointer to the ELF dynamic segment, an array of tag/value
+pairs that provide various pieces of information that the dynamic
+linking process uses. On most architectures, addresses in the dynamic
+segment are relocated at run time, but on some architectures and in some
+run-time configurations, it is necessary to add the @code{l_addr} field
+value to obtain a proper address.
+
+@item l_prev
+@itemx l_next
+These fields are used to maintain a double-linked linked list of all
+link maps within one @code{dlmopen} namespace. Note that there is
+currently no thread-safe way to iterate over this list. The
+callback-based @code{dl_iterate_phdr} interface can be used instead.
+@end table
+@end deftp
+
+@strong{Portability note:} It is not possible to create a @code{struct
+link_map} object and pass a pointer to a function that expects a
+@code{struct link_map *} argument. Only link map pointers initially
+supplied by @theglibc{} are permitted as arguments. In current versions
+of @theglibc{}, handles returned by @code{dlopen} and @code{dlmopen} are
+pointers to link maps. However, this is not a portable assumption, and
+may even change in future versions of @theglibc{}. To obtain the link
+map associated with a handle, see @code{dlinfo} and
+@code{RTLD_DI_LINKMAP} below. If a function accepts both
+@code{dlopen}/@code{dlmopen} handles and @code{struct link_map} pointers
+in its @code{void *} argument, that is documented explicitly.
+
+@subsection Querying information for loaded objects
+
+The @code{dlinfo} function provides access to internal information
+associated with @code{dlopen}/@code{dlmopen} handles and link maps.
+
@deftypefun {int} dlinfo (void *@var{handle}, int @var{request}, void *@var{arg})
@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
@standards{GNU, dlfcn.h}
This function returns information about @var{handle} in the memory
location @var{arg}, based on @var{request}. The @var{handle} argument
must be a pointer returned by @code{dlopen} or @code{dlmopen}; it must
-not have been closed by @code{dlclose}.
+not have been closed by @code{dlclose}. Alternatively, @var{handle}
+can be a @code{struct link_map *} value for a link map of an object
+that has not been closed.
On success, @code{dlinfo} returns 0 for most request types; exceptions
are noted below. If there is an error, the function returns @math{-1},

View File

@ -0,0 +1,83 @@
commit 87cd94bba4091d22e24116298ade33b712ada235
Author: DJ Delorie <dj@redhat.com>
Date: Tue Dec 10 17:07:21 2024 -0500
manual: Document more sigaction flags
Adds documentation for three-argument handler
Adds remainder of the SA_* flags
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/signal.texi b/manual/signal.texi
index 5c2ba7dae6072926..2012980efe5e2ccc 100644
--- a/manual/signal.texi
+++ b/manual/signal.texi
@@ -1141,6 +1141,15 @@ This is used in the same way as the @var{action} argument to the
@code{signal} function. The value can be @code{SIG_DFL},
@code{SIG_IGN}, or a function pointer. @xref{Basic Signal Handling}.
+@item void (*sa_sigaction) (int @var{signum}, siginfo_t *@var{info}, void *@var{ucontext})
+This is an alternate to @code{sa_handler} that is used when the
+@code{sa_flags} includes the @code{flag SA_SIGINFO}. Note that this
+and @code{sa_handler} overlap; only ever set one at a time.
+
+The contents of the @var{info} and @var{ucontext} structures are
+kernel and architecture dependent. Please see
+@manpageurl{sigaction,2} for details.
+
@item sigset_t sa_mask
This specifies a set of signals to be blocked while the handler runs.
Blocking is explained in @ref{Blocking for Handler}. Note that the
@@ -1324,6 +1333,24 @@ delivered for both terminated children and stopped children.
Setting this flag for a signal other than @code{SIGCHLD} has no effect.
@end deftypevr
+@deftypevr Macro int SA_NOCLDWAIT
+This flag is meaningful only for the @code{SIGCHLD} signal. When the
+flag is set, the terminated child will not wait for the parent to reap
+it, or become a zombie if not reaped. The child will instead be
+reaped by the kernel immediately on termination, similar to setting
+SIGCHLD to SIG_IGN.
+
+Setting this flag for a signal other than @code{SIGCHLD} has no effect.
+@end deftypevr
+
+@deftypevr Macro int SA_NODEFER
+Normally a signal is added to the signal mask while running its own
+handler; this negates that, so that the same signal can be received
+while it's handler is running. Note that if the signal is included in
+@code{sa_mask}, it is masked regardless of this flag. Only useful when
+assigning a function as a signal handler.
+@end deftypevr
+
@deftypevr Macro int SA_ONSTACK
@standards{BSD, signal.h}
If this flag is set for a particular signal number, the system uses the
@@ -1332,6 +1359,12 @@ If a signal with this flag arrives and you have not set a signal stack,
the normal user stack is used instead, as if the flag had not been set.
@end deftypevr
+@deftypevr Macro int SA_RESETHAND
+Resets the handler for a signal to SIG_DFL, at the moment specified
+handler function begins. I.e. the handler is called once, then the
+action resets.
+@end deftypevr
+
@deftypevr Macro int SA_RESTART
@standards{BSD, signal.h}
This flag controls what happens when a signal is delivered during
@@ -1347,6 +1380,12 @@ clear, returning from a handler makes the function fail.
@xref{Interrupted Primitives}.
@end deftypevr
+@deftypevr Macro int SA_SIGINFO
+Indicates that the @code{sa_sigaction} three-argument form of the
+handler should be used in setting up a handler instead of the
+one-argument @code{sa_handler} form.
+@end deftypevr
+
@node Initial Signal Actions
@subsection Initial Signal Actions
@cindex initial signal actions

220
glibc-RHEL-108974-13.patch Normal file
View File

@ -0,0 +1,220 @@
commit a3a5634d9b0e193502d16488205452598dc4aa74
Author: Arjun Shankar <arjun@redhat.com>
Date: Tue Jan 14 02:52:09 2025 +0100
manual: Consolidate POSIX Semaphores docs in Threads chapter
This commit moves the `sem_*' family of functions from the IPC chapter,
replacing them with a reference to their new location in the Threads
chapter. `sem_clockwait' is also moved out of the Non-POSIX Extensions
subsection since it is now included in the standard since Issue 8:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/sem_clockwait.html
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/manual/ipc.texi b/manual/ipc.texi
index 32c5ac066fb94579..f9c763835961ec32 100644
--- a/manual/ipc.texi
+++ b/manual/ipc.texi
@@ -46,71 +46,6 @@ by @theglibc{}.
@end deftypefun
@subsection POSIX Semaphores
-
-@deftypefun int sem_init (sem_t *@var{sem}, int @var{pshared}, unsigned int @var{value})
-@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
-@c Does not atomically update sem_t therefore AC-unsafe
-@c because it can leave sem_t partially initialized.
-@end deftypefun
-
-@deftypefun int sem_destroy (sem_t *@var{sem})
-@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
-@c Function does nothing and is therefore always safe.
-@end deftypefun
-
-@deftypefun {sem_t *} sem_open (const char *@var{name}, int @var{oflag}, ...)
-@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acuinit{}}}
-@c pthread_once asuinit
-@c
-@c We are AC-Unsafe because we use pthread_once to initialize
-@c a global variable that holds the location of the mounted
-@c shmfs on Linux.
-@end deftypefun
-
-@deftypefun int sem_close (sem_t *@var{sem})
-@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
-@c lll_lock asulock aculock
-@c twalk mtsrace{:root}
-@c
-@c We are AS-unsafe because we take a non-recursive lock.
-@c We are AC-unsafe because several internal data structures
-@c are not updated atomically.
-@end deftypefun
-
-@deftypefun int sem_unlink (const char *@var{name})
-@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acucorrupt{}}}
-@c pthread_once asuinit acucorrupt aculock
-@c mempcpy acucorrupt
-@end deftypefun
-
-@deftypefun int sem_wait (sem_t *@var{sem})
-@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
-@c atomic_fetch_add_relaxed (nwaiters) acucorrupt
-@c
-@c Given the use atomic operations this function seems
-@c to be AS-safe. It is AC-unsafe because there is still
-@c a window between atomic_fetch_add_relaxed and the pthread_push
-@c of the handler that undoes that operation. A cancellation
-@c at that point would fail to remove the process from the
-@c waiters count.
-@end deftypefun
-
-@deftypefun int sem_timedwait (sem_t *@var{sem}, const struct timespec *@var{abstime})
-@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
-@c Same safety issues as sem_wait.
-@end deftypefun
-
-@deftypefun int sem_trywait (sem_t *@var{sem})
-@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
-@c All atomic operations are safe in all contexts.
-@end deftypefun
-
-@deftypefun int sem_post (sem_t *@var{sem})
-@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
-@c Same safety as sem_trywait.
-@end deftypefun
-
-@deftypefun int sem_getvalue (sem_t *@var{sem}, int *@var{sval})
-@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
-@c Atomic write of a value is safe in all contexts.
-@end deftypefun
+@Theglibc{} provides POSIX semaphores as well. These functions' names begin
+with @code{sem_} and they are declared in @file{semaphore.h}. @xref{POSIX
+Semaphores}.
diff --git a/manual/threads.texi b/manual/threads.texi
index 9ea137cb9663b89c..806ab866c5231015 100644
--- a/manual/threads.texi
+++ b/manual/threads.texi
@@ -554,6 +554,8 @@ This section describes the @glibcadj{} POSIX Threads implementation.
@menu
* Thread-specific Data:: Support for creating and
managing thread-specific data
+* POSIX Semaphores:: Support for process and thread
+ synchronization using semaphores
* Non-POSIX Extensions:: Additional functions to extend
POSIX Thread functionality
@end menu
@@ -615,6 +617,86 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
@end deftypefun
+@node POSIX Semaphores
+@subsection POSIX Semaphores
+
+@deftypefun int sem_init (sem_t *@var{sem}, int @var{pshared}, unsigned int @var{value})
+@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
+@c Does not atomically update sem_t therefore AC-unsafe
+@c because it can leave sem_t partially initialized.
+@end deftypefun
+
+@deftypefun int sem_destroy (sem_t *@var{sem})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@c Function does nothing and is therefore always safe.
+@end deftypefun
+
+@deftypefun {sem_t *} sem_open (const char *@var{name}, int @var{oflag}, ...)
+@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acuinit{}}}
+@c pthread_once asuinit
+@c
+@c We are AC-Unsafe because we use pthread_once to initialize
+@c a global variable that holds the location of the mounted
+@c shmfs on Linux.
+@end deftypefun
+
+@deftypefun int sem_close (sem_t *@var{sem})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@c lll_lock asulock aculock
+@c twalk mtsrace{:root}
+@c
+@c We are AS-unsafe because we take a non-recursive lock.
+@c We are AC-unsafe because several internal data structures
+@c are not updated atomically.
+@end deftypefun
+
+@deftypefun int sem_unlink (const char *@var{name})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acucorrupt{}}}
+@c pthread_once asuinit acucorrupt aculock
+@c mempcpy acucorrupt
+@end deftypefun
+
+@deftypefun int sem_wait (sem_t *@var{sem})
+@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
+@c atomic_fetch_add_relaxed (nwaiters) acucorrupt
+@c
+@c Given the use atomic operations this function seems
+@c to be AS-safe. It is AC-unsafe because there is still
+@c a window between atomic_fetch_add_relaxed and the pthread_push
+@c of the handler that undoes that operation. A cancellation
+@c at that point would fail to remove the process from the
+@c waiters count.
+@end deftypefun
+
+@deftypefun int sem_timedwait (sem_t *@var{sem}, const struct timespec *@var{abstime})
+@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
+@c Same safety issues as sem_wait.
+@end deftypefun
+
+@deftypefun int sem_clockwait (sem_t *@var{sem}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Behaves like @code{sem_timedwait} except the time @var{abstime} is measured
+against the clock specified by @var{clockid} rather than
+@code{CLOCK_REALTIME}. Currently, @var{clockid} must be either
+@code{CLOCK_MONOTONIC} or @code{CLOCK_REALTIME}.
+@end deftypefun
+
+@deftypefun int sem_trywait (sem_t *@var{sem})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@c All atomic operations are safe in all contexts.
+@end deftypefun
+
+@deftypefun int sem_post (sem_t *@var{sem})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@c Same safety as sem_trywait.
+@end deftypefun
+
+@deftypefun int sem_getvalue (sem_t *@var{sem}, int *@var{sval})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@c Atomic write of a value is safe in all contexts.
+@end deftypefun
+
+
@node Non-POSIX Extensions
@subsection Non-POSIX Extensions
@@ -752,16 +834,6 @@ freed.
@Theglibc{} provides several waiting functions that expect an explicit
@code{clockid_t} argument.
-@comment semaphore.h
-@comment POSIX-proposed
-@deftypefun int sem_clockwait (sem_t *@var{sem}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
-@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
-Behaves like @code{sem_timedwait} except the time @var{abstime} is measured
-against the clock specified by @var{clockid} rather than
-@code{CLOCK_REALTIME}. Currently, @var{clockid} must be either
-@code{CLOCK_MONOTONIC} or @code{CLOCK_REALTIME}.
-@end deftypefun
-
@comment pthread.h
@comment POSIX-proposed
@deftypefun int pthread_cond_clockwait (pthread_cond_t *@var{cond}, pthread_mutex_t *@var{mutex}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
@@ -835,6 +907,9 @@ Currently, @var{clockid} must be either @code{CLOCK_MONOTONIC} or
@code{CLOCK_REALTIME}.
@end deftypefun
+The @code{sem_clockwait} function also works using a @code{clockid_t}
+argument. @xref{POSIX Semaphores}.
+
@node Single-Threaded
@subsubsection Detecting Single-Threaded Execution

111
glibc-RHEL-108974-14.patch Normal file
View File

@ -0,0 +1,111 @@
commit 47c4f4045caaaad1e6165cb638e45d633d6ca97f
Author: Arjun Shankar <arjun@redhat.com>
Date: Tue Jan 14 02:52:10 2025 +0100
manual: Add links to POSIX Semaphores man-pages documentation
The POSIX Semaphores functions are currently undocumented in our info
pages. This commit adds links to the man-pages documentation for all
the `sem_*' functions (except `sem_clockwait') so that they refer to
some useful documentation instead of just being stubs. `sem_clockwait'
isn't documented by man-pages but thankfully already has a small useful
blurb in our own docs.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/manual/threads.texi b/manual/threads.texi
index 806ab866c5231015..7b9c79636c9cc79c 100644
--- a/manual/threads.texi
+++ b/manual/threads.texi
@@ -621,18 +621,24 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
@subsection POSIX Semaphores
@deftypefun int sem_init (sem_t *@var{sem}, int @var{pshared}, unsigned int @var{value})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
+@manpagefunctionstub{sem_init,3}
@c Does not atomically update sem_t therefore AC-unsafe
@c because it can leave sem_t partially initialized.
@end deftypefun
@deftypefun int sem_destroy (sem_t *@var{sem})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@manpagefunctionstub{sem_destroy,3}
@c Function does nothing and is therefore always safe.
@end deftypefun
@deftypefun {sem_t *} sem_open (const char *@var{name}, int @var{oflag}, ...)
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acuinit{}}}
+@manpagefunctionstub{sem_open,3}
@c pthread_once asuinit
@c
@c We are AC-Unsafe because we use pthread_once to initialize
@@ -641,7 +647,9 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
@end deftypefun
@deftypefun int sem_close (sem_t *@var{sem})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@manpagefunctionstub{sem_close,3}
@c lll_lock asulock aculock
@c twalk mtsrace{:root}
@c
@@ -651,13 +659,17 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
@end deftypefun
@deftypefun int sem_unlink (const char *@var{name})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acucorrupt{}}}
+@manpagefunctionstub{sem_unlink,3}
@c pthread_once asuinit acucorrupt aculock
@c mempcpy acucorrupt
@end deftypefun
@deftypefun int sem_wait (sem_t *@var{sem})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
+@manpagefunctionstub{sem_wait,3}
@c atomic_fetch_add_relaxed (nwaiters) acucorrupt
@c
@c Given the use atomic operations this function seems
@@ -669,11 +681,14 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
@end deftypefun
@deftypefun int sem_timedwait (sem_t *@var{sem}, const struct timespec *@var{abstime})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
+@manpagefunctionstub{sem_timedwait,3}
@c Same safety issues as sem_wait.
@end deftypefun
@deftypefun int sem_clockwait (sem_t *@var{sem}, clockid_t @var{clockid}, const struct timespec *@var{abstime})
+@standards{POSIX.1-2024, semaphore.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
Behaves like @code{sem_timedwait} except the time @var{abstime} is measured
against the clock specified by @var{clockid} rather than
@@ -682,17 +697,23 @@ against the clock specified by @var{clockid} rather than
@end deftypefun
@deftypefun int sem_trywait (sem_t *@var{sem})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@manpagefunctionstub{sem_trywait,3}
@c All atomic operations are safe in all contexts.
@end deftypefun
@deftypefun int sem_post (sem_t *@var{sem})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@manpagefunctionstub{sem_post,3}
@c Same safety as sem_trywait.
@end deftypefun
@deftypefun int sem_getvalue (sem_t *@var{sem}, int *@var{sval})
+@standards{POSIX.1-2008, semaphore.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@manpagefunctionstub{sem_getvalue,3}
@c Atomic write of a value is safe in all contexts.
@end deftypefun

View File

@ -0,0 +1,31 @@
commit 1b29cb7b781ecf3f6dc4647c32861119bacbd5ef
Author: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
Date: Tue Jan 28 15:31:01 2025 -0300
manual: Safety annotations for timespec_get and timespec_getres
Add preliminary annotations that are consistent with clock_gettime and
clock_getres.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/time.texi b/manual/time.texi
index 6ccb07fcfc10449b..6abae3f43640e8ec 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -595,6 +595,7 @@ Systems may support more than just this @w{ISO C} clock.
@deftypefun int timespec_get (struct timespec *@var{ts}, int @var{base})
@standards{ISO, time.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Store into @code{*@var{ts}} the current time according to the @w{ISO
C} time @var{base}.
@@ -603,6 +604,7 @@ The return value is @var{base} on success and @code{0} on failure.
@deftypefun int timespec_getres (struct timespec *@var{res}, int @var{base})
@standards{ISO, time.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
If @var{ts} is non-null, store into @code{*@var{ts}} the resolution of
the time provided by @code{timespec_get} function for the @w{ISO C}
time @var{base}.

View File

@ -0,0 +1,94 @@
commit 37a0933e1bf97346b45463bde0c4631be8abaa07
Author: DJ Delorie <dj@redhat.com>
Date: Tue Dec 10 16:57:21 2024 -0500
manual: make @manpageurl more specific to each output
Tweak the @manpageurl macro to customize the output for
each of html, info, and pdf output. HTML and PDF (at
least, these days) support clicking on the link title,
whereas info does not. Add text to the intro section
explaining which man pages are normative and which
aren't.
diff --git a/manual/intro.texi b/manual/intro.texi
index 879c1b38d9b73a46..d95648468db6f224 100644
--- a/manual/intro.texi
+++ b/manual/intro.texi
@@ -966,13 +966,25 @@ functionality is available on commercial systems.
@Theglibc{} includes by reference the Linux man-pages
@value{man_pages_version} documentation to document the listed
-syscalls for the Linux kernel. For reference purposes only the latest
+syscalls for the Linux kernel. For reference purposes only, the latest
@uref{https://www.kernel.org/doc/man-pages/,Linux man-pages Project}
documentation can be accessed from the
@uref{https://www.kernel.org,Linux kernel} website. Where the syscall
has more specific documentation in this manual that more specific
documentation is considered authoritative.
+Throughout this manual, when we refer to a man page, for example:
+@quotation
+@manpageurl{sendmsg,2}
+@end quotation
+@noindent
+we are referring primarily to the specific version noted above (the
+``normative'' version), typically accessed by running (for example)
+@code{man 2 sendmsg} on a system with that version installed. For
+convenience, we will also link to the online latest copy of the man
+pages, but keep in mind that version will almost always be newer than,
+and thus different than, the normative version noted above.
+
Additional details on the Linux system call interface can be found in
@xref{System Calls}.
diff --git a/manual/macros.texi b/manual/macros.texi
index f48dd4ec2282634f..2003ce2678054ae4 100644
--- a/manual/macros.texi
+++ b/manual/macros.texi
@@ -282,14 +282,22 @@ cwd\comments\
@macro standardsx {element, standard, header}
@end macro
+@ifhtml
@macro manpageurl {func, sec}
-@url{https://man7.org/linux/man-pages/man\sec\/\func\.\sec\.html}
+@url{https://man7.org/linux/man-pages/man\sec\/\func\.\sec\.html,,\func\(\sec\)}
+@xref{Linux Kernel}
@end macro
+@end ifhtml
+@ifnothtml
+@macro manpageurl {func, sec}
+\func\(\sec\) (Latest, online: @url{https://man7.org/linux/man-pages/man\sec\/\func\.\sec\.html})
+@xref{Linux Kernel}
+@end macro
+@end ifnothtml
@macro manpagefunctionstub {func,sec}
This documentation is a stub. For additional information on this
function, consult the manual page @manpageurl{\func\,\sec\}.
-@xref{Linux Kernel}.
@end macro
@end ifclear
diff --git a/manual/resource.texi b/manual/resource.texi
index 6729ada79402f0ad..23952a6b8b9f4f58 100644
--- a/manual/resource.texi
+++ b/manual/resource.texi
@@ -966,7 +966,6 @@ scheduling policies.
For additional information about scheduling policies, consult consult
the manual pages @manpageurl{sched,7} and @manpageurl{sched_setattr,2}.
-@xref{Linux Kernel}.
@strong{Note:} Calling the @code{sched_setattr} function is incompatible
with support for @code{PTHREAD_PRIO_PROTECT} mutexes.
@@ -1000,7 +999,7 @@ Scheduling flags associated with the scheduling policy.
In addition to the generic fields, policy-specific fields are available.
For additional information, consult the manual page
-@manpageurl{sched_setattr,2}. @xref{Linux Kernel}.
+@manpageurl{sched_setattr,2}.
@end deftp
@deftypefun int sched_setattr (pid_t @var{tid}, struct sched_attr *@var{attr}, unsigned int flags)

View File

@ -0,0 +1,86 @@
commit bb6496b96444dfd55d7105396780f6eba14b1cd9
Author: DJ Delorie <dj@redhat.com>
Date: Fri Jan 17 17:34:02 2025 -0500
manual: Update signal descriptions
Based on auditing all the signals and source trees for Hurd and
Linux...
SIGSYS - This is not used for a bad system call (ENOSYS is used
for that). This is used by SECCOMP and some cases where an invalid
sub-function was requested.
SIGSTKFLT - Note it used to be a coprocessor stack fault but is now
obsolete and available for general user use.
SIGLOST - Hurd only now; note that its original purpose as an NFS
lock lost signal is obsolete.
SIGPWR - Note this is for power lost *and* power restored, and is
more a user-mode signal than a kernel-generated signal.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/signal.texi b/manual/signal.texi
index 2012980efe5e2ccc..842b4e49a275bd3b 100644
--- a/manual/signal.texi
+++ b/manual/signal.texi
@@ -427,9 +427,18 @@ failure to properly emulate them.
@deftypevr Macro int SIGSYS
@standards{Unix, signal.h}
-Bad system call; that is to say, the instruction to trap to the
-operating system was executed, but the code number for the system call
-to perform was invalid.
+System call event. This signal may be generated by a valid system
+call which requested an invalid sub-function, and also by the SECCOMP
+filter when it filters or traps a system call.
+
+If the system call itself is invalid or unsupported by the kernel, the
+call will not raise this signal, but will return @code{ENOSYS}.
+@end deftypevr
+
+@deftypevr Macro int SIGSTKFLT
+Coprocessor stack fault. Obsolete, no longer generated. This signal
+may be used by applications in much the way @code{SIGUSR1} and
+@code{SIGUSR2} are.
@end deftypevr
@node Termination Signals
@@ -752,12 +761,11 @@ that isn't connected. @xref{Sending Data}.
@deftypevr Macro int SIGLOST
@standards{GNU, signal.h}
@cindex lost resource signal
-Resource lost. This signal is generated when you have an advisory lock
-on an NFS file, and the NFS server reboots and forgets about your lock.
-
-On @gnuhurdsystems{}, @code{SIGLOST} is generated when any server program
-dies unexpectedly. It is usually fine to ignore the signal; whatever
-call was made to the server that died just returns an error.
+Resource lost. On @gnuhurdsystems{}, @code{SIGLOST} is generated when
+any server program dies unexpectedly. It is usually fine to ignore
+the signal; whatever call was made to the server that died just
+returns an error. This signal's original purpose of signalling a lost
+NFS lock is obsolete.
@end deftypevr
@deftypevr Macro int SIGXCPU
@@ -817,6 +825,17 @@ to print some status information about the system and what the process
is doing. Otherwise the default is to do nothing.
@end deftypevr
+@deftypevr Macro int SIGPWR
+@cindex power event signal
+Power lost or restored. On s390x Linux systems, this signal is
+generated when a machine check warning is issued, and is sent to the
+process designated to receive ctrl-alt-del notifications. Otherwise,
+it is up to userspace applications to generate this signal and manage
+notifications as to the type of power event that happened.
+
+The default action is to terminate the process.
+@end deftypevr
+
@node Signal Messages
@subsection Signal Messages
@cindex signal messages

View File

@ -0,0 +1,60 @@
commit 226476e32251b5688eead482a9338c04ce84d715
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Jan 30 10:05:17 2025 -0500
manual: Explain sched_yield semantics with different schedulers
The manual entry for sched_yield mentions that the function call could
be a nop if there are no other tasks with the same absolute priority.
Expand the explanation to include example schedulers on Linux so that
it's clear that sched_yield may not always result in a different task
being scheduled.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Joseph Myers <josmyers@redhat.com>
diff --git a/manual/resource.texi b/manual/resource.texi
index 23952a6b8b9f4f58..685ddd6defc57818 100644
--- a/manual/resource.texi
+++ b/manual/resource.texi
@@ -929,18 +929,31 @@ function, so there are no specific @code{errno} values.
@c Direct syscall on Linux; alias to swtch on HURD.
This function voluntarily gives up the task's claim on the CPU.
-
-Technically, @code{sched_yield} causes the calling task to be made
-immediately ready to run (as opposed to running, which is what it was
-before). This means that if it has absolute priority higher than 0, it
-gets pushed onto the tail of the queue of tasks that share its
+Depending on the scheduling policy in effect and the tasks ready to run
+on the system, another task may be scheduled to run instead.
+
+A call to @code{sched_yield} does not guarantee that a different task
+from the calling task is scheduled as a result; it depends on the
+scheduling policy used on the target system. It is possible that the
+call may not result in any visible effect, i.e., the same task gets
+scheduled again.
+
+For example on Linux systems, when a simple priority-based FIFO
+scheduling policy (@code{SCHED_FIFO}) is in effect, the calling task is
+made immediately ready to run (as opposed to running, which is what it
+was before). This means that if it has absolute priority higher than 0,
+it gets pushed onto the tail of the queue of tasks that share its
absolute priority and are ready to run, and it will run again when its
turn next arrives. If its absolute priority is 0, it is more
complicated, but still has the effect of yielding the CPU to other
-tasks.
-
-If there are no other tasks that share the calling task's absolute
-priority, this function doesn't have any effect.
+tasks. If there are no other tasks that share the calling task's
+absolute priority, it will be scheduled again as if @code{sched_yield}
+was never called.
+
+Another example could be a time slice based preemptive round-robin
+policy, such as the @code{SCHED_RR} policy on Linux. It is possible
+with this policy that the calling task is scheduled again because it
+still has time left in its slice.
To the extent that the containing program is oblivious to what other
processes in the system are doing and how fast it executes, this

View File

@ -0,0 +1,65 @@
commit f451a02a8c3c0bc6b41dac5e9e6ad49dd1c9529c
Author: Joseph Myers <josmyers@redhat.com>
Date: Mon May 12 14:56:07 2025 +0000
Document all CLOCK_* values
The manual documents CLOCK_REALTIME and CLOCK_MONOTONIC but not other
CLOCK_* values. Add documentation of the POSIX clocks
CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, along with a
reference to the Linux man pages for the semantics of the
Linux-specific clocks supported (as with some other functionality
coming direct from the Linux kernel where the man pages can be
considered the main documentation).
Note: CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE and
CLOCK_MONOTONIC_COARSE are also defined in the toplevel bits/time.h,
as used for Hurd. Nevertheless, I see no sign that the Hurd code in
glibc actually has any support for those clocks, so I think it is
correct to document them as Linux-specific (and to refer only to the
Linux man pages for their semantics).
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/time.texi b/manual/time.texi
index 6abae3f43640e8ec..4dde875dde4d8075 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -528,7 +528,36 @@ Therefore, @code{CLOCK_MONOTONIC} cannot be used to measure
absolute time, only elapsed time.
@end deftypevr
-Systems may support more than just these two POSIX clocks.
+The following clocks are defined by POSIX, but may not be supported by
+all POSIX systems:
+
+@deftypevr Macro clockid_t CLOCK_PROCESS_CPUTIME_ID
+@standards{POSIX.1, time.h}
+This POSIX clock measures the amount of CPU time used by the calling
+process.
+@end deftypevr
+
+@deftypevr Macro clockid_t CLOCK_THREAD_CPUTIME_ID
+@standards{POSIX.1, time.h}
+This POSIX clock measures the amount of CPU time used by the calling
+thread.
+@end deftypevr
+
+The following clocks are Linux extensions:
+
+@deftypevr Macro clockid_t CLOCK_MONOTONIC_RAW
+@deftypevrx Macro clockid_t CLOCK_REALTIME_COARSE
+@deftypevrx Macro clockid_t CLOCK_MONOTONIC_COARSE
+@deftypevrx Macro clockid_t CLOCK_BOOTTIME
+@deftypevrx Macro clockid_t CLOCK_REALTIME_ALARM
+@deftypevrx Macro clockid_t CLOCK_BOOTTIME_ALARM
+@deftypevrx Macro clockid_t CLOCK_TAI
+@standards{Linux, time.h}
+For details of these clocks, see the manual page
+@manpageurl{clock_gettime,2}.
+@end deftypevr
+
+Systems may support additional clocks beyond those listed here.
@deftypefun int clock_gettime (clockid_t @var{clock}, struct timespec *@var{ts})
@standards{POSIX.1, time.h}

1893
glibc-RHEL-108974-2.patch Normal file

File diff suppressed because it is too large Load Diff

144
glibc-RHEL-108974-20.patch Normal file
View File

@ -0,0 +1,144 @@
commit 6c9bb270d6a624f82a38443545e3d99f5b1e07e1
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri May 16 16:47:02 2025 +0200
manual: Clarifications for listing directories
Support for seeking is limited. Using the d_off and d_reclen members
of struct dirent is discouraged, especially with readdir. Concurrent
modification of directories during iteration may result in duplicate
or missing etnries.
diff --git a/manual/filesys.texi b/manual/filesys.texi
index aabb68385b6b9732..450d175e614d8834 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -409,18 +409,41 @@ entries. It contains the following fields:
This is the null-terminated file name component. This is the only
field you can count on in all POSIX systems.
+While this field is defined with a specified length, functions such as
+@code{readdir} may return a pointer to a @code{struct dirent} where the
+@code{d_name} extends beyond the end of the struct.
+
@item ino_t d_fileno
This is the file serial number. For BSD compatibility, you can also
refer to this member as @code{d_ino}. On @gnulinuxhurdsystems{} and most POSIX
systems, for most files this the same as the @code{st_ino} member that
@code{stat} will return for the file. @xref{File Attributes}.
+@item off_t d_off
+This value contains the offset of the next directory entry (after this
+entry) in the directory stream. The value may not be compatible with
+@code{lseek} or @code{seekdir}, especially if the width of @code{d_off}
+is less than 64 bits. Directory entries are not ordered by offset, and
+the @code{d_off} and @code{d_reclen} values are unrelated. Seeking on
+directory streams is not recommended. The symbol
+@code{_DIRENT_HAVE_D_OFF} is defined if the @code{d_ino} member is
+available.
+
@item unsigned char d_namlen
This is the length of the file name, not including the terminating
null character. Its type is @code{unsigned char} because that is the
integer type of the appropriate size. This member is a BSD extension.
The symbol @code{_DIRENT_HAVE_D_NAMLEN} is defined if this member is
-available.
+available. (It is not available on Linux.)
+
+@item unsigned short int d_reclen
+This is the length of the entire directory record. When iterating
+through a buffer filled by @code{getdents64} (@pxref{Low-level Directory
+Access}), this value needs to be added to the offset of the current
+directory entry to obtain the offset of the next entry. When using
+@code{readdir} and related functions, the value of @code{d_reclen} is
+undefined and should not be accessed. The symbol
+@code{_DIRENT_HAVE_D_RECLEN} is defined if this member is available.
@item unsigned char d_type
This is the type of the file, possibly unknown. The following constants
@@ -457,7 +480,7 @@ This member is a BSD extension. The symbol @code{_DIRENT_HAVE_D_TYPE}
is defined if this member is available. On systems where it is used, it
corresponds to the file type bits in the @code{st_mode} member of
@code{struct stat}. If the value cannot be determined the member
-value is DT_UNKNOWN. These two macros convert between @code{d_type}
+value is @code{DT_UNKNOWN}. These two macros convert between @code{d_type}
values and @code{st_mode} values:
@deftypefun int IFTODT (mode_t @var{mode})
@@ -632,6 +655,20 @@ and can be rewritten by a subsequent call.
return entries for @file{.} and @file{..}, even though these are always
valid file names in any directory. @xref{File Name Resolution}.
+If a directory is modified between a call to @code{readdir} and after
+the directory stream was created or @code{rewinddir} was last called on
+it, it is unspecified according to POSIX whether newly created or
+removed entries appear among the entries returned by repeated
+@code{readdir} calls before the end of the directory is reached.
+However, due to practical implementation constraints, it is possible
+that entries (including unrelated, unmodified entries) appear multiple
+times or do not appear at all if the directory is modified while listing
+it. If the application intends to create files in the directory, it may
+be necessary to complete the iteration first and create a copy of the
+information obtained before creating any new files. (See below for
+instructions regarding copying of @code{d_name}.) The iteration can be
+restarted using @code{rewinddir}. @xref{Random Access Directory}.
+
If there are no more entries in the directory or an error is detected,
@code{readdir} returns a null pointer. The following @code{errno} error
conditions are defined for this function:
@@ -812,6 +849,10 @@ directory since it was opened with @code{opendir}. (Entries for these
files might or might not be returned by @code{readdir} if they were
added or removed since you last called @code{opendir} or
@code{rewinddir}.)
+
+For example, it is recommended to call @code{rewinddir} followed by
+@code{readdir} to check if a directory is empty after listing it with
+@code{readdir} and deleting all encountered files from it.
@end deftypefun
@deftypefun {long int} telldir (DIR *@var{dirstream})
@@ -823,6 +864,13 @@ added or removed since you last called @code{opendir} or
The @code{telldir} function returns the file position of the directory
stream @var{dirstream}. You can use this value with @code{seekdir} to
restore the directory stream to that position.
+
+Using the the @code{telldir} function is not recommended.
+
+The value returned by @code{telldir} may not be compatible with the
+@code{d_off} field in @code{struct dirent}, and cannot be used with the
+@code{lseek} function. The returned value may not unambiguously
+identify the position in the directory stream.
@end deftypefun
@deftypefun void seekdir (DIR *@var{dirstream}, long int @var{pos})
@@ -836,6 +884,9 @@ stream @var{dirstream} to @var{pos}. The value @var{pos} must be the
result of a previous call to @code{telldir} on this particular stream;
closing and reopening the directory can invalidate values returned by
@code{telldir}.
+
+Using the the @code{seekdir} function is not recommended. To seek to
+the beginning of the directory stream, use @code{rewinddir}.
@end deftypefun
@@ -1007,9 +1058,20 @@ Note that some file systems support file names longer than
@code{NAME_MAX} bytes (e.g., because they support up to 255 Unicode
characters), so a buffer size of at least 1024 is recommended.
+If the directory has been modified since the first call to
+@code{getdents64} on the directory (opening the descriptor or seeking to
+offset zero), it is possible that the buffer contains entries that have
+been encountered before. Likewise, it is possible that files that are
+still present are not reported before the end of the directory is
+encountered (and @code{getdents64} returns zero).
+
This function is specific to Linux.
@end deftypefun
+Systems that support @code{getdents64} support seeking on directory
+streams. @xref{File Position Primitive}. However, the only offset that
+works reliably is offset zero, indicating that reading the directory
+should start from the beginning.
@node Working with Directory Trees
@section Working with Directory Trees

View File

@ -0,0 +1,67 @@
commit 43afae31e0d7579deef13536c4c3704afaa017da
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Thu May 29 22:11:38 2025 +0100
manual: Document error codes missing for 'socket'
Add missing EAFNOSUPPORT, ESOCKTNOSUPPORT, EPROTOTYPE, EINVAL, EPERM,
and ENOMEM error codes, and adjust existing descriptions accordingly.
On Linux either ENOBUFS or ENOMEM is returned in the case of a memory
allocation failure, depending on the namespace requested, e.g. AF_INET
returns ENOMEM while AF_INET6 returns ENOBUFS, so document these codes
as alternatives.
Similarly EPERM is returned rather than EACCES on Linux, so document
these codes as alternatives as well. We might want to convert EPERM to
EACCES for POSIX compliance, but it is beyond the scope of this change,
and software has to expect either anyway, owing to the long-established
practice.
Finally ESOCKTNOSUPPORT is returned rather than EPROTONOSUPPORT for an
unsupported style except for the AF_QIPCRTR namespace where EPROTOTYPE
is used, so document these codes as alternatives too.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/socket.texi b/manual/socket.texi
index 8708cbb07ca02b5c..ed24cd5bd41ce8c0 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -2205,9 +2205,19 @@ socket, or @code{-1} in case of error. The following @code{errno} error
conditions are defined for this function:
@table @code
+@item EAFNOSUPPORT
+The @var{namespace} requested is not supported.
+
+@item ESOCKTNOSUPPORT
+@itemx EPROTONOSUPPORT
+@itemx EPROTOTYPE
+The @var{style} is not supported by the @var{namespace} specified.
+
@item EPROTONOSUPPORT
-The @var{protocol} or @var{style} is not supported by the
-@var{namespace} specified.
+The @var{protocol} is not supported by the @var{namespace} specified.
+
+@item EINVAL
+The @var{style} or @var{protocol} requested is not valid.
@item EMFILE
The process already has too many file descriptors open.
@@ -2216,11 +2226,13 @@ The process already has too many file descriptors open.
The system already has too many file descriptors open.
@item EACCES
+@itemx EPERM
The process does not have the privilege to create a socket of the specified
@var{style} or @var{protocol}.
@item ENOBUFS
-The system ran out of internal buffer space.
+@itemx ENOMEM
+Insufficient memory was available.
@end table
The file descriptor returned by the @code{socket} function supports both

View File

@ -0,0 +1,36 @@
commit 79b5febd762d6735ba8e878086a50ea04993e340
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Thu May 29 22:11:38 2025 +0100
manual: Document error codes missing for 'inet_ntop'
Add documentation for EAFNOSUPPORT and ENOSPC error codes returned, and
the return value on failure.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/socket.texi b/manual/socket.texi
index ed24cd5bd41ce8c0..2f0e7509e92974d1 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -1211,7 +1211,19 @@ network (binary) to presentation (textual) form. @var{af} should be
either @code{AF_INET} or @code{AF_INET6}, as appropriate. @var{cp} is a
pointer to the address to be converted. @var{buf} should be a pointer
to a buffer to hold the result, and @var{len} is the length of this
-buffer. The return value from the function will be this buffer address.
+buffer.
+
+The return value is @var{buf} on success. On failure, the function's
+return value is a null pointer and @code{errno} is set accordingly.
+The following @code{errno} values are specific to this function:
+
+@table @code
+@item EAFNOSUPPORT
+The address family requested is neither @code{AF_INET} nor @code{AF_INET6}.
+
+@item ENOSPC
+Insufficient space available for the result in the buffer provided.
+@end table
@end deftypefun
@node Host Names

View File

@ -0,0 +1,23 @@
commit 9a743032cd59c59167bf615d8ab4acc96b2bf47e
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Fri May 30 15:01:51 2025 +0100
manual: Fix invalid 'illegal' usage with 'nanosleep'
The GNU Coding Standards demand that 'illegal' only be used to refer to
activities prohibited by law. Replace it with 'invalid' accordingly in
the description of the EINVAL error condition for 'nanosleep'.
diff --git a/manual/time.texi b/manual/time.texi
index 4dde875dde4d8075..e754d3a7e7f5c52d 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -3212,7 +3212,7 @@ elapsed time.
@item EINVAL
The nanosecond value in the @var{requested_time} parameter contains an
-illegal value. Either the value is negative or greater than or equal to
+invalid value. Either the value is negative or greater than or equal to
1000 million.
@end table

121
glibc-RHEL-108974-24.patch Normal file
View File

@ -0,0 +1,121 @@
commit 1a3d8f2201d4d613401ce5be9a283f4f28c43093
Author: Arjun Shankar <arjun@redhat.com>
Date: Fri May 30 02:09:50 2025 +0200
manual: Document clock_nanosleep
Make minor clarifications in the documentation for 'nanosleep' and add
an entry for 'clock_nanosleep' as a generalized variant of the former
function that allows clock selection.
Reviewed-by: Maciej W. Rozycki <macro@redhat.com>
diff --git a/manual/time.texi b/manual/time.texi
index e754d3a7e7f5c52d..60e4d4b6fab1482b 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -3179,12 +3179,12 @@ On @gnusystems{}, it is safe to use @code{sleep} and @code{SIGALRM} in
the same program, because @code{sleep} does not work by means of
@code{SIGALRM}.
-@deftypefun int nanosleep (const struct timespec *@var{requested_time}, struct timespec *@var{remaining})
+@deftypefun int nanosleep (const struct timespec *@var{requested_time}, struct timespec *@var{remaining_time})
@standards{POSIX.1, time.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c On Linux, it's a syscall. On Mach, it calls gettimeofday and uses
@c ports.
-If resolution to seconds is not enough the @code{nanosleep} function can
+If resolution to seconds is not enough, the @code{nanosleep} function can
be used. As the name suggests the sleep interval can be specified in
nanoseconds. The actual elapsed time of the sleep interval might be
longer since the system rounds the elapsed time you request up to the
@@ -3193,21 +3193,22 @@ next integer multiple of the actual resolution the system can deliver.
@code{*@var{requested_time}} is the elapsed time of the interval you
want to sleep.
-The function returns as @code{*@var{remaining}} the elapsed time left
-in the interval for which you requested to sleep. If the interval
-completed without getting interrupted by a signal, this is zero.
+If @var{remaining_time} is not the null pointer, the function returns as
+@code{*@var{remaining_time}} the elapsed time left in the interval for which
+you requested to sleep. If the interval completed without getting
+interrupted by a signal, this is zero.
@code{struct timespec} is described in @ref{Time Types}.
-If the function returns because the interval is over the return value is
-zero. If the function returns @math{-1} the global variable @code{errno}
+If the function returns because the interval is over, the return value is
+zero. If the function returns @math{-1}, the global variable @code{errno}
is set to the following values:
@table @code
@item EINTR
The call was interrupted because a signal was delivered to the thread.
-If the @var{remaining} parameter is not the null pointer the structure
-pointed to by @var{remaining} is updated to contain the remaining
+If the @var{remaining_time} parameter is not the null pointer, the structure
+pointed to by @var{remaining_time} is updated to contain the remaining
elapsed time.
@item EINVAL
@@ -3219,10 +3220,58 @@ invalid value. Either the value is negative or greater than or equal to
This function is a cancellation point in multi-threaded programs. This
is a problem if the thread allocates some resources (like memory, file
descriptors, semaphores or whatever) at the time @code{nanosleep} is
-called. If the thread gets canceled these resources stay allocated
-until the program ends. To avoid this calls to @code{nanosleep} should
+called. If the thread gets canceled, these resources stay allocated
+until the program ends. To avoid this, calls to @code{nanosleep} should
be protected using cancellation handlers.
@c ref pthread_cleanup_push / pthread_cleanup_pop
The @code{nanosleep} function is declared in @file{time.h}.
@end deftypefun
+
+@deftypefun int clock_nanosleep (clockid_t @var{clock}, int @var{flags}, const struct timespec *@var{requested_time}, struct timespec *@var{remaining_time})
+@standards{POSIX.1-2001, time.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+This function is a generalized variant of @code{nanosleep}, providing the
+caller with a way to specify the clock to be used to measure elapsed time
+and express the sleep interval in absolute or relative terms. The call:
+
+@smallexample
+nanosleep (@var{requested_time}, @var{remaining_time})
+@end smallexample
+
+is equivalent to:
+
+@smallexample
+clock_nanosleep (CLOCK_REALTIME, 0, @var{requested_time}, @var{remaining_time})
+@end smallexample
+
+The @var{clock} argument specifies the clock to use.
+@xref{Getting the Time}, for the @code{clockid_t} type and possible values
+of @var{clock}. Not all clocks listed are supported for use with
+@code{clock_nanosleep}. For details, see the manual page
+@manpageurl{clock_nanosleep,2}.
+
+The @var{flags} argument is either @code{0} or @code{TIMER_ABSTIME}. If
+@var{flags} is @code{0}, then @code{clock_nanosleep} interprets
+@var{requested_time} as an interval relative to the current time specified
+by @var{clock}. If it is @code{TIMER_ABSTIME} instead, @var{requested_time}
+specifies an absolute time measured by @var{clock}; if at the time of the
+call the value requested is less than or equal to the clock specified, then
+the function returns right away. When @var{flags} is @code{TIMER_ABSTIME},
+@var{remaining_time} is not updated.
+
+The return values and error conditions for @code{clock_nanosleep} are the
+same as for @code{nanosleep}, with the following conditions additionally
+defined:
+
+@table @code
+@item EINVAL
+The @var{clock} argument is not a valid clock.
+
+@item EOPNOTSUPP
+The @var{clock} argument is not supported by the kernel for
+@code{clock_nanosleep}.
+@end table
+
+The @code{clock_nanosleep} function is declared in @file{time.h}.
+@end deftypefun

View File

@ -0,0 +1,74 @@
commit 591283a68965fe61a7186c9c81f7812e71b282b4
Author: Arjun Shankar <arjun@redhat.com>
Date: Mon Jun 2 10:41:02 2025 +0200
manual: Correct return value description of 'clock_nanosleep'
Commit 1a3d8f2201d4d613401ce5be9a283f4f28c43093 incorrectly described
'clock_nanosleep' as having the same return values as 'nanosleep'. Fix
this, clarifying that 'clock_nanosleep' returns a positive error number
upon failure instead of setting 'errno'. Also clarify that 'nanosleep'
returns '-1' upon error.
Fixes: 1a3d8f2201d4d613401ce5be9a283f4f28c43093
Reported-by: Mark Harris <mark.hsj@gmail.com>
Reviewed-by: Mark Harris <mark.hsj@gmail.com>
diff --git a/manual/time.texi b/manual/time.texi
index 60e4d4b6fab1482b..a7c276e1e4f074a6 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -3200,9 +3200,9 @@ interrupted by a signal, this is zero.
@code{struct timespec} is described in @ref{Time Types}.
-If the function returns because the interval is over, the return value is
-zero. If the function returns @math{-1}, the global variable @code{errno}
-is set to the following values:
+If the function returns because the interval is over, it returns zero.
+Otherwise it returns @math{-1} and sets the global variable @code{errno} to
+one of the following values:
@table @code
@item EINTR
@@ -3231,19 +3231,14 @@ The @code{nanosleep} function is declared in @file{time.h}.
@deftypefun int clock_nanosleep (clockid_t @var{clock}, int @var{flags}, const struct timespec *@var{requested_time}, struct timespec *@var{remaining_time})
@standards{POSIX.1-2001, time.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
-This function is a generalized variant of @code{nanosleep}, providing the
-caller with a way to specify the clock to be used to measure elapsed time
-and express the sleep interval in absolute or relative terms. The call:
-
-@smallexample
-nanosleep (@var{requested_time}, @var{remaining_time})
-@end smallexample
-
-is equivalent to:
-
-@smallexample
-clock_nanosleep (CLOCK_REALTIME, 0, @var{requested_time}, @var{remaining_time})
-@end smallexample
+This function is similar to @code{nanosleep} while additionally providing
+the caller with a way to specify the clock to be used to measure elapsed
+time and express the sleep interval in absolute or relative terms. It
+returns zero when returning because the interval is over, and a positive
+error number corresponding to the error encountered otherwise. This is
+different from @code{nanosleep}, which returns @math{-1} upon failure and
+sets the global variable @code{errno} according to the error encountered
+instead.
The @var{clock} argument specifies the clock to use.
@xref{Getting the Time}, for the @code{clockid_t} type and possible values
@@ -3260,9 +3255,9 @@ call the value requested is less than or equal to the clock specified, then
the function returns right away. When @var{flags} is @code{TIMER_ABSTIME},
@var{remaining_time} is not updated.
-The return values and error conditions for @code{clock_nanosleep} are the
-same as for @code{nanosleep}, with the following conditions additionally
-defined:
+The @code{clock_nanosleep} function returns error codes as positive return
+values. The error conditions for @code{clock_nanosleep} are the same as for
+@code{nanosleep}, with the following conditions additionally defined:
@table @code
@item EINVAL

View File

@ -0,0 +1,47 @@
commit 46acdf46cc1948187d6540cdf4abee5053cd8bcc
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Wed Jun 4 16:27:20 2025 +0100
manual: Document error codes missing for 'if_indextoname'
Add documentation for ENXIO error code returned and refer to 'socket'
for further possible codes from the underlying function call.
While changing the text clarify the description by mentioning 'ifname'
and replace @code tags with @var ones where referring to a function
parameter.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/socket.texi b/manual/socket.texi
index 2f0e7509e92974d1..a6fb6b1b7e2b0473 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -505,11 +505,22 @@ name. If no interface exists with the name given, it returns 0.
@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{}}}
@c It opens a socket with opensock to use ioctl on the fd to get the
@c name from the index.
-This function maps an interface index to its corresponding name. The
-returned name is placed in the buffer pointed to by @code{ifname}, which
-must be at least @code{IFNAMSIZ} bytes in length. If the index was
-invalid, the function's return value is a null pointer, otherwise it is
-@code{ifname}.
+This function maps an interface index @var{ifindex} to its corresponding
+name. The returned name is placed in the buffer pointed to by @var{ifname},
+which must be at least @code{IFNAMSIZ} bytes in length.
+
+The return value is @var{ifname} on success. On failure, the function's
+return value is a null pointer and @code{errno} is set accordingly. The
+following @code{errno} values are specific to this function:
+
+@table @code
+@item ENXIO
+There is no interface at the index requested.
+@end table
+
+Additionally, since @code{if_indextoname} invokes @code{socket}
+internally, @code{errno} may also be set to a value listed for the
+@code{socket} function (@pxref{Creating a Socket}).
@end deftypefun
@deftp {Data Type} {struct if_nameindex}

View File

@ -0,0 +1,39 @@
commit 5a9020eeb27eee88e7839ff5e9cea94892ec90ff
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Wed Jun 4 16:27:20 2025 +0100
manual: Document error codes missing for 'if_nametoindex'
Add documentation for ENODEV error code returned and refer to 'socket'
for further possible codes from the underlying function call.
While changing the text clarify the description by mentioning 'ifname'.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/socket.texi b/manual/socket.texi
index a6fb6b1b7e2b0473..e8285b9200bbfc6d 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -497,7 +497,20 @@ interface name, including its terminating zero byte.
@c takes a lock, which makes all callers AS- and AC-Unsafe.
@c opensock @asulock @aculock @acsfd
This function yields the interface index corresponding to a particular
-name. If no interface exists with the name given, it returns 0.
+name specified with @var{ifname}.
+
+The return value is the interface index on success. On failure, the
+function's return value is zero and @code{errno} is set accordingly.
+The following @code{errno} values are specific to this function:
+
+@table @code
+@item ENODEV
+There is no interface by the name requested.
+@end table
+
+Additionally, since @code{if_nametoindex} invokes @code{socket}
+internally, @code{errno} may also be set to a value listed for the
+@code{socket} function (@pxref{Creating a Socket}).
@end deftypefun
@deftypefun {char *} if_indextoname (unsigned int @var{ifindex}, char *@var{ifname})

View File

@ -0,0 +1,33 @@
commit 140b20e9716b51659a5223b182dcf07ac62b3f77
Author: Maciej W. Rozycki <macro@redhat.com>
Date: Wed Jun 4 16:27:20 2025 +0100
manual: Document error codes missing for 'inet_pton'
Add documentation for EAFNOSUPPORT error code returned, and the possible
return values on non-success.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/socket.texi b/manual/socket.texi
index e8285b9200bbfc6d..d804c7a48b91b403 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -1216,6 +1216,17 @@ either @code{AF_INET} or @code{AF_INET6}, as appropriate for the type of
address being converted. @var{cp} is a pointer to the input string, and
@var{buf} is a pointer to a buffer for the result. It is the caller's
responsibility to make sure the buffer is large enough.
+
+The return value is @code{1} on success and @code{0} if @var{cp} does not
+point to a valid address string for the address family @var{af} requested.
+On failure, the function's return value is @code{-1} and @code{errno} is
+set accordingly. The following @code{errno} values are specific to this
+function:
+
+@table @code
+@item EAFNOSUPPORT
+The address family requested is neither @code{AF_INET} nor @code{AF_INET6}.
+@end table
@end deftypefun
@deftypefun {const char *} inet_ntop (int @var{af}, const void *@var{cp}, char *@var{buf}, socklen_t @var{len})

View File

@ -0,0 +1,67 @@
commit 3b21166c4d34ee032093bcf599ffac42ad8a4371
Author: Arjun Shankar <arjun@redhat.com>
Date: Wed Jun 4 13:08:53 2025 +0200
manual: Expand Descriptor-Relative Access section
Improve the clarity of the paragraphs describing common flags and add a
list of common error conditions for descriptor-relative functions.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 450d175e614d8834..28d38f23fc58c51f 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -310,12 +310,17 @@ This is a GNU extension.
The flags argument in @code{@dots{}at} functions can be a combination of
the following flags, defined in @file{fcntl.h}. Not all such functions
support all flags, and some (such as @code{openat}) do not accept a
-flags argument at all.
-
-In the flag descriptions below, the @dfn{effective final path component}
-refers to the final component (basename) of the full path constructed
-from the descriptor and file name arguments, using file name lookup, as
-described above.
+flags argument at all. Although the flags specific to each function have
+distinct values from each other, some flags (relevant to different
+functions) might share the same value and therefore are not guaranteed to
+have unique values.
+
+A non-exhaustive list of common flags and their descriptions follows. Flags
+specific to a function are described alongside the function itself. In
+these flag descriptions, the @dfn{effective final path component} refers to
+the final component (basename) of the full path constructed from the
+descriptor and file name arguments, using file name lookup, as described
+above.
@vtable @code
@item AT_EMPTY_PATH
@@ -353,6 +358,28 @@ a non-final component of the file name are still followed.
argument to the @code{getauxval} function (with @code{AT_@dots{}}
constants defined in @file{elf.h}). @xref{Auxiliary Vector}.
+@cindex common errors in descriptor-relative functions
+@cindex common errors in @code{@dots{}at} functions
+
+The @code{@dots{}at} functions have some common error conditions due to the
+nature of descriptor-relative access. A list of common errors and their
+descriptions follows. Errors specific to a function are described alongside
+the function itself.
+
+@table @code
+@item EBADF
+The file name argument is a relative path but the descriptor argument
+is neither @code{AT_FDCWD} nor a valid file descriptor.
+
+@item EINVAL
+If the function accepts a @var{flags} argument, the flag combination passed
+is not valid for the function.
+
+@item ENOTDIR
+The file name argument is a relative file name but the descriptor
+argument is associated with a file that is not a directory.
+@end table
+
@node Accessing Directories
@section Accessing Directories
@cindex accessing directories

206
glibc-RHEL-108974-3.patch Normal file
View File

@ -0,0 +1,206 @@
commit dce754b1553b86fc6352636f1fa490a85b7cf0ff
Author: DJ Delorie <dj@redhat.com>
Date: Fri May 10 14:52:09 2024 -0400
Update mmap() flags and errors lists
Extend the list of MAP_* macros to include all macros available
to the average program (gcc -E -dM | grep MAP_*)
Extend the list of errno codes.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/llio.texi b/manual/llio.texi
index a8ed72c5db6ecba9..be55dca1b7c9ebcd 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -1574,10 +1574,15 @@ permitted. They include @code{PROT_READ}, @code{PROT_WRITE}, and
of address space for future use. The @code{mprotect} function can be
used to change the protection flags. @xref{Memory Protection}.
-@var{flags} contains flags that control the nature of the map.
-One of @code{MAP_SHARED} or @code{MAP_PRIVATE} must be specified.
+The @var{flags} parameter contains flags that control the nature of
+the map. One of @code{MAP_SHARED}, @code{MAP_SHARED_VALIDATE}, or
+@code{MAP_PRIVATE} must be specified. Additional flags may be bitwise
+OR'd to further define the mapping.
-They include:
+Note that, aside from @code{MAP_PRIVATE} and @code{MAP_SHARED}, not
+all flags are supported on all versions of all operating systems.
+Consult the kernel-specific documentation for details. The flags
+include:
@vtable @code
@item MAP_PRIVATE
@@ -1599,9 +1604,19 @@ Note that actual writing may take place at any time. You need to use
@code{msync}, described below, if it is important that other processes
using conventional I/O get a consistent view of the file.
+@item MAP_SHARED_VALIDATE
+Similar to @code{MAP_SHARED} except that additional flags will be
+validated by the kernel, and the call will fail if an unrecognized
+flag is provided. With @code{MAP_SHARED} using a flag on a kernel
+that doesn't support it causes the flag to be ignored.
+@code{MAP_SHARED_VALIDATE} should be used when the behavior of all
+flags is required.
+
@item MAP_FIXED
This forces the system to use the exact mapping address specified in
-@var{address} and fail if it can't.
+@var{address} and fail if it can't. Note that if the new mapping
+would overlap an existing mapping, the overlapping portion of the
+existing map is unmapped.
@c One of these is official - the other is obviously an obsolete synonym
@c Which is which?
@@ -1642,10 +1657,73 @@ The @code{MAP_HUGETLB} flag is specific to Linux.
@c There is a mechanism to select different hugepage sizes; see
@c include/uapi/asm-generic/hugetlb_encode.h in the kernel sources.
-@c Linux has some other MAP_ options, which I have not discussed here.
-@c MAP_DENYWRITE, MAP_EXECUTABLE and MAP_GROWSDOWN don't seem applicable to
-@c user programs (and I don't understand the last two). MAP_LOCKED does
-@c not appear to be implemented.
+@item MAP_32BIT
+Require addresses that can be accessed with a signed 32 bit pointer,
+i.e., within the first 2 GiB. Ignored if MAP_FIXED is specified.
+
+@item MAP_DENYWRITE
+@itemx MAP_EXECUTABLE
+@itemx MAP_FILE
+
+Provided for compatibility. Ignored by the Linux kernel.
+
+@item MAP_FIXED_NOREPLACE
+Similar to @code{MAP_FIXED} except the call will fail with
+@code{EEXIST} if the new mapping would overwrite an existing mapping.
+To test for support for this flag, specify MAP_FIXED_NOREPLACE without
+MAP_FIXED, and (if the call was successful) check the actual address
+returned. If it does not match the address passed, then this flag is
+not supported.
+
+@item MAP_GROWSDOWN
+This flag is used to make stacks, and is typically only needed inside
+the program loader to set up the main stack for the running process.
+The mapping is created according to the other flags, except an
+additional page just prior to the mapping is marked as a ``guard
+page''. If a write is attempted inside this guard page, that page is
+mapped, the mapping is extended, and a new guard page is created.
+Thus, the mapping continues to grow towards lower addresses until it
+encounters some other mapping.
+
+Note that accessing memory beyond the guard page will not trigger this
+feature. In gcc, use @code{-fstack-clash-protection} to ensure the
+guard page is always touched.
+
+@item MAP_LOCKED
+A hint that requests that mapped pages are locked in memory (i.e. not
+paged out). Note that this is a request and not a requirement; use
+@code{mlock} if locking is required.
+
+@item MAP_POPULATE
+@itemx MAP_NONBLOCK
+@code{MAP_POPULATE} is a hint that requests that the kernel read-ahead
+a file-backed mapping, causing pages to be mapped before they're
+needed. @code{MAP_NONBLOCK} is a hint that requests that the kernel
+@emph{not} attempt such except for pages are already in memory. Note
+that neither of these hints affects future paging activity, use
+@code{mlock} if such needs to be controlled.
+
+@item MAP_NORESERVE
+Asks the kernel to not reserve physical backing (i.e. space in a swap
+device) for a mapping. This would be useful for, for example, a very
+large but sparsely used mapping which need not be limited in total
+length by available RAM, but with very few mapped pages. Note that
+writes to such a mapping may cause a @code{SIGSEGV} if the system is
+unable to map a page due to lack of resources.
+
+On Linux, this flag's behavior may be overwridden by
+@file{/proc/sys/vm/overcommit_memory} as documented in the proc(5) man
+page.
+
+@item MAP_STACK
+Ensures that the resulting mapping is suitable for use as a program
+stack. For example, the use of huge pages might be precluded.
+
+@item MAP_SYNC
+This is a special flag for DAX devices, which tells the kernel to
+write dirty metadata out whenever dirty data is written out. Unlike
+most other flags, this one will fail unless @code{MAP_SHARED_VALIDATE}
+is also given.
@item MAP_DROPPABLE
Request the page to be never written out to swap, it will be zeroed
@@ -1665,6 +1743,24 @@ Possible errors include:
@table @code
+@item EACCES
+
+@var{filedes} was not open for the type of access specified in @var{protect}.
+
+@item EAGAIN
+
+The system has temporarily run out of resources.
+
+@item EBADF
+
+The @var{fd} passed is invalid, and a valid file descriptor is
+required (i.e. MAP_ANONYMOUS was not specified).
+
+@item EEXIST
+
+@code{MAP_FIXED_NOREPLACE} was specified and an existing mapping was
+found overlapping the requested address range.
+
@item EINVAL
Either @var{address} was unusable (because it is not a multiple of the
@@ -1673,23 +1769,37 @@ applicable page size), or inconsistent @var{flags} were given.
If @code{MAP_HUGETLB} was specified, the file or system does not support
large page sizes.
-@item EACCES
+@item ENODEV
-@var{filedes} was not open for the type of access specified in @var{protect}.
+This file is of a type that doesn't support mapping, the process has
+exceeded its data space limit, or the map request would exceed the
+process's virtual address space.
@item ENOMEM
-Either there is not enough memory for the operation, or the process is
-out of address space.
-
-@item ENODEV
-
-This file is of a type that doesn't support mapping.
+There is not enough memory for the operation, the process is out of
+address space, or there are too many mappings. On Linux, the maximum
+number of mappings can be controlled via
+@file{/proc/sys/vm/max_map_count} or, if your OS supports it, via
+the @code{vm.max_map_count} @code{sysctl} setting.
@item ENOEXEC
The file is on a filesystem that doesn't support mapping.
+@item EPERM
+
+@code{PROT_EXEC} was requested but the file is on a filesystem that
+was mounted with execution denied, a file seal prevented the mapping,
+or the caller set MAP_HUDETLB but does not have the required
+priviledges.
+
+@item EOVERFLOW
+
+Either the offset into the file plus the length of the mapping causes
+internal page counts to overflow, or the offset requested exceeds the
+length of the file.
+
@c On Linux, EAGAIN will appear if the file has a conflicting mandatory lock.
@c However mandatory locks are not discussed in this manual.
@c

View File

@ -0,0 +1,50 @@
commit 941157dbcdf1c410960bde991206bfb6d9bb292f
Author: Arjun Shankar <arjun@redhat.com>
Date: Wed Jun 4 13:08:54 2025 +0200
manual: Document faccessat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 28d38f23fc58c51f..17c15b54037e719d 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -3069,6 +3069,29 @@ Flag meaning test for execute/search permission.
Flag meaning test for existence of the file.
@end deftypevr
+@deftypefun int faccessat (int @var{filedes}, const char *@var{filename}, int @var{how}, int @var{flags})
+@standards{POSIX.1-2008, unistd.h}
+@comment Unaudited and therefore marked AC-Unsafe and AS-Unsafe by default
+@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
+This function is a descriptor-relative version of the @code{access}
+function above. @xref{Descriptor-Relative Access}. The @var{flags}
+argument can contain a combination of the flags @code{AT_EACCESS} described
+below, @code{AT_EMPTY_PATH}, and @code{AT_SYMLINK_NOFOLLOW}.
+
+@vtable @code
+@item AT_EACCESS
+This flag when passed to the @code{faccessat} function causes it to perform
+access checks using effective user and group IDs instead of real IDs, which
+is the default and matches the @code{access} function.
+@end vtable
+
+Compared to @code{access}, some additional error conditions can occur.
+@xref{Descriptor-Relative Access}.
+
+This function may not work correctly on older kernels missing the
+@code{faccessat2} system call.
+@end deftypefun
+
@node File Times
@subsection File Times
@@ -3849,7 +3872,6 @@ creation always works like @code{open} with @code{O_EXCL}.
The @code{mkdtemp} function comes from OpenBSD.
@c FIXME these are undocumented:
-@c faccessat
@c fchmodat
@c fchownat
@c futimesat

View File

@ -0,0 +1,38 @@
commit 49766eb1a5b93d093bd0fada55ca7a42dfdb10d6
Author: Arjun Shankar <arjun@redhat.com>
Date: Wed Jun 4 13:08:55 2025 +0200
manual: Document mkdirat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 17c15b54037e719d..d8f362f3beda9b28 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -1964,6 +1964,17 @@ To use this function, your program should include the header file
@pindex sys/stat.h
@end deftypefun
+@deftypefun int mkdirat (int @var{filedes}, const char *@var{filename}, mode_t @var{mode})
+@standards{POSIX.1-2008, sys/stat.h}
+@comment Unaudited and therefore marked AC-Unsafe and AS-Unsafe by default
+@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
+This function is a descriptor-relative version of the @code{mkdir}
+function above. @xref{Descriptor-Relative Access}.
+
+Compared to @code{mkdir}, some additional error conditions can occur.
+@xref{Descriptor-Relative Access}.
+@end deftypefun
+
@node File Attributes
@section File Attributes
@@ -3877,7 +3888,6 @@ The @code{mkdtemp} function comes from OpenBSD.
@c futimesat
@c fstatat (there's a commented-out safety assessment for this one)
@c statx
-@c mkdirat
@c mkfifoat
@c name_to_handle_at
@c openat

View File

@ -0,0 +1,38 @@
commit 60f86c9cd062882cbeb04b2944c3dfb7457ee5c5
Author: Arjun Shankar <arjun@redhat.com>
Date: Wed Jun 4 13:08:56 2025 +0200
manual: Document renameat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/filesys.texi b/manual/filesys.texi
index d8f362f3beda9b28..8a173c562fa71f83 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -1910,6 +1910,17 @@ file systems.
@end table
@end deftypefun
+@deftypefun int renameat (int @var{oldfiledes}, const char *@var{oldname}, int @var{newfiledes}, const char *@var{newname})
+@standards{POSIX.1-2008, stdio.h}
+@comment Unaudited and therefore marked AC-Unsafe and AS-Unsafe by default
+@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
+This function is a descriptor-relative version of the @code{rename}
+function above. @xref{Descriptor-Relative Access}.
+
+Compared to @code{rename}, some additional error conditions can occur.
+@xref{Descriptor-Relative Access}.
+@end deftypefun
+
@node Creating Directories
@section Creating Directories
@cindex creating a directory
@@ -3893,7 +3904,6 @@ The @code{mkdtemp} function comes from OpenBSD.
@c openat
@c open_by_handle_at
@c readlinkat
-@c renameat
@c renameat2
@c scandirat
@c symlinkat

View File

@ -0,0 +1,51 @@
commit 75b725717ff23d0ae38fc7f4a0361cb1bdffbe2e
Author: Arjun Shankar <arjun@redhat.com>
Date: Wed Jun 4 13:08:57 2025 +0200
manual: Document unlinkat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 8a173c562fa71f83..396d68c32925c501 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -1779,6 +1779,31 @@ file system and can't be modified.
@end table
@end deftypefun
+@deftypefun int unlinkat (int @var{filedes}, const char *@var{filename}, int @var{flags})
+@standards{POSIX.1-2008, unistd.h}
+@comment Unaudited and therefore marked AC-Unsafe and AS-Unsafe by default
+@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
+This function is a descriptor-relative version of the @code{unlink}
+function above. @xref{Descriptor-Relative Access}. The @var{flags}
+argument may either be @code{0} or contain the flag @code{AT_REMOVEDIR}:
+
+@table @code
+@item AT_REMOVEDIR
+This flag causes @code{unlinkat} to perform an @code{rmdir} operation on
+@code{filename} instead of performing the equivalent of @code{unlink}.
+@end table
+
+Compared to @code{unlink}, some additional error conditions can occur due to
+descriptor-relative access. @xref{Descriptor-Relative Access}. In
+addition to this, the following other errors can also occur:
+
+@table @code
+@item EISDIR
+The effective final path derived from @var{filename} and @var{filedes} is a
+directory but @code{AT_REMOVEDIR} was not passed in @code{flags}.
+@end table
+@end deftypefun
+
@deftypefun int rmdir (const char *@var{filename})
@standards{POSIX.1, unistd.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@@ -3907,6 +3932,5 @@ The @code{mkdtemp} function comes from OpenBSD.
@c renameat2
@c scandirat
@c symlinkat
-@c unlinkat
@c utimensat
@c mknodat

View File

@ -0,0 +1,97 @@
commit 25f1d945766a3a757d9b54eb48fe7c3c48c0f791
Author: Arjun Shankar <arjun@redhat.com>
Date: Wed Jun 4 13:08:58 2025 +0200
manual: Document futimens and utimensat
Document futimens and utimensat. Also document the EINVAL error
condition for futimes. It is inherited by futimens and utimensat as
well.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 396d68c32925c501..f21f21804251e480 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -3307,6 +3307,10 @@ permission for the file, or be a privileged user.
@item EBADF
The @var{filedes} argument is not a valid file descriptor.
+@item EINVAL
+At least one of the fields in the @code{tvp} array passed has an invalid
+value.
+
@item EPERM
If the @var{times} argument is not a null pointer, you must either be
the owner of the file or be a privileged user.
@@ -3316,6 +3320,64 @@ The file lives on a read-only file system.
@end table
@end deftypefun
+@deftypefun int futimens (int @var{filedes}, const struct timespec @var{tsp}@t{[2]})
+@standards{POSIX.1-2008, sys/stat.h}
+@comment Unaudited and therefore marked AC-Unsafe and AS-Unsafe by default
+@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
+This function is like @code{futimes}, except that it sets the file access
+and modification timestamps with nanosecond precision. The argument
+@code{tsp} is used similarly to @code{futimes}' @code{tvp}, but has a
+@code{const struct timespec} type that can express calendar time with
+nanosecond precision. @xref{Time Types}.
+@end deftypefun
+
+@deftypefun int utimensat (int @var{filedes}, const char *@var{filename}, const struct timespec @var{tsp}@t{[2]}, int @var{flags})
+@standards{POSIX.1-2008, sys/stat.h}
+@comment Unaudited and therefore marked AC-Unsafe and AS-Unsafe by default
+@safety{@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
+This function is a descriptor-relative version of the @code{futimens}
+function above. @xref{Descriptor-Relative Access}. The @var{flags}
+argument can contain a combination of the flags @code{AT_EMPTY_PATH}, and
+@code{AT_SYMLINK_NOFOLLOW}. The call:
+
+@smallexample
+futimens (@var{filedes}, @var{tsp})
+@end smallexample
+
+is equivalent to:
+
+@smallexample
+utimensat (@var{filedes}, @code{NULL}, @var{tsp}, 0)
+@end smallexample
+
+Compared to @code{futimens}, some additional error conditions can occur due
+to descriptor-relative access. @xref{Descriptor-Relative Access}. In
+addition to this, the following other errors can also occur:
+
+@table @code
+@item EINVAL
+The @var{filename} argument is NULL, @var{filedes} is not @code{AT_FDCWD},
+and @var{flags} is not @code{0}.
+
+@item ELOOP
+There are too many levels of indirection. This can be the result of
+circular symbolic links to directories.
+
+@item ENAMETOOLONG
+The resulting path is too long. This error only occurs on systems which
+have a limit on the file name length.
+
+@item ENOENT
+The @var{filename} argument is an empty string and @var{flags} does not
+contain @code{AT_EMPTY_PATH}, or @var{filename} does not refer to an
+existing file.
+
+@item ESRCH
+Search permission was denied for one of the prefix components of the the
+@var{filename} argument.
+@end table
+@end deftypefun
+
@node File Size
@subsection File Size
@@ -3932,5 +3994,4 @@ The @code{mkdtemp} function comes from OpenBSD.
@c renameat2
@c scandirat
@c symlinkat
-@c utimensat
@c mknodat

44
glibc-RHEL-108974-4.patch Normal file
View File

@ -0,0 +1,44 @@
commit 0e16db440cc73d2cdd94e439c0efa1ec43d92b2a
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue Aug 13 15:52:34 2024 +0200
manual: Document generic printf error codes
Describe EOVERFLOW, ENOMEN, EILSEQ.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 393ed9c665792609..19b4a53299410ca6 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2354,6 +2354,29 @@ the easiest way to make sure you have all the right prototypes is to
just include @file{stdio.h}.
@pindex stdio.h
+The @code{printf} family shares the error codes listed below.
+Individual functions may report additional @code{errno} values if they
+fail.
+
+@table @code
+@item EOVERFLOW
+The number of written bytes would have exceeded @code{INT_MAX}, and thus
+could not be represented in the return type @code{int}.
+
+@item ENOMEM
+The function could not allocate memory during processing. Long argument
+lists and certain floating point conversions may require memory
+allocation, as does initialization of an output stream upon first use.
+
+@item EILSEQ
+POSIX specifies this error code should be used if a wide character is
+encountered that does not have a matching valid character. @Theglibc{}
+always performs transliteration, using a replacement character if
+necessary, so this error condition cannot occur on output. However,
+@theglibc{} uses @code{EILSEQ} to indicate that an input character
+sequence (wide or multi-byte) could not be converted successfully.
+@end table
+
@deftypefun int printf (const char *@var{template}, @dots{})
@standards{ISO, stdio.h}
@safety{@prelim{}@mtsafe{@mtslocale{}}@asunsafe{@asucorrupt{} @ascuheap{}}@acunsafe{@acsmem{} @aculock{} @acucorrupt{}}}

53
glibc-RHEL-108974-5.patch Normal file
View File

@ -0,0 +1,53 @@
commit 2be0572f3a41d5d5a8bb3b2b04244b7c01ac0f58
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue Aug 13 15:52:34 2024 +0200
manual: Document dprintf and vdprintf
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 19b4a53299410ca6..3f837fa99c3c6574 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2523,6 +2523,26 @@ store the result in which case @code{-1} is returned. This was
changed in order to comply with the @w{ISO C99} standard.
@end deftypefun
+@deftypefun dprintf (int @var{fd}, @var{template}, ...)
+@standards{POSIX, stdio.h}
+@safety{@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
+This function formats its arguments according to @var{template} and
+writes the result to the file descriptor @var{fd}, using the
+@code{write} function. It returns the number of bytes written, or a
+negative value if there was an error. In the error case, @code{errno}
+is set appropriately. The possible @code{errno} values depend on the
+type of the file descriptor @var{fd}, in addition to the general
+@code{printf} error codes.
+
+The number of calls to @code{write} is unspecified, and some @code{write}
+calls may have happened even if @code{dprintf} returns with an error.
+
+@strong{Portability Note:} POSIX does not require that this function is
+async-signal-safe, and @theglibc{} implementation is not. However, some
+other systems offer this function as an async-signal-safe alternative to
+@code{fprintf}. @xref{POSIX Safety Concepts}.
+@end deftypefun
+
@node Dynamic Output
@subsection Dynamically Allocating Formatted Output
@@ -2736,6 +2756,13 @@ The @code{obstack_vprintf} function is the equivalent of
as for @code{vprintf}.
@end deftypefun
+@deftypefun int vdprintf (int @var{fd}, const char *@var{template}, va_list @var{ap})
+@standards{POSIX, stdio.h}
+@safety{@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
+The @code{vdprintf} is the equivalent of @code{dprintf}, but processes
+an argument list.
+@end deftypefun
+
Here's an example showing how you might use @code{vfprintf}. This is a
function that prints error messages to the stream @code{stderr}, along
with a prefix indicating the name of the program

321
glibc-RHEL-108974-6.patch Normal file
View File

@ -0,0 +1,321 @@
commit 3de73f974fab55430177c811c9c9ba3f251d5747
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Aug 7 14:57:41 2024 +0200
manual: Add Descriptor-Relative Access section
Reference this new section from the O_PATH documentation.
And document the functions openat, openat64, fstatat, fstatat64.
(The safety assessment for fstatat was already obsolete because
current glibc assumes kernel support for the underlying system
call.)
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 47d929744eea75dd..aabb68385b6b9732 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -15,6 +15,7 @@ access permissions and modification times.
@menu
* Working Directory:: This is used to resolve relative
file names.
+* Descriptor-Relative Access:: Ways to control file name lookup.
* Accessing Directories:: Finding out what files a directory
contains.
* Working with Directory Trees:: Apply actions to all files or a selectable
@@ -206,6 +207,151 @@ An I/O error occurred.
@end table
@end deftypefun
+@node Descriptor-Relative Access
+@section Descriptor-Relative Access
+@cindex file name resolution based on descriptors
+@cindex descriptor-based file name resolution
+@cindex @code{@dots{}at} functions
+
+Many functions that accept file names have @code{@dots{}at} variants
+which accept a file descriptor and a file name argument instead of just
+a file name argument. For example, @code{fstatat} is the
+descriptor-based variant of the @code{fstat} function. Most such
+functions also accept an additional flags argument which changes the
+behavior of the file name lookup based on the passed @code{AT_@dots{}}
+flags.
+
+There are several reasons to use descriptor-relative access:
+
+@itemize @bullet
+@item
+The working directory is a process-wide resource, so individual threads
+cannot change it without affecting other threads in the process.
+Explicitly specifying the directory against which relative paths are
+resolved can be a thread-safe alternative to changing the working
+directory.
+
+@item
+If a program wishes to access a directory tree which is being modified
+concurrently, perhaps even by a different user on the system, the
+program must avoid looking up file names with multiple components, in
+order to detect symbolic links, using the @code{O_NOFOLLOW} flag
+(@pxref{Open-time Flags}) or the @code{AT_SYMLINK_FOLLOW} flag
+(described below). Without directory-relative access, it is necessary
+to use the @code{fchdir} function to change the working directory
+(@pxref{Working Directory}), which is not thread-safe.
+
+@item
+Listing directory contents using the @code{readdir} or @code{readdir64}
+functions (@pxref{Reading/Closing Directory}) does not provide full file
+name paths. Using @code{@dots{}at} functions, it is possible to use the
+file names directly, without having to construct such full paths.
+
+@item
+Additional flags available with some of the @code{@dots{}at} functions
+provide access to functionality which is not available otherwise.
+@end itemize
+
+The file descriptor used by these @code{@dots{}at} functions has the
+following uses:
+
+@itemize @bullet
+@item
+It can be a file descriptor referring to a directory. Such a descriptor
+can be created explicitly using the @code{open} function and the
+@code{O_RDONLY} file access mode, with or without the @code{O_DIRECTORY}
+flag. @xref{Opening and Closing Files}. Or it can be created
+implicitly by @code{opendir} and retrieved using the @code{dirfd}
+function. @xref{Opening a Directory}.
+
+If a directory descriptor is used with one of the @code{@dots{}at}
+functions, a relative file name argument is resolved relative to
+directory referred to by the file descriptor, just as if that directory
+were the current working directory. Absolute file name arguments
+(starting with @samp{/}) are resolved against the file system root, and
+the descriptor argument is effectively ignored.
+
+This means that file name lookup is not constrained to the directory of
+the descriptor. For example, it is possible to access a file
+@file{example} in the descriptor's parent directory using a file name
+argument @code{"../example"}, or in the root directory using
+@code{"/example"}.
+
+If the file descriptor refers to a directory, the empty string @code{""}
+is not a valid file name argument. It is possible to use @code{"."} to
+refer to the directory itself. Also see @code{AT_EMPTY_PATH} below.
+
+@item
+@vindex @code{AT_FDCWD}
+The special value @code{AT_FDCWD}. This means that the current working
+directory is used for the lookup if the file name is a relative. For
+@code{@dots{}at} functions with an @code{AT_@dots{}} flags argument,
+this provides a shortcut to use those flags with regular (not
+descriptor-based) file name lookups.
+
+If @code{AT_FDCWD} is used, the empty string @code{""} is not a valid
+file name argument.
+
+@item
+An arbitrary file descriptor, along with an empty string @code{""} as
+the file name argument, and the @code{AT_EMPTY_PATH} flag. In this
+case, the operation uses the file descriptor directly, without further
+file name resolution. On Linux, this allows operations on descriptors
+opened with the @code{O_PATH} flag. For regular descriptors (opened
+without @code{O_PATH}), the same functionality is also available through
+the plain descriptor-based functions (for example, @code{fstat} instead
+of @code{fstatat}).
+
+This is a GNU extension.
+@end itemize
+
+@cindex file name resolution flags
+@cindex @code{AT_*} file name resolution flags
+The flags argument in @code{@dots{}at} functions can be a combination of
+the following flags, defined in @file{fcntl.h}. Not all such functions
+support all flags, and some (such as @code{openat}) do not accept a
+flags argument at all.
+
+In the flag descriptions below, the @dfn{effective final path component}
+refers to the final component (basename) of the full path constructed
+from the descriptor and file name arguments, using file name lookup, as
+described above.
+
+@vtable @code
+@item AT_EMPTY_PATH
+This flag is used with an empty file name @code{""} and a descriptor
+which does not necessarily refer to a directory. It is most useful with
+@code{O_PATH} descriptors, as described above. This flag is a GNU
+extension.
+
+@item AT_NO_AUTOMOUNT
+If the effective final path component refers to a potential file system
+mount point controlled by an auto-mounting service, the operation does
+not trigger auto-mounting and refers to the unmounted mount point
+instead. @xref{Mount-Unmount-Remount}. If a file system has already
+been mounted at the effective final path component, the operation
+applies to the file or directory in the mounted file system, not the
+underlying file system that was mounted over. This flag is a GNU
+extension.
+
+@item AT_SYMLINK_FOLLOW
+If the effective final path component is a symbolic link, the
+operation follows the symbolic link and operates on its target. (For
+most functions, this is the default behavior.)
+
+@item AT_SYMLINK_NOFOLLOW
+If the effective final path component is a symbolic link, the
+operation operates on the symbolic link, without following it. The
+difference in behavior enabled by this flag is similar to the difference
+between the @code{lstat} and @code{stat} functions, or the behavior
+activated by the @code{O_NOFOLLOW} argument to the @code{open} function.
+Even with the @code{AT_SYMLINK_NOFOLLOW} flag present, symbolic links in
+a non-final component of the file name are still followed.
+@end vtable
+
+@strong{Note:} There is no relationship between these flags and the type
+argument to the @code{getauxval} function (with @code{AT_@dots{}}
+constants defined in @file{elf.h}). @xref{Auxiliary Vector}.
@node Accessing Directories
@section Accessing Directories
@@ -1250,10 +1396,11 @@ A hardware error occurred while trying to read or write the to filesystem.
The @code{linkat} function is analogous to the @code{link} function,
except that it identifies its source and target using a combination of a
-file descriptor (referring to a directory) and a pathname. If a
-pathnames is not absolute, it is resolved relative to the corresponding
-file descriptor. The special file descriptor @code{AT_FDCWD} denotes
-the current directory.
+file descriptor (referring to a directory) and a file name.
+@xref{Descriptor-Relative Access}. For @code{linkat}, if a file name is
+not absolute, it is resolved relative to the corresponding file
+descriptor. As usual, the special value @code{AT_FDCWD} denotes the
+current directory.
The @var{flags} argument is a combination of the following flags:
@@ -2091,9 +2238,44 @@ function is available under the name @code{fstat} and so transparently
replaces the interface for small files on 32-bit machines.
@end deftypefun
-@c fstatat will call alloca and snprintf if the syscall is not
-@c available.
-@c @safety{@mtsafe{}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
+@deftypefun int fstatat (int @var{filedes}, const char *@var{filename}, struct stat *@var{buf}, int @var{flags})
+@standards{POSIX.1, sys/stat.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+This function is a descriptor-relative version of the @code{fstat}
+function above. @xref{Descriptor-Relative Access}. The @var{flags}
+argument can contain a combination of the flags @code{AT_EMPTY_PATH},
+@code{AT_NO_AUTOMOUNT}, @code{AT_SYMLINK_NOFOLLOW}.
+
+Compared to @code{fstat}, the following additional error conditions can
+occur:
+
+@table @code
+@item EBADF
+The @var{filedes} argument is not a valid file descriptor.
+
+@item EINVAL
+The @var{flags} argument is not valid for this function.
+
+@item ENOTDIR
+The descriptor @var{filedes} is not associated with a directory, and
+@var{filename} is a relative file name.
+@end table
+
+When the sources are compiled with @code{_FILE_OFFSET_BITS == 64} this
+function is in fact @code{fstatat64} since the LFS interface transparently
+replaces the normal implementation.
+@end deftypefun
+
+@deftypefun int fstatat64 (int @var{filedes}, const char *@var{filename}, struct stat64 *@var{buf}, int @var{flags})
+@standards{GNU, sys/stat.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+This function is the large-file variant of @code{fstatat}, similar to
+how @code{fstat64} is the variant of @code{fstat}.
+
+When the sources are compiled with @code{_FILE_OFFSET_BITS == 64} this
+function is available under the name @code{fstatat} and so transparently
+replaces the interface for small files on 32-bit machines.
+@end deftypefun
@deftypefun int lstat (const char *@var{filename}, struct stat *@var{buf})
@standards{BSD, sys/stat.h}
diff --git a/manual/llio.texi b/manual/llio.texi
index be55dca1b7c9ebcd..05ab44c6e7a5d4fd 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -181,6 +181,43 @@ new, extended API using 64 bit file sizes and offsets transparently
replaces the old API.
@end deftypefun
+@deftypefun int openat (int @var{filedes}, const char *@var{filename}, int @var{flags}[, mode_t @var{mode}])
+@standards{POSIX.1, fcntl.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{@acsfd{}}}
+This function is the descriptor-relative variant of the @code{open}
+function. @xref{Descriptor-Relative Access}.
+
+Note that the @var{flags} argument of @code{openat} does not accept
+@code{AT_@dots{}} flags, only the flags described for the @code{open}
+function above.
+
+The @code{openat} function can fail for additional reasons:
+
+@table @code
+@item EBADF
+The @var{filedes} argument is not a valid file descriptor.
+
+@item ENOTDIR
+The descriptor @var{filedes} is not associated with a directory, and
+@var{filename} is a relative file name.
+@end table
+
+When the sources are compiled with @code{_FILE_OFFSET_BITS == 64} this
+function is in fact @code{openat64} since the LFS interface transparently
+replaces the normal implementation.
+@end deftypefun
+
+@deftypefun int openat64 (int @var{filedes}, const char *@var{filename}, int @var{flags}[, mode_t @var{mode}])
+@standards{GNU, fcntl.h}
+The large-file variant of the @code{openat}, similar to how
+@code{open64} is the large-file variant of @code{open}.
+
+When the sources are translated with @code{_FILE_OFFSET_BITS == 64} this
+function is actually available under the name @code{openat}. I.e., the
+new, extended API using 64 bit file sizes and offsets transparently
+replaces the old API.
+@end deftypefun
+
@deftypefn {Obsolete function} int creat (const char *@var{filename}, mode_t @var{mode})
@standards{POSIX.1, fcntl.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{@acsfd{}}}
@@ -3816,7 +3853,9 @@ contains it is still needed), and permissions are checked when the
descriptor is used later on.
For example, such descriptors can be used with the @code{fexecve}
-function (@pxref{Executing a File}).
+function (@pxref{Executing a File}). Other applications involve the
+@samp{*at} function variants, along with the @code{AT_EMPTY_PATH} flag.
+@xref{Descriptor-Relative Access}.
This access mode is specific to Linux. On @gnuhurdsystems{}, it is
possible to use @code{O_EXEC} explicitly, or specify no access modes
diff --git a/manual/startup.texi b/manual/startup.texi
index c421563d16979c64..c1a3683d584cb914 100644
--- a/manual/startup.texi
+++ b/manual/startup.texi
@@ -664,8 +664,12 @@ basis there may be information that is not available any other way.
This function is used to inquire about the entries in the auxiliary
vector. The @var{type} argument should be one of the @samp{AT_} symbols
defined in @file{elf.h}. If a matching entry is found, the value is
-returned; if the entry is not found, zero is returned and @code{errno} is
-set to @code{ENOENT}.
+returned; if the entry is not found, zero is returned and @code{errno}
+is set to @code{ENOENT}.
+
+@strong{Note:} There is no relationship between the @samp{AT_} contants
+defined in @file{elf.h} and the file name lookup flags in
+@file{fcntl.h}. @xref{Descriptor-Relative Access}.
@end deftypefun
For some platforms, the key @code{AT_HWCAP} is the easiest way to inquire

31
glibc-RHEL-108974-7.patch Normal file
View File

@ -0,0 +1,31 @@
commit 6efd6cd46bf2257e674be4933a034542d80944eb
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Sep 6 14:07:00 2024 +0200
manual: Safety annotations for clock_gettime, clock_getres
The annotations are preliminary, for consistency with existing
annotations on gettimeofday etc.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/time.texi b/manual/time.texi
index ab5063be81cf0af9..d292e269ebb2f975 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -532,6 +532,7 @@ Systems may support more than just these two POSIX clocks.
@deftypefun int clock_gettime (clockid_t @var{clock}, struct timespec *@var{ts})
@standards{POSIX.1, time.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Get the current time according to the clock identified by @var{clock},
storing it as seconds and nanoseconds in @code{*@var{ts}}.
@xref{Time Types}, for a description of @code{struct timespec}.
@@ -553,6 +554,7 @@ clock:
@deftypefun int clock_getres (clockid_t @var{clock}, struct timespec *@var{res})
@standards{POSIX.1, time.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Get the actual resolution of the clock identified by @var{clock},
storing it in @code{*@var{ts}}.

387
glibc-RHEL-108974-8.patch Normal file
View File

@ -0,0 +1,387 @@
commit 83a1cc3bc3d28c97d1af6c0957b11fe39fd786d8
Author: Carlos O'Donell <carlos@redhat.com>
Date: Wed Oct 9 18:32:26 2024 -0400
manual: Fix and test @deftypef* function formatting
The manual contained several instances of incorrect formatting
that were correct texinfo but produced incorrectly rendered manuals
or incorrect behaviour from the tooling.
The most important was incorrect quoting of function returns
by failing to use {} to quote the return. The impact of this
mistake means that 'info libc func' does not jump to the function
in question but instead to the introductory page under the assumption
that func doesn't exist. The function returns are now correctly
quoted.
The second issue was the use of a category specifier with
@deftypefun which doesn't accept a category specifier. If a category
specifier is required then @deftypefn needs to be used. This is
corrected by changing the command to @deftypefn for such functions
that used {Deprecated function} as a category.
The last issue is a missing space between the function name and the
arguments which results in odd function names like "epoll_wait(int"
instead of "epoll_wait". This also impacts the use of 'info libc'
and is corrected.
We additionally remove ';' from the end of function arguments and
add an 'int' return type for dprintf.
Lastly we add a new test check-deftype.sh which verifies the expected
formatting of @deftypefun, @deftypefunx, @deftypefn, and
@deftypefnx. The new test is also run as the summary file is
generated to ensure we don't generate incorrect results.
The existing check-safety.sh is also run directly as a test to increase
coverage since the existing tests only ran on manual install.
The new tests now run as part of the standard "make check" that
pre-commit CI runs and developers should run.
No regressions on x86_64.
HTML and PDF rendering reviewed and looks correct for all changes.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
diff --git a/manual/Makefile b/manual/Makefile
index a6c05db540d6c1da..6a4cfbeb765265f3 100644
--- a/manual/Makefile
+++ b/manual/Makefile
@@ -69,6 +69,11 @@ chapters.% top-menu.%: libc-texinfo.sh $(texis-path) Makefile
'$(chapters)' \
'$(appendices) $(licenses)'
+# Verify validity of texinfo sources against project rules.
+tests-special += \
+ $(objpfx)check-deftype.out \
+ $(objpfx)check-safety.out \
+ # tests-special
$(objpfx)libc.dvi $(objpfx)libc.pdf $(objpfx)libc.info: \
$(addprefix $(objpfx),$(libc-texi-generated))
@@ -83,10 +88,19 @@ $(objpfx)summary.texi: $(objpfx)stamp-summary ;
$(objpfx)stamp-summary: summary.pl $(filter-out $(objpfx)summary.texi, \
$(texis-path))
$(SHELL) ./check-safety.sh $(filter-out $(objpfx)%, $(texis-path))
+ $(SHELL) ./check-deftype.sh $(filter-out $(objpfx)%, $(texis-path))
LC_ALL=C $(PERL) $^ > $(objpfx)summary-tmp
$(move-if-change) $(objpfx)summary-tmp $(objpfx)summary.texi
touch $@
+$(objpfx)check-safety.out: check-safety.sh
+ $(SHELL) $< > $@ ; \
+ $(evaluate-test)
+
+$(objpfx)check-deftype.out: check-deftype.sh
+ $(SHELL) $< > $@ ; \
+ $(evaluate-test)
+
# Generate a file which can be added to the `dir' content to provide direct
# access to the documentation of the function, variables, and other
# definitions.
@@ -152,10 +166,19 @@ $(objpfx)%.pdf: %.texinfo
# Distribution.
-minimal-dist = summary.pl texis.awk tsort.awk libc-texinfo.sh libc.texinfo \
- libm-err.texi stamp-libm-err check-safety.sh \
- $(filter-out summary.texi, $(nonexamples)) \
- $(patsubst %.c.texi,examples/%.c, $(examples))
+minimal-dist = \
+ $(filter-out summary.texi, $(nonexamples)) \
+ $(patsubst %.c.texi,examples/%.c, $(examples)) \
+ check-deftype.sh \
+ check-safety.sh \
+ libc-texinfo.sh \
+ libc.texinfo \
+ libm-err.texi \
+ stamp-libm-err \
+ summary.pl \
+ texis.awk \
+ tsort.awk \
+ # minimal-dist
indices = cp fn pg tp vr ky
generated-dirs += libc
diff --git a/manual/check-deftype.sh b/manual/check-deftype.sh
new file mode 100644
index 0000000000000000..395c99af6afe1fdd
--- /dev/null
+++ b/manual/check-deftype.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Copyright 2024 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+# Check that the @deftypefun command is called with the expected
+# arguments and includes checking for common mistakes including
+# failure to include a space after the function name, or incorrect
+# quoting.
+
+success=:
+
+# If no arguments are given, take all *.texi files in the current directory.
+test $# != 0 || set *.texi
+
+# We search for all @deftypefun and @deftypefunx command uses.
+# Then we remove all of those that match our expectations.
+# A @deftypefun or @deftypefunx command takes 3 arguments:
+# - return type
+# - name
+# - arguments
+# This is different from @deftypefn which includes an additional
+# category which is implicit here.
+grep -n -r '^@deftypefun' "$@" |
+grep -v '^.*@deftypefunx\?'\
+' \({\?[a-zA-Z0-9_ *]*}\?\) \([a-zA-Z0-9_]*\) (.*)$' &&
+success=false
+
+# We search for all @deftypefn and @deftypefnx command uses.
+# We have 4 arguments in the command including the category.
+grep -n -r '^@deftypefn' "$@" |
+grep -v '^.*@deftypefnx\?'\
+' {\?[a-zA-Z ]*}\? \({\?[a-zA-Z0-9@{}_ *]*}\?\) \([a-zA-Z0-9_]*\) (.*)$' &&
+success=false
+
+$success
diff --git a/manual/ipc.texi b/manual/ipc.texi
index 6a6e5ad410c14387..32c5ac066fb94579 100644
--- a/manual/ipc.texi
+++ b/manual/ipc.texi
@@ -20,7 +20,7 @@ by @theglibc{}.
@c Need descriptions for all of these functions.
@subsection System V Semaphores
-@deftypefun int semctl (int @var{semid}, int @var{semnum}, int @var{cmd});
+@deftypefun int semctl (int @var{semid}, int @var{semnum}, int @var{cmd})
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{/linux}}}
@c syscall(ipc) ok
@c
@@ -30,35 +30,35 @@ by @theglibc{}.
@c semid_ds.
@end deftypefun
-@deftypefun int semget (key_t @var{key}, int @var{nsems}, int @var{semflg});
+@deftypefun int semget (key_t @var{key}, int @var{nsems}, int @var{semflg})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c syscall(ipc) ok
@end deftypefun
-@deftypefun int semop (int @var{semid}, struct sembuf *@var{sops}, size_t @var{nsops});
+@deftypefun int semop (int @var{semid}, struct sembuf *@var{sops}, size_t @var{nsops})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c syscall(ipc) ok
@end deftypefun
-@deftypefun int semtimedop (int @var{semid}, struct sembuf *@var{sops}, size_t @var{nsops}, const struct timespec *@var{timeout});
+@deftypefun int semtimedop (int @var{semid}, struct sembuf *@var{sops}, size_t @var{nsops}, const struct timespec *@var{timeout})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c syscall(ipc) ok
@end deftypefun
@subsection POSIX Semaphores
-@deftypefun int sem_init (sem_t *@var{sem}, int @var{pshared}, unsigned int @var{value});
+@deftypefun int sem_init (sem_t *@var{sem}, int @var{pshared}, unsigned int @var{value})
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
@c Does not atomically update sem_t therefore AC-unsafe
@c because it can leave sem_t partially initialized.
@end deftypefun
-@deftypefun int sem_destroy (sem_t *@var{sem});
+@deftypefun int sem_destroy (sem_t *@var{sem})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c Function does nothing and is therefore always safe.
@end deftypefun
-@deftypefun sem_t *sem_open (const char *@var{name}, int @var{oflag}, ...);
+@deftypefun {sem_t *} sem_open (const char *@var{name}, int @var{oflag}, ...)
@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acuinit{}}}
@c pthread_once asuinit
@c
@@ -67,7 +67,7 @@ by @theglibc{}.
@c shmfs on Linux.
@end deftypefun
-@deftypefun int sem_close (sem_t *@var{sem});
+@deftypefun int sem_close (sem_t *@var{sem})
@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
@c lll_lock asulock aculock
@c twalk mtsrace{:root}
@@ -77,13 +77,13 @@ by @theglibc{}.
@c are not updated atomically.
@end deftypefun
-@deftypefun int sem_unlink (const char *@var{name});
+@deftypefun int sem_unlink (const char *@var{name})
@safety{@prelim{}@mtsafe{}@asunsafe{@asuinit{}}@acunsafe{@acucorrupt{}}}
@c pthread_once asuinit acucorrupt aculock
@c mempcpy acucorrupt
@end deftypefun
-@deftypefun int sem_wait (sem_t *@var{sem});
+@deftypefun int sem_wait (sem_t *@var{sem})
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
@c atomic_fetch_add_relaxed (nwaiters) acucorrupt
@c
@@ -95,22 +95,22 @@ by @theglibc{}.
@c waiters count.
@end deftypefun
-@deftypefun int sem_timedwait (sem_t *@var{sem}, const struct timespec *@var{abstime});
+@deftypefun int sem_timedwait (sem_t *@var{sem}, const struct timespec *@var{abstime})
@safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}}
@c Same safety issues as sem_wait.
@end deftypefun
-@deftypefun int sem_trywait (sem_t *@var{sem});
+@deftypefun int sem_trywait (sem_t *@var{sem})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c All atomic operations are safe in all contexts.
@end deftypefun
-@deftypefun int sem_post (sem_t *@var{sem});
+@deftypefun int sem_post (sem_t *@var{sem})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c Same safety as sem_trywait.
@end deftypefun
-@deftypefun int sem_getvalue (sem_t *@var{sem}, int *@var{sval});
+@deftypefun int sem_getvalue (sem_t *@var{sem}, int *@var{sval})
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c Atomic write of a value is safe in all contexts.
@end deftypefun
diff --git a/manual/llio.texi b/manual/llio.texi
index 05ab44c6e7a5d4fd..850d09205a604589 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -4840,12 +4840,12 @@ of an IOCTL, see @ref{Out-of-Band Data}.
@manpagefunctionstub{poll,2}
@end deftypefun
-@deftypefun int epoll_create(int @var{size})
+@deftypefun int epoll_create (int @var{size})
@manpagefunctionstub{epoll_create,2}
@end deftypefun
-@deftypefun int epoll_wait(int @var{epfd}, struct epoll_event *@var{events}, int @var{maxevents}, int @var{timeout})
+@deftypefun int epoll_wait (int @var{epfd}, struct epoll_event *@var{events}, int @var{maxevents}, int @var{timeout})
@manpagefunctionstub{epoll_wait,2}
@end deftypefun
diff --git a/manual/memory.texi b/manual/memory.texi
index 3710d7ec667519cc..58683ee93dace783 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -2935,7 +2935,7 @@ exceed the process' data storage limit.
@end deftypefun
-@deftypefun void *sbrk (ptrdiff_t @var{delta})
+@deftypefun {void *} sbrk (ptrdiff_t @var{delta})
@standards{BSD, unistd.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 3f837fa99c3c6574..aa137e9888b5b59d 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2523,7 +2523,7 @@ store the result in which case @code{-1} is returned. This was
changed in order to comply with the @w{ISO C99} standard.
@end deftypefun
-@deftypefun dprintf (int @var{fd}, @var{template}, ...)
+@deftypefun int dprintf (int @var{fd}, @var{template}, ...)
@standards{POSIX, stdio.h}
@safety{@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
This function formats its arguments according to @var{template} and
diff --git a/manual/threads.texi b/manual/threads.texi
index 25e99c9606dcad77..9ea137cb9663b89c 100644
--- a/manual/threads.texi
+++ b/manual/threads.texi
@@ -592,7 +592,7 @@ destructor for the thread-specific data is not called during destruction, nor
is it called during thread exit.
@end deftypefun
-@deftypefun void *pthread_getspecific (pthread_key_t @var{key})
+@deftypefun {void *} pthread_getspecific (pthread_key_t @var{key})
@standards{POSIX, pthread.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
@c pthread_getspecific ok
diff --git a/manual/time.texi b/manual/time.texi
index d292e269ebb2f975..6ccb07fcfc10449b 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -1829,7 +1829,7 @@ can be placed in the buffer @var{s} the return value is zero, with the
same problems indicated in the @code{strftime} documentation.
@end deftypefun
-@deftypefun {Deprecated function} {char *} asctime (const struct tm *@var{brokentime})
+@deftypefn {Deprecated function} {char *} asctime (const struct tm *@var{brokentime})
@standards{ISO, time.h}
@safety{@prelim{}@mtunsafe{@mtasurace{:asctime} @mtslocale{}}@asunsafe{}@acsafe{}}
@c asctime @mtasurace:asctime @mtslocale
@@ -1863,9 +1863,9 @@ string.)
@strong{Portability note:}
This obsolescent function is deprecated in C23.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
-@deftypefun {Deprecated function} {char *} asctime_r (const struct tm *@var{brokentime}, char *@var{buffer})
+@deftypefn {Deprecated function} {char *} asctime_r (const struct tm *@var{brokentime}, char *@var{buffer})
@standards{???, time.h}
@safety{@prelim{}@mtsafe{@mtslocale{}}@assafe{}@acsafe{}}
@c asctime_r @mtslocale
@@ -1884,9 +1884,9 @@ it returns @code{NULL}.
@strong{Portability Note:}
POSIX.1-2024 removed this obsolescent function.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
-@deftypefun {Deprecated function} {char *} ctime (const time_t *@var{time})
+@deftypefn {Deprecated function} {char *} ctime (const time_t *@var{time})
@standards{ISO, time.h}
@safety{@prelim{}@mtunsafe{@mtasurace{:tmbuf} @mtasurace{:asctime} @mtsenv{} @mtslocale{}}@asunsafe{@ascuheap{} @asulock{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
@c ctime @mtasurace:tmbuf @mtasurace:asctime @mtsenv @mtslocale @ascuheap @asulock @aculock @acsmem @acsfd
@@ -1909,9 +1909,9 @@ Calling @code{ctime} also sets the time zone state as if
@strong{Portability note:}
This obsolescent function is deprecated in C23.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
-@deftypefun {Deprecated function} {char *} ctime_r (const time_t *@var{time}, char *@var{buffer})
+@deftypefn {Deprecated function} {char *} ctime_r (const time_t *@var{time}, char *@var{buffer})
@standards{???, time.h}
@safety{@prelim{}@mtsafe{@mtsenv{} @mtslocale{}}@asunsafe{@ascuheap{} @asulock{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
@c ctime_r @mtsenv @mtslocale @ascuheap @asulock @aculock @acsmem @acsfd
@@ -1935,7 +1935,7 @@ it returns @code{NULL}.
@strong{Portability Note:}
POSIX.1-2024 removed this obsolescent function.
Programs should instead use @code{strftime} or even @code{sprintf}.
-@end deftypefun
+@end deftypefn
@node Parsing Date and Time
@subsection Convert textual time and date information back

58
glibc-RHEL-108974-9.patch Normal file
View File

@ -0,0 +1,58 @@
commit dcad78507433a9a64b8b548b19e110933f8d939a
Author: DJ Delorie <dj@redhat.com>
Date: Thu Oct 10 17:16:35 2024 -0400
manual: Document stdio.h functions that may be macros
Glibc has two gnu-extension functions that are implemented as
macros but not documented as such: fread_unlocked and
fwrite_unlocked. Document them as such.
Additionally, putc_unlocked and getc_unlocked are documented in
POSIX as possibly being macros. Update the manual to add a warning
about those also, depite glibc not implementing them as macros.
diff --git a/manual/stdio.texi b/manual/stdio.texi
index aa137e9888b5b59d..1708d33b10a63b89 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -921,6 +921,9 @@ Therefore, @var{stream} should never be an expression with side-effects.
@safety{@prelim{}@mtsafe{@mtsrace{:stream}}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
The @code{putc_unlocked} function is equivalent to the @code{putc}
function except that it does not implicitly lock the stream.
+Like @code{putc}, it may be implemented as a macro and may evaluate
+the @var{stream} argument more than once. Therefore, @var{stream}
+should not be an expression with side-effects.
@end deftypefun
@deftypefun wint_t putwc_unlocked (wchar_t @var{wc}, FILE *@var{stream})
@@ -1124,6 +1127,9 @@ Therefore, @var{stream} should never be an expression with side-effects.
@safety{@prelim{}@mtsafe{@mtsrace{:stream}}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
The @code{getc_unlocked} function is equivalent to the @code{getc}
function except that it does not implicitly lock the stream.
+Like @code{getc}, it may be implemented as a macro and may evaluate
+the @var{stream} argument more than once. Therefore, @var{stream}
+should not be an expression with side-effects.
@end deftypefun
@deftypefun wint_t getwc_unlocked (FILE *@var{stream})
@@ -1563,6 +1569,9 @@ The @code{fread_unlocked} function is equivalent to the @code{fread}
function except that it does not implicitly lock the stream.
This function is a GNU extension.
+This function may be implemented as a macro and may evaluate
+@var{stream} more than once. Therefore, @var{stream} should not be an
+expression with side-effects.
@end deftypefun
@deftypefun size_t fwrite (const void *@var{data}, size_t @var{size}, size_t @var{count}, FILE *@var{stream})
@@ -1581,6 +1590,9 @@ The @code{fwrite_unlocked} function is equivalent to the @code{fwrite}
function except that it does not implicitly lock the stream.
This function is a GNU extension.
+This function may be implemented as a macro and may evaluate
+@var{stream} more than once. Therefore, @var{stream} should not be an
+expression with side-effects.
@end deftypefun
@node Formatted Output

View File

@ -147,7 +147,7 @@ Version: %{glibcversion}
# - It allows using the Release number without the %%dist tag in the dependency
# generator to make the generated requires interchangeable between Rawhide
# and ELN (.elnYY < .fcXX).
%global baserelease 54
%global baserelease 55
Release: %{baserelease}%{?dist}
# Licenses:
@ -651,6 +651,40 @@ Patch325: glibc-RHEL-107695-18.patch
Patch326: glibc-RHEL-107695-19.patch
Patch327: glibc-RHEL-108475-1.patch
Patch328: glibc-RHEL-108475-2.patch
Patch329: glibc-RHEL-108974-1.patch
Patch330: glibc-RHEL-108974-2.patch
Patch331: glibc-RHEL-108974-3.patch
Patch332: glibc-RHEL-108974-4.patch
Patch333: glibc-RHEL-108974-5.patch
Patch334: glibc-RHEL-108974-6.patch
Patch335: glibc-RHEL-108974-7.patch
Patch336: glibc-RHEL-108974-8.patch
Patch337: glibc-RHEL-108974-9.patch
Patch338: glibc-RHEL-108974-10.patch
Patch339: glibc-RHEL-108974-11.patch
Patch340: glibc-RHEL-108974-12.patch
Patch341: glibc-RHEL-108974-13.patch
Patch342: glibc-RHEL-108974-14.patch
Patch343: glibc-RHEL-108974-15.patch
Patch344: glibc-RHEL-108974-16.patch
Patch345: glibc-RHEL-108974-17.patch
Patch346: glibc-RHEL-108974-18.patch
Patch347: glibc-RHEL-108974-19.patch
Patch348: glibc-RHEL-108974-20.patch
Patch349: glibc-RHEL-108974-21.patch
Patch350: glibc-RHEL-108974-22.patch
Patch351: glibc-RHEL-108974-23.patch
Patch352: glibc-RHEL-108974-24.patch
Patch353: glibc-RHEL-108974-25.patch
Patch354: glibc-RHEL-108974-26.patch
Patch355: glibc-RHEL-108974-27.patch
Patch356: glibc-RHEL-108974-28.patch
Patch357: glibc-RHEL-108974-29.patch
Patch358: glibc-RHEL-108974-30.patch
Patch359: glibc-RHEL-108974-31.patch
Patch360: glibc-RHEL-108974-32.patch
Patch361: glibc-RHEL-108974-33.patch
Patch362: glibc-RHEL-108974-34.patch
##############################################################################
# Continued list of core "glibc" package information:
@ -2664,6 +2698,9 @@ update_gconv_modules_cache ()
%endif
%changelog
* Wed Aug 13 2025 Arjun Shankar <arjun@redhat.com> - 2.39-55
- Various updates to the manual from upstream (RHEL-108974)
* Mon Aug 11 2025 Frédéric Bérat <fberat@redhat.com> - 2.39-54
- Fix memory leak after fdopen seek failure (RHEL-108475)