aboutsummaryrefslogtreecommitdiff
path: root/lib/libsys
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libsys')
-rw-r--r--lib/libsys/Makefile.sys1
-rw-r--r--lib/libsys/_libsys.h3
-rw-r--r--lib/libsys/clock_gettime.23
-rw-r--r--lib/libsys/closefrom.27
-rw-r--r--lib/libsys/getrlimitusage.24
-rw-r--r--lib/libsys/kexec_load.2119
-rw-r--r--lib/libsys/kqueue.229
-rw-r--r--lib/libsys/pathconf.28
-rw-r--r--lib/libsys/posix_fallocate.226
-rw-r--r--lib/libsys/reboot.27
-rw-r--r--lib/libsys/revoke.24
-rw-r--r--lib/libsys/socket.2302
-rw-r--r--lib/libsys/syscalls.map2
-rw-r--r--lib/libsys/write.220
14 files changed, 432 insertions, 103 deletions
diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys
index bd65b58083c2..1d1a4f1136ce 100644
--- a/lib/libsys/Makefile.sys
+++ b/lib/libsys/Makefile.sys
@@ -243,6 +243,7 @@ MAN+= abort2.2 \
jail.2 \
kcmp.2 \
kenv.2 \
+ kexec_load.2 \
kill.2 \
kldfind.2 \
kldfirstmod.2 \
diff --git a/lib/libsys/_libsys.h b/lib/libsys/_libsys.h
index 6bd768708a78..12417b572a60 100644
--- a/lib/libsys/_libsys.h
+++ b/lib/libsys/_libsys.h
@@ -32,6 +32,7 @@ struct itimerspec;
struct itimerval;
struct jail;
struct kevent;
+struct kexec_segment;
struct kld_file_stat;
struct mac;
struct module_stat;
@@ -470,6 +471,7 @@ typedef int (__sys_getgroups_t)(int, gid_t *);
typedef int (__sys_setgroups_t)(int, const gid_t *);
typedef int (__sys_jail_attach_jd_t)(int);
typedef int (__sys_jail_remove_jd_t)(int);
+typedef int (__sys_kexec_load_t)(uint64_t, u_long, struct kexec_segment *, u_long);
_Noreturn void __sys__exit(int rval);
int __sys_fork(void);
@@ -876,6 +878,7 @@ int __sys_getgroups(int gidsetsize, gid_t * gidset);
int __sys_setgroups(int gidsetsize, const gid_t * gidset);
int __sys_jail_attach_jd(int fd);
int __sys_jail_remove_jd(int fd);
+int __sys_kexec_load(uint64_t entry, u_long nseg, struct kexec_segment * segments, u_long flags);
__END_DECLS
#endif /* __LIBSYS_H_ */
diff --git a/lib/libsys/clock_gettime.2 b/lib/libsys/clock_gettime.2
index 89551d0f720b..841673648dfc 100644
--- a/lib/libsys/clock_gettime.2
+++ b/lib/libsys/clock_gettime.2
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 10, 2024
+.Dd October 15, 2025
.Dt CLOCK_GETTIME 2
.Os
.Sh NAME
@@ -80,7 +80,6 @@ Behavior during a leap second is not defined by and POSIX standard.
Increments in SI seconds, even while the system is suspended.
Its epoch is unspecified.
The count is not adjusted by leap seconds.
-.Fx implements
.It Dv CLOCK_UPTIME
.It Dv CLOCK_UPTIME_PRECISE
.It Dv CLOCK_UPTIME_FAST
diff --git a/lib/libsys/closefrom.2 b/lib/libsys/closefrom.2
index 1885a6fdeaa8..e6b4a5a3e9d7 100644
--- a/lib/libsys/closefrom.2
+++ b/lib/libsys/closefrom.2
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 17, 2025
+.Dd October 27, 2025
.Dt CLOSEFROM 2
.Os
.Sh NAME
@@ -94,6 +94,11 @@ function first appeared in
.Fx 8.0 .
.Pp
The
+.Fn close_range
+function first appeared in
+.Fx 12.2 .
+.Pp
+The
.Dv CLOSE_RANGE_CLOFORK
flag appeared in
.Fx 15.0 .
diff --git a/lib/libsys/getrlimitusage.2 b/lib/libsys/getrlimitusage.2
index e2114def56c2..d0e92d7f88b4 100644
--- a/lib/libsys/getrlimitusage.2
+++ b/lib/libsys/getrlimitusage.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 27, 2024
+.Dd October 24, 2025
.Dt GETRLIMITUSAGE 2
.Os
.Sh NAME
@@ -97,4 +97,4 @@ and
The
.Fn getrlimitusage
system call appeared in
-.Bx 15.0 .
+.Fx 14.2 .
diff --git a/lib/libsys/kexec_load.2 b/lib/libsys/kexec_load.2
new file mode 100644
index 000000000000..c3d458f34100
--- /dev/null
+++ b/lib/libsys/kexec_load.2
@@ -0,0 +1,119 @@
+.\"
+.\" SPDX-License-Identifier: BSD-3-Clause
+.\"
+.\" Copyright (c) 2025 Juniper Networks, Inc.
+.\"
+.Dd October 29, 2025
+.Dt KEXEC_LOAD 2
+.Os
+.Sh NAME
+.Nm kexec_load
+.Nd prepare new kernel to reboot into
+.Sh SYNOPSIS
+.Lb libc
+.In sys/kexec.h
+.Ft int
+.Fn kexec_load "uint64_t entry" "unsigned long count" \
+ "struct kexec_segment *segments" "unsigned long flags"
+.Sh DESCRIPTION
+The
+.Fn kexec_load
+system call loads a new kernel that can be executed later by
+.Xr reboot 2 .
+Subsequent calls will replace previously loaded images.
+.Pp
+The
+.Fa flags
+argument is a bitmask of flags that control the operation of the call.
+This argument is present for compatibility with Linux, although it is currently
+unused and must be 0.
+.Pp
+The
+.Fa entry
+argument is the physical address of the entry point of the new kernel image.
+.Pp
+The
+.Fa count
+argument is the number of segments in the image, currently limited to 16.
+A value of 0 will unload the currently staged image, if one exists, without
+staging a new image.
+.Pp
+The
+.Fa segments
+argument is an array of
+.Fa count
+members of the following structure:
+.Bd -literal -offset indent
+struct kexec_segment {
+ void *buf;
+ size_t bufsz;
+ vm_paddr_t mem;
+ vm_size_t memsz;
+};
+.Ed
+.Pp
+The
+.Va buf
+and
+.Va bufsz
+members specify a memory region in the caller's address space containing the
+source of the segment.
+The
+.Va mem
+and
+.Va memsz
+members specify the target physical region of the segment.
+.Va bufsz
+must be less than or equal to
+.Va memsz ,
+and
+.Va mem
+and
+.Va memsz
+must be page aligned.
+The region covered by
+.Va mem
+must be in the list covered by the
+.Va vm.phys_segs
+sysctl.
+.Pp
+The
+.Fn kexec_load
+system call stages the kernel image in safe memory along with all
+machine-dependent image data until
+.Xr reboot 2
+is called with the
+.Va RB_KEXEC
+flag to load the image and execute the new kernel.
+.Sh RETURN VALUES
+The
+.Fn kexec_load
+system call returns 0 on success.
+On failure, -1 is returned, and
+.Va errno
+is set to indicate the error.
+On success any previously loaded image is unloaded and replaced with the new
+image.
+On failure, the previously loaded image is unchanged.
+.Sh ERRORS
+The following errors may be returned:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+Too many segments in image.
+.It Bq Er EINVAL
+The value of
+.Va bufsz
+is larger than
+.Va memsz
+in one or more segments.
+.It Bq Er EINVAL
+Machine-dependent load error.
+.It Bq Er EBUSY
+Another
+.Fn kexec_load
+call is in progress.
+.Sh HISTORY
+The
+.Nm
+system call appeared in
+.Fx 16.0 .
diff --git a/lib/libsys/kqueue.2 b/lib/libsys/kqueue.2
index 96c9b0222a37..a8ebabf02cf7 100644
--- a/lib/libsys/kqueue.2
+++ b/lib/libsys/kqueue.2
@@ -97,10 +97,37 @@ system call also creates a new kernel event queue, and additionally takes
a
.Fa flags
argument, which is a bitwise-inclusive OR of the following flags:
-.Bl -tag -width "KQUEUE_CLOEXEC"
+.Bl -tag -width "KQUEUE_CPONFORK"
.It Dv KQUEUE_CLOEXEC
The returned file descriptor is automatically closed on
.Xr execve 2
+.It Dv KQUEUE_CPONFORK
+When this flag is set, the created kqueue is copied into
+the child process on
+.Xr fork 2
+calls.
+The kqueue descriptor index of the new kqueue will be inherited by the child,
+that is, the numeric value of the descriptor will remain the same.
+.Pp
+Copying is deep, that is, each registered event in the original kqueue is
+copied (and not shared) into the new kqueue.
+This is contrary to how other descriptor types are handled upon
+.Xr fork 2 ,
+where the copied file descriptor references the same file object
+as the source descriptor (shallow copy).
+.Pp
+By default, in other words, when the flag is not set, kqueues from
+the parent are not copied on fork to the child process.
+The corresponding file descriptor indeces are unused in the child.
+.Pp
+Registered events that reference file descriptors which are not
+duplicated on fork, are not copied into the new kqueue.
+For instance, if the event references a file descriptor opened with the
+.Dv O_CLOEXEC
+flag set, it is not copied.
+Similarly, if event references a kqueue opened without the
+.Dv KQUEUE_CPONFORK
+flag, the event is not copied.
.El
.Pp
The
diff --git a/lib/libsys/pathconf.2 b/lib/libsys/pathconf.2
index 5a983a3a13e2..5348128be706 100644
--- a/lib/libsys/pathconf.2
+++ b/lib/libsys/pathconf.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 6, 2025
+.Dd October 31, 2025
.Dt PATHCONF 2
.Os
.Sh NAME
@@ -180,7 +180,8 @@ Return 1 if named attributes are enabled for the file system, otherwise 0.
.It Li _PC_HAS_NAMEDATTR
Return 1 if one or more named attributes exist for the file, otherwise 0.
.It Li _PC_HAS_HIDDENSYSTEM
-Return 1 if both
+Return 1 if all of the
+.Dv UF_ARCHIVE ,
.Dv UF_HIDDEN
and
.Dv UF_SYSTEM
@@ -192,6 +193,9 @@ Returns the block size required for block cloning via
.Xr copy_file_range 2
for a file system if block cloning is supported,
otherwise 0.
+.It Li _PC_CASE_INSENSITIVE
+Return 1 if the file system performs case insensitive lookups,
+otherwise 0.
.El
.Sh RETURN VALUES
If the call to
diff --git a/lib/libsys/posix_fallocate.2 b/lib/libsys/posix_fallocate.2
index 8be075b41331..94858c4a0f90 100644
--- a/lib/libsys/posix_fallocate.2
+++ b/lib/libsys/posix_fallocate.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 30, 2020
+.Dd November 2, 2025
.Dt POSIX_FALLOCATE 2
.Os
.Sh NAME
@@ -105,8 +105,7 @@ The
.Fa len
argument was less than or equal to zero, the
.Fa offset
-argument was less than zero,
-or the operation is not supported by the file system.
+argument was less than zero.
.It Bq Er EIO
An I/O error occurred while reading from or writing to a file system.
.It Bq Er EINTEGRITY
@@ -123,6 +122,8 @@ media.
The file descriptor
.Fa fd
has insufficient rights.
+.It Bq Er EOPNOTSUPP
+The operation is not supported by the file system.
.It Bq Er ESPIPE
The
.Fa fd
@@ -137,12 +138,29 @@ argument is associated with a pipe or FIFO.
The
.Fn posix_fallocate
system call conforms to
-.St -p1003.1-2004 .
+.St -p1003.1-2024 .
.Sh HISTORY
The
.Fn posix_fallocate
function appeared in
.Fx 9.0 .
+.Pp
+Previous versions of
+.Nm
+used
+.Er EINVAL
+to indicate that the operation is not supported by the file system, as specified
+in
+.St -p1003.1
+Base Specifications, Issue 7.
+.St -p1003.1
+Base Specifications, Issue 8 switched to requiring
+.Er EOPNOTSUPP
+for this error case.
+ZFS adopted the latter convention in
+.Fx 15.0 ,
+and the remaining filesystems in base adopted it in
+.Fx 15.1 .
.Sh AUTHORS
.Fn posix_fallocate
and this manual page were initially written by
diff --git a/lib/libsys/reboot.2 b/lib/libsys/reboot.2
index f6c7bf6c83cc..54fa8b599cd5 100644
--- a/lib/libsys/reboot.2
+++ b/lib/libsys/reboot.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 10, 2018
+.Dd October 29, 2025
.Dt REBOOT 2
.Os
.Sh NAME
@@ -126,6 +126,10 @@ on the console.
is actually interpreted by the
.Xr init 8
program in the newly booted system.
+.It Dv RB_KEXEC
+Execute a new kernel loaded via
+.Fn kexec_load 2 .
+If no kernel was loaded, reboot as normal.
.El
.Pp
When no options are given (i.e.,
@@ -149,6 +153,7 @@ variable
The caller is not the super-user.
.El
.Sh SEE ALSO
+.Xr kexec_load 2 ,
.Xr crash 8 ,
.Xr halt 8 ,
.Xr init 8 ,
diff --git a/lib/libsys/revoke.2 b/lib/libsys/revoke.2
index f5ae1e92c357..938d2f083e27 100644
--- a/lib/libsys/revoke.2
+++ b/lib/libsys/revoke.2
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 25, 2016
+.Dd October 24, 2025
.Dt REVOKE 2
.Os
.Sh NAME
@@ -62,7 +62,7 @@ using a special close method which does not block.
Access to a file may be revoked only by its owner or the super user.
The
.Fn revoke
-system call is currently supported only for block and character special
+system call is currently supported only for character special
device files.
It is normally used to prepare a terminal device for a new login session,
preventing any access by a previous user of the terminal.
diff --git a/lib/libsys/socket.2 b/lib/libsys/socket.2
index b211611c6354..48b8f4e87489 100644
--- a/lib/libsys/socket.2
+++ b/lib/libsys/socket.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 17, 2025
+.Dd September 28, 2025
.Dt SOCKET 2
.Os
.Sh NAME
@@ -64,7 +64,7 @@ PF_NETGRAPH Netgraph sockets,
PF_NETLINK Netlink protocols,
PF_BLUETOOTH Bluetooth protocols,
PF_INET_SDP OFED socket direct protocol (IPv4),
-AF_HYPERV HyperV sockets
+PF_HYPERV HyperV sockets
.Ed
.Pp
Each protocol family is connected to an address family, which has the
@@ -89,32 +89,6 @@ SOCK_RAW Raw-protocol interface,
SOCK_SEQPACKET Sequenced packet stream
.Ed
.Pp
-A
-.Dv SOCK_STREAM
-type provides sequenced, reliable,
-two-way connection based byte streams.
-An out-of-band data transmission mechanism may be supported.
-A
-.Dv SOCK_DGRAM
-socket supports
-datagrams (connectionless, unreliable messages of
-a fixed (typically small) maximum length).
-A
-.Dv SOCK_SEQPACKET
-socket may provide a sequenced, reliable,
-two-way connection-based data transmission path for datagrams
-of fixed maximum length; a consumer may be required to read
-an entire packet with each read system call.
-This facility may have protocol-specific properties.
-.Dv SOCK_RAW
-sockets provide access to internal network protocols and interfaces.
-The
-.Dv SOCK_RAW
-type is available only to the super-user and is described in
-.Xr ip 4
-and
-.Xr ip6 4 .
-.Pp
Additionally, the following flags are allowed in the
.Fa type
argument:
@@ -140,32 +114,23 @@ particular to the
in which communication
is to take place; see
.Xr protocols 5 .
-.Pp
The
.Fa protocol
argument may be set to zero (0) to request the default
implementation of a socket type for the protocol, if any.
-.Pp
-Sockets of type
+.Sh STREAM SOCKET TYPE
+The
+.Dv SOCK_STREAM
+socket type provides reliable, sequenced, full-duplex octet streams between
+the socket and a peer to which the socket is connected.
+A socket of type
.Dv SOCK_STREAM
-are full-duplex byte streams, similar
-to pipes.
-A stream socket must be in a
+needs to be in a
.Em connected
-state before any data may be sent or received
-on it.
+state before any data can be sent or received.
A connection to another socket is created with a
.Xr connect 2
system call.
-Once connected, data may be transferred using
-.Xr read 2
-and
-.Xr write 2
-calls or some variant of the
-.Xr send 2
-and
-.Xr recv 2
-functions.
(Some protocol families, such as the Internet family,
support the notion of an
.Dq implied connect ,
@@ -173,62 +138,210 @@ which permits data to be sent piggybacked onto a connect operation by
using the
.Xr sendto 2
system call.)
-When a session has been completed a
-.Xr close 2
-may be performed.
-Out-of-band data may also be transmitted as described in
+Once connected, data may be sent using
+.Xr send 2 ,
+.Xr sendto 2 ,
+.Xr sendmsg 2
+and
+.Xr write 2
+system calls.
+Data may be received using
+.Xr recv 2 ,
+.Xr recvfrom 2 ,
+.Xr recvmsg 2 ,
+and
+.Xr read 2
+system calls.
+Record boundaries are not maintained; data sent on a stream socket using output
+operations of one size can be received using input operations of smaller or
+larger sizes without loss of data.
+Data may be buffered; successful return from an output function does not imply
+that the data has been delivered to the peer or even transmitted from the local
+system.
+For certain protocols out-of-band data may also be transmitted as described in
.Xr send 2
and received as described in
.Xr recv 2 .
.Pp
-The communications protocols used to implement a
-.Dv SOCK_STREAM
-ensure that data
-is not lost or duplicated.
-If a piece of data for which the
-peer protocol has buffer space cannot be successfully transmitted
-within a reasonable length of time, then
-the connection is considered broken and calls
-will indicate an error with
--1 returns and with
-.Er ETIMEDOUT
-as the specific code
-in the global variable
-.Va errno .
-The protocols optionally keep sockets
-.Dq warm
-by forcing transmissions
-roughly every minute in the absence of other activity.
-An error is then indicated if no response can be
-elicited on an otherwise
-idle connection for an extended period (e.g.\& 5 minutes).
-By default, a
+If data cannot be successfully transmitted within a given time then the
+connection is considered broken, and subsequent operations shall fail with
+a protocol specific error code.
+A
.Dv SIGPIPE
-signal is raised if a process sends
-on a broken stream, but this behavior may be inhibited via
+signal is raised if a thread attempts to send data on a broken stream (one that
+is no longer connected).
+The signal can be suppressed by the
+.Dv MSG_NOSIGNAL
+flag with distinct
+.Xr send 2 ,
+.Xr sendto 2 ,
+and
+.Xr sendmsg 2
+system calls or by the
+.Dv SO_NOSIGPIPE
+socket option set on the socket with
.Xr setsockopt 2 .
.Pp
-.Dv SOCK_SEQPACKET
-sockets employ the same system calls
-as
+The
.Dv SOCK_STREAM
-sockets.
-The only difference
-is that
-.Xr read 2
-calls will return only the amount of data requested,
-and any remaining in the arriving packet will be discarded.
+socket is supported by the following protocol families:
+.Dv PF_INET ,
+.Dv PF_INET6 ,
+.Dv PF_UNIX ,
+.Dv PF_BLUETOOTH ,
+.Dv PF_HYPERV ,
+and
+.Dv PF_INET_SDP .
+Out-of-band data transmission mechanism is supported for stream sockets of
+.Dv PF_INET
+and
+.Dv PF_INET6
+protocol families.
+.Sh DATAGRAM SOCKET TYPE
+The
+.Dv SOCK_DGRAM
+socket type supports connectionless data transfer which is not necessarily
+acknowledged or reliable.
+Datagrams can be sent to the address specified (possibly multicast or
+broadcast) in each output operation, and incoming datagrams can be received
+from multiple sources.
+The source address of each datagram is available when receiving the datagram
+with
+.Xr recvfrom 2
+or
+.Xr recvmsg 2 .
+An application can also pre-specify a peer address with
+.Xr sendto 2
+or
+.Xr sendmsg 2 ,
+in which case calls to output functions that do not specify a peer address
+shall send to the pre-specified peer.
+If a peer has been specified, only datagrams from that peer shall be received.
+A datagram shall be sent in a single output operation, and needs to be received
+in a single input operation.
+The maximum size of a datagram is protocol-specific.
+Output datagrams may be buffered within the system; thus, a successful return
+from an output function does not guarantee that a datagram is actually sent or
+received.
.Pp
+The
.Dv SOCK_DGRAM
+socket is supported by the following protocol families:
+.Dv PF_INET ,
+.Dv PF_INET6 ,
+.Dv PF_UNIX ,
+.Dv PF_NETGRAPH ,
and
-.Dv SOCK_RAW
-sockets allow sending of datagrams to correspondents
-named in
+.Dv PF_NETLINK .
+.Sh SEQUENCED PACKET SOCKET TYPE
+The
+.Dv SOCK_SEQPACKET
+socket type is similar to the
+.Dv SOCK_STREAM
+type, and is also connection-oriented.
+The only difference between these types is that record boundaries are
+maintained using the
+.Dv SOCK_SEQPACKET
+type.
+A record can be sent using one or more output operations and received using one
+or more input operations, but a single operation never transfers parts of more
+than one record.
+Record boundaries are set by the sender with the
+.Dv MSG_EOR
+flag of
.Xr send 2
-calls.
-Datagrams are generally received with
+or
+.Xr sendmsg 2
+functions.
+There is no possibility to set a record boundary with
+.Xr write 2 .
+Record boundaries are visible to the receiver via the
+.Dv MSG_EOR
+flag in the received message flags returned by the
+.Xr recvmsg 2
+function.
+It is protocol-specific whether a maximum record size is imposed.
+.Pp
+The
+.Dv SOCK_SEQPACKET
+socket is supported by the following protocol families:
+.Dv PF_INET ,
+.Dv PF_INET6 ,
+and
+.Dv PF_UNIX .
+.Pp
+.Sh RAW SOCKET TYPE
+The
+.Dv SOCK_RAW
+socket type provides access to internal network protocols and interfaces.
+It is a datagram socket in its nature, thus has the same semantics of
+read and write operations.
+The
+.Dv SOCK_RAW
+type is available only to the super-user and is described in
+.Xr ip 4
+and
+.Xr ip6 4 .
+.Sh NON-BLOCKING MODE
+A socket can be created in
+.Em non-blocking mode
+with the help of
+.Dv SOCK_NONBLOCK
+flag.
+Alternatively, the non-blocking mode on a socket can be turned on and off with
+the help of the
+.Dv O_NONBLOCK
+flag of the
+.Xr fcntl 2
+system call.
+.Pp
+When a non-blocking socket has not enough data in its receive buffer to fulfill
+the application supplied buffer, then data receiving system calls like
+.Xr recv 2 ,
.Xr recvfrom 2 ,
-which returns the next datagram with its return address.
+.Xr recvmsg 2
+and
+.Xr read 2
+will not block waiting for the data but immediately return.
+Return value will indicate amount of bytes read into the supplied buffer.
+The
+.Va errno
+will be set to
+.Dv EAGAIN
+.Po
+has same value as
+.Dv EWOULDBLOCK
+.Pc .
+.Pp
+If application tries to send more data on a non-blocking socket than the socket
+send buffer can accomodate with
+.Xr send 2 ,
+.Xr sendto 2 ,
+.Xr sendmsg 2
+or
+.Xr write 2
+system calls partial data will be sent.
+Return value will indicate amount of bytes sent.
+The
+.Va errno
+will be set to
+.Dv EAGAIN .
+Note that sockets of
+.Dv SOCK_DGRAM
+type are unreliable, thus for these sockets sending operations will never fail
+with
+.Dv EAGAIN
+in non-blocking mode neither will block in blocking mode.
+.Sh OTHER OPERATIONS ON SOCKETS
+Since socket descriptors are file descriptors, many generic file operations
+performed by
+.Xr fcntl 2 ,
+apply.
+Socket descriptors can be used with all event engines, such as
+.Xr kevent 2 ,
+.Xr select 2
+and
+.Xr poll 2 .
.Pp
An
.Xr fcntl 2
@@ -250,6 +363,12 @@ The
and
.Xr getsockopt 2
system calls are used to set and get options, respectively.
+.Pp
+Connection associated with a socket can be terminated by
+.Xr close 2
+system call.
+One direction of communication can be disabled with
+.Xr shutdown 2 .
.Sh RETURN VALUES
A -1 is returned if an error occurs, otherwise the return
value is a descriptor referencing the socket.
@@ -282,16 +401,23 @@ The socket type is not supported by the protocol.
.Sh SEE ALSO
.Xr accept 2 ,
.Xr bind 2 ,
+.Xr close 2 ,
.Xr connect 2 ,
+.Xr fcntl 2 ,
.Xr getpeername 2 ,
.Xr getsockname 2 ,
.Xr getsockopt 2 ,
.Xr ioctl 2 ,
+.Xr kevent 2 ,
.Xr listen 2 ,
+.Xr poll 2 ,
.Xr read 2 ,
.Xr recv 2 ,
.Xr select 2 ,
.Xr send 2 ,
+.Xr sendmsg 2 ,
+.Xr sendto 2 ,
+.Xr signal 3 ,
.Xr shutdown 2 ,
.Xr socketpair 2 ,
.Xr write 2 ,
diff --git a/lib/libsys/syscalls.map b/lib/libsys/syscalls.map
index b5400b9849b3..d00c862eb462 100644
--- a/lib/libsys/syscalls.map
+++ b/lib/libsys/syscalls.map
@@ -817,4 +817,6 @@ FBSDprivate_1.0 {
__sys_jail_attach_jd;
_jail_remove_jd;
__sys_jail_remove_jd;
+ _kexec_load;
+ __sys_kexec_load;
};
diff --git a/lib/libsys/write.2 b/lib/libsys/write.2
index d2ff41ceead9..77067893ab4c 100644
--- a/lib/libsys/write.2
+++ b/lib/libsys/write.2
@@ -132,6 +132,26 @@ and
may write fewer bytes than requested;
the return value must be noted,
and the remainder of the operation should be retried when possible.
+.Sh ATOMICITY OF WRITES
+When operating on regular files on local file systems, the effects of
+.Fn write
+are atomic.
+As required by the POSIX standard,
+the
+.Fn read ,
+.Fn write ,
+and
+.Fn ftruncate
+functions and their variations are atomic with respect to
+each other on the file data and metadata for regular files.
+See for instance
+.St -p1003.1-2024
+Volume 2, Section 2.9.7 for more information.
+.Pp
+.Fx
+implements the requirement by taking
+a read/write range lock on the file byte range
+affected by the corresponding function.
.Sh RETURN VALUES
Upon successful completion the number of bytes which were written
is returned.