Index: head/lib/libc/sys/access.2 =================================================================== --- head/lib/libc/sys/access.2 (revision 359464) +++ head/lib/libc/sys/access.2 (revision 359465) @@ -1,268 +1,270 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)access.2 8.2 (Berkeley) 4/1/94 .\" $FreeBSD$ .\" -.Dd November 11, 2018 +.Dd March 30, 2020 .Dt ACCESS 2 .Os .Sh NAME .Nm access , .Nm eaccess , .Nm faccessat .Nd check accessibility of a file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn access "const char *path" "int mode" .Ft int .Fn eaccess "const char *path" "int mode" .Ft int .Fn faccessat "int fd" "const char *path" "int mode" "int flag" .Sh DESCRIPTION The .Fn access and .Fn eaccess system calls check the accessibility of the file named by the .Fa path argument for the access permissions indicated by the .Fa mode argument. The value of .Fa mode is either the bitwise-inclusive OR of the access permissions to be checked .Dv ( R_OK for read permission, .Dv W_OK for write permission, and .Dv X_OK for execute/search permission), or the existence test .Pq Dv F_OK . .Pp For additional information, see the .Sx "File Access Permission" section of .Xr intro 2 . .Pp The .Fn eaccess system call uses the effective user ID and the group access list to authorize the request; the .Fn access system call uses the real user ID in place of the effective user ID, the real group ID in place of the effective group ID, and the rest of the group access list. .Pp The .Fn faccessat system call is equivalent to .Fn access except in the case where .Fa path specifies a relative path. In this case the file whose accessibility is to be determined is located relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. If .Fn faccessat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn access . Values for .Fa flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_EACCESS The checks for accessibility are performed using the effective user and group IDs instead of the real user and group ID as required in a call to .Fn access . .It Dv AT_BENEATH Only operate on files and directories below the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp Even if a process's real or effective user has appropriate privileges and indicates success for .Dv X_OK , the file may not actually have execute permission bits set. Likewise for .Dv R_OK and .Dv W_OK . .Sh RETURN VALUES .Rv -std .Sh ERRORS .Fn access , .Fn eaccess , or .Fn faccessat will fail if: .Bl -tag -width Er .It Bq Er EINVAL The value of the .Fa mode argument is invalid. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EROFS Write access is requested for a file on a read-only file system. .It Bq Er ETXTBSY Write access is requested for a pure procedure (shared text) file presently being executed. .It Bq Er EACCES Permission bits of the file mode do not permit the requested access, or search permission is denied on a component of the path prefix. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp Also, the .Fn faccessat system call may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fn faccessat , and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Sh SEE ALSO .Xr chmod 2 , .Xr intro 2 , .Xr stat 2 .Sh STANDARDS The .Fn access system call is expected to conform to .St -p1003.1-90 . The .Fn faccessat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn access function appeared in .At v7 . The .Fn faccessat system call appeared in .Fx 8.0 . .Sh SECURITY CONSIDERATIONS The .Fn access system call is a potential security hole due to race conditions and should never be used. Set-user-ID and set-group-ID applications should restore the effective user or group ID, and perform actions directly rather than use .Fn access to simulate access checks for the real user or group ID. The .Fn eaccess system call likewise may be subject to races if used inappropriately. .Pp .Fn access remains useful for providing clues to users as to whether operations make sense for particular filesystem objects (e.g. 'delete' menu item only highlighted in a writable folder ... avoiding interpretation of the st_mode bits that the application might not understand -- e.g. in the case of AFS). It also allows a cheaper file existence test than .Xr stat 2 . Index: head/lib/libc/sys/acct.2 =================================================================== --- head/lib/libc/sys/acct.2 (revision 359464) +++ head/lib/libc/sys/acct.2 (revision 359465) @@ -1,131 +1,133 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)acct.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 17, 2004 +.Dd March 30, 2020 .Dt ACCT 2 .Os .Sh NAME .Nm acct .Nd enable or disable process accounting .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn acct "const char *file" .Sh DESCRIPTION The .Fn acct system call enables or disables the collection of system accounting records. If the argument .Fa file is a null pointer, accounting is disabled. If .Fa file is an .Em existing pathname (null-terminated), record collection is enabled and for every process initiated which terminates under normal conditions an accounting record is appended to .Fa file . Abnormal conditions of termination are reboots or other fatal system problems. Records for processes which never terminate cannot be produced by .Fn acct . .Pp For more information on the record structure used by .Fn acct , see .In sys/acct.h and .Xr acct 5 . .Pp This call is permitted only to the super-user. .Sh NOTES Accounting is automatically disabled when the file system the accounting file resides on runs out of space; it is enabled when space once again becomes available. The values controlling this behaviour can be modified using the following .Xr sysctl 8 variables: .Bl -tag -width ".Va kern.acct_chkfreq" .It Va kern.acct_chkfreq Specifies the frequency (in seconds) with which free disk space should be checked. .It Va kern.acct_resume The percentage of free disk space above which process accounting will resume. .It Va kern.acct_suspend The percentage of free disk space below which process accounting will suspend. .El .Sh RETURN VALUES On error -1 is returned. The file must exist and the call may be exercised only by the super-user. .Sh ERRORS The .Fn acct system call will fail if one of the following is true: .Bl -tag -width Er .It Bq Er EPERM The caller is not the super-user. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix, or the path name is not a regular file. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er EFAULT The .Fa file argument points outside the process's allocated address space. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr acct 5 , .Xr accton 8 , .Xr sa 8 .Sh HISTORY The .Fn acct function appeared in .At v7 . Index: head/lib/libc/sys/bind.2 =================================================================== --- head/lib/libc/sys/bind.2 (revision 359464) +++ head/lib/libc/sys/bind.2 (revision 359465) @@ -1,139 +1,141 @@ .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)bind.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd August 18, 2016 +.Dd March 30, 2020 .Dt BIND 2 .Os .Sh NAME .Nm bind .Nd assign a local protocol address to a socket .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/socket.h .Ft int .Fn bind "int s" "const struct sockaddr *addr" "socklen_t addrlen" .Sh DESCRIPTION The .Fn bind system call assigns the local protocol address to a socket. When a socket is created with .Xr socket 2 it exists in an address family space but has no protocol address assigned. The .Fn bind system call requests that .Fa addr be assigned to the socket. .Sh NOTES Binding an address in the UNIX domain creates a socket in the file system that must be deleted by the caller when it is no longer needed (using .Xr unlink 2 ) . .Pp The rules used in address binding vary between communication domains. Consult the manual entries in section 4 for detailed information. .Pp For maximum portability, you should always zero the socket address structure before populating it and passing it to .Fn bind . .Sh RETURN VALUES .Rv -std bind .Sh ERRORS The .Fn bind system call will fail if: .Bl -tag -width Er .It Bq Er EAGAIN Kernel resources to complete the request are temporarily unavailable. .It Bq Er EBADF The .Fa s argument is not a valid descriptor. .It Bq Er EINVAL The socket is already bound to an address, and the protocol does not support binding to a new address; or the socket has been shut down. .It Bq Er EINVAL The .Fa addrlen argument is not a valid length for the address family. .It Bq Er ENOTSOCK The .Fa s argument is not a socket. .It Bq Er EADDRNOTAVAIL The specified address is not available from the local machine. .It Bq Er EADDRINUSE The specified address is already in use. .It Bq Er EAFNOSUPPORT Addresses in the specified address family cannot be used with this socket. .It Bq Er EACCES The requested address is protected, and the current user has inadequate permission to access it. .It Bq Er EFAULT The .Fa addr argument is not in a valid part of the user address space. .El .Pp The following errors are specific to binding addresses in the UNIX domain. .Bl -tag -width EADDRNOTAVA .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT A prefix component of the path name does not exist. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EIO An I/O error occurred while making the directory entry or allocating the inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EROFS The name would reside on a read-only file system. .It Bq Er EISDIR An empty pathname was specified. .El .Sh SEE ALSO .Xr connect 2 , .Xr getsockname 2 , .Xr listen 2 , .Xr socket 2 .Sh HISTORY The .Fn bind system call appeared in .Bx 4.2 . Index: head/lib/libc/sys/chdir.2 =================================================================== --- head/lib/libc/sys/chdir.2 (revision 359464) +++ head/lib/libc/sys/chdir.2 (revision 359465) @@ -1,132 +1,134 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)chdir.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd December 1, 2017 +.Dd March 30, 2020 .Dt CHDIR 2 .Os .Sh NAME .Nm chdir , .Nm fchdir .Nd change current working directory .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn chdir "const char *path" .Ft int .Fn fchdir "int fd" .Sh DESCRIPTION The .Fa path argument points to the pathname of a directory. The .Fn chdir system call causes the named directory to become the current working directory, that is, the starting point for path searches of pathnames not beginning with a slash, .Ql / . .Pp The .Fn fchdir system call causes the directory referenced by .Fa fd to become the current working directory, the starting point for path searches of pathnames not beginning with a slash, .Ql / . .Pp In order for a directory to become the current directory, a process must have execute (search) access to the directory. .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn chdir system call will fail and the current working directory will be unchanged if one or more of the following are true: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named directory does not exist. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EACCES Search permission is denied for any component of the path name. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp The .Fn fchdir system call will fail and the current working directory will be unchanged if one or more of the following are true: .Bl -tag -width Er .It Bq Er EACCES Search permission is denied for the directory referenced by the file descriptor. .It Bq Er ENOTDIR The file descriptor does not reference a directory. .It Bq Er EBADF The argument .Fa fd is not a valid file descriptor. .El .Sh SEE ALSO .Xr chroot 2 .Sh STANDARDS The .Fn chdir system call is expected to conform to .St -p1003.1-90 . .Sh HISTORY The .Fn chdir system call appeared in .At v1 . The .Fn fchdir system call appeared in .Bx 4.2 . Index: head/lib/libc/sys/chflags.2 =================================================================== --- head/lib/libc/sys/chflags.2 (revision 359464) +++ head/lib/libc/sys/chflags.2 (revision 359465) @@ -1,352 +1,356 @@ .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)chflags.2 8.3 (Berkeley) 5/2/95 .\" $FreeBSD$ .\" -.Dd November 11, 2018 +.Dd March 30, 2020 .Dt CHFLAGS 2 .Os .Sh NAME .Nm chflags , .Nm lchflags , .Nm fchflags , .Nm chflagsat .Nd set file flags .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/stat.h .In unistd.h .Ft int .Fn chflags "const char *path" "unsigned long flags" .Ft int .Fn lchflags "const char *path" "unsigned long flags" .Ft int .Fn fchflags "int fd" "unsigned long flags" .Ft int .Fn chflagsat "int fd" "const char *path" "unsigned long flags" "int atflag" .Sh DESCRIPTION The file whose name is given by .Fa path or referenced by the descriptor .Fa fd has its flags changed to .Fa flags . .Pp The .Fn lchflags system call is like .Fn chflags except in the case where the named file is a symbolic link, in which case .Fn lchflags will change the flags of the link itself, rather than the file it points to. .Pp The .Fn chflagsat is equivalent to either .Fn chflags or .Fn lchflags depending on the .Fa atflag except in the case where .Fa path specifies a relative path. In this case the file to be changed is determined relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. The values for the .Fa atflag are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_NOFOLLOW If .Fa path names a symbolic link, then the flags of the symbolic link are changed. .It Dv AT_BENEATH Only allow to change flags for a file which is beneath of the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn chflagsat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used. If also .Fa atflag is zero, the behavior is identical to a call to .Fn chflags . .Pp The flags specified are formed by .Em or Ns 'ing the following values .Pp .Bl -tag -width ".Dv SF_IMMUTABLE" -compact -offset indent .It Dv SF_APPEND The file may only be appended to. .It Dv SF_ARCHIVED The file has been archived. This flag means the opposite of the DOS, Windows and CIFS FILE_ATTRIBUTE_ARCHIVE attribute. This flag has been deprecated, and may be removed in a future release. .It Dv SF_IMMUTABLE The file may not be changed. .It Dv SF_NOUNLINK The file may not be renamed or deleted. .It Dv SF_SNAPSHOT The file is a snapshot file. .It Dv UF_APPEND The file may only be appended to. .It Dv UF_ARCHIVE The file needs to be archived. This flag has the same meaning as the DOS, Windows and CIFS FILE_ATTRIBUTE_ARCHIVE attribute. Filesystems in FreeBSD may or may not have special handling for this flag. For instance, ZFS tracks changes to files and will set this bit when a file is updated. UFS only stores the flag, and relies on the application to change it when needed. .It Dv UF_HIDDEN The file may be hidden from directory listings at the application's discretion. The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_HIDDEN attribute. .It Dv UF_IMMUTABLE The file may not be changed. .It Dv UF_NODUMP Do not dump the file. .It Dv UF_NOUNLINK The file may not be renamed or deleted. .It Dv UF_OFFLINE The file is offline, or has the Windows and CIFS FILE_ATTRIBUTE_OFFLINE attribute. Filesystems in FreeBSD store and display this flag, but do not provide any special handling when it is set. .It Dv UF_OPAQUE The directory is opaque when viewed through a union stack. .It Dv UF_READONLY The file is read only, and may not be written or appended. Filesystems may use this flag to maintain compatibility with the DOS, Windows and CIFS FILE_ATTRIBUTE_READONLY attribute. .It Dv UF_REPARSE The file contains a Windows reparse point and has the Windows and CIFS FILE_ATTRIBUTE_REPARSE_POINT attribute. .It Dv UF_SPARSE The file has the Windows FILE_ATTRIBUTE_SPARSE_FILE attribute. This may also be used by a filesystem to indicate a sparse file. .It Dv UF_SYSTEM The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_SYSTEM attribute. Filesystems in FreeBSD may store and display this flag, but do not provide any special handling when it is set. .El .Pp If one of .Dv SF_IMMUTABLE , SF_APPEND , or .Dv SF_NOUNLINK is set a non-super-user cannot change any flags and even the super-user can change flags only if securelevel is 0. (See .Xr init 8 for details.) .Pp The .Dv UF_IMMUTABLE , UF_APPEND , UF_NOUNLINK , UF_NODUMP , and .Dv UF_OPAQUE flags may be set or unset by either the owner of a file or the super-user. .Pp The .Dv SF_IMMUTABLE , SF_APPEND , SF_NOUNLINK , and .Dv SF_ARCHIVED flags may only be set or unset by the super-user. Attempts to toggle these flags by non-super-users are rejected. These flags may be set at any time, but normally may only be unset when the system is in single-user mode. (See .Xr init 8 for details.) .Pp The implementation of all flags is filesystem-dependent. See the description of the .Dv UF_ARCHIVE flag above for one example of the differences in behavior. Care should be exercised when writing applications to account for support or lack of support of these flags in various filesystems. .Pp The .Dv SF_SNAPSHOT flag is maintained by the system and cannot be toggled. .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn chflags system call will fail if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user. .It Bq Er EPERM One of .Dv SF_IMMUTABLE , SF_APPEND , or .Dv SF_NOUNLINK is set and the user is either not the super-user or securelevel is greater than 0. .It Bq Er EPERM A non-super-user attempted to toggle one of .Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND , or .Dv SF_NOUNLINK . .It Bq Er EPERM An attempt was made to toggle the .Dv SF_SNAPSHOT flag. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EOPNOTSUPP The underlying file system does not support file flags, or does not support all of the flags set in .Fa flags . .El .Pp The .Fn fchflags system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The descriptor is not valid. .It Bq Er EINVAL The .Fa fd argument refers to a socket, not to a file. .It Bq Er EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user. .It Bq Er EPERM One of .Dv SF_IMMUTABLE , SF_APPEND , or .Dv SF_NOUNLINK is set and the user is either not the super-user or securelevel is greater than 0. .It Bq Er EPERM A non-super-user attempted to toggle one of .Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND , or .Dv SF_NOUNLINK . .It Bq Er EPERM An attempt was made to toggle the .Dv SF_SNAPSHOT flag. .It Bq Er EROFS The file resides on a read-only file system. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EOPNOTSUPP The underlying file system does not support file flags, or does not support all of the flags set in .Fa flags . .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fn chflagsat , and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Sh SEE ALSO .Xr chflags 1 , .Xr fflagstostr 3 , .Xr strtofflags 3 , .Xr init 8 , .Xr mount_unionfs 8 .Sh HISTORY The .Fn chflags and .Fn fchflags system calls first appeared in .Bx 4.4 . The .Fn lchflags system call first appeared in .Fx 5.0 . The .Fn chflagsat system call first appeared in .Fx 10.0 . Index: head/lib/libc/sys/chmod.2 =================================================================== --- head/lib/libc/sys/chmod.2 (revision 359464) +++ head/lib/libc/sys/chmod.2 (revision 359465) @@ -1,353 +1,357 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)chmod.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd November 11, 2018 +.Dd March 30, 2020 .Dt CHMOD 2 .Os .Sh NAME .Nm chmod , .Nm fchmod , .Nm lchmod , .Nm fchmodat .Nd change mode of file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/stat.h .Ft int .Fn chmod "const char *path" "mode_t mode" .Ft int .Fn fchmod "int fd" "mode_t mode" .Ft int .Fn lchmod "const char *path" "mode_t mode" .Ft int .Fn fchmodat "int fd" "const char *path" "mode_t mode" "int flag" .Sh DESCRIPTION The file permission bits of the file named specified by .Fa path or referenced by the file descriptor .Fa fd are changed to .Fa mode . The .Fn chmod system call verifies that the process owner (user) either owns the file specified by .Fa path (or .Fa fd ) , or is the super-user. The .Fn chmod system call follows symbolic links to operate on the target of the link rather than the link itself. .Pp The .Fn lchmod system call is similar to .Fn chmod but does not follow symbolic links. .Pp The .Fn fchmodat is equivalent to either .Fn chmod or .Fn lchmod depending on the .Fa flag except in the case where .Fa path specifies a relative path. In this case the file to be changed is determined relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. The values for the .Fa flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_NOFOLLOW If .Fa path names a symbolic link, then the mode of the symbolic link is changed. .It Dv AT_BENEATH Only allow to change permissions of a file which is beneath of the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn fchmodat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used. If also .Fa flag is zero, the behavior is identical to a call to .Fn chmod . .Pp A mode is created from .Em or'd permission bit masks defined in .In sys/stat.h : .Pp .Bd -literal -offset indent -compact #define S_IRWXU 0000700 /* RWX mask for owner */ #define S_IRUSR 0000400 /* R for owner */ #define S_IWUSR 0000200 /* W for owner */ #define S_IXUSR 0000100 /* X for owner */ #define S_IRWXG 0000070 /* RWX mask for group */ #define S_IRGRP 0000040 /* R for group */ #define S_IWGRP 0000020 /* W for group */ #define S_IXGRP 0000010 /* X for group */ #define S_IRWXO 0000007 /* RWX mask for other */ #define S_IROTH 0000004 /* R for other */ #define S_IWOTH 0000002 /* W for other */ #define S_IXOTH 0000001 /* X for other */ #define S_ISUID 0004000 /* set user id on execution */ #define S_ISGID 0002000 /* set group id on execution */ #define S_ISVTX 0001000 /* sticky bit */ .Ed .Pp The non-standard .Dv S_ISTXT is a synonym for .Dv S_ISVTX . .Pp The .Fx VM system totally ignores the sticky bit .Pq Dv S_ISVTX for executables. On UFS-based file systems (FFS, LFS) the sticky bit may only be set upon directories. .Pp If mode .Dv S_ISVTX (the `sticky bit') is set on a directory, an unprivileged user may not delete or rename files of other users in that directory. The sticky bit may be set by any user on a directory which the user owns or has appropriate permissions. For more details of the properties of the sticky bit, see .Xr sticky 7 . .Pp If mode ISUID (set UID) is set on a directory, and the MNT_SUIDDIR option was used in the mount of the file system, then the owner of any new files and sub-directories created within this directory are set to be the same as the owner of that directory. If this function is enabled, new directories will inherit the bit from their parents. Execute bits are removed from the file, and it will not be given to root. This behavior does not change the requirements for the user to be allowed to write the file, but only the eventual owner after it has been created. Group inheritance is not affected. .Pp This feature is designed for use on fileservers serving PC users via ftp, SAMBA, or netatalk. It provides security holes for shell users and as such should not be used on shell machines, especially on home directories. This option requires the SUIDDIR option in the kernel to work. Only UFS file systems support this option. For more details of the suiddir mount option, see .Xr mount 8 . .Pp Writing or changing the owner of a file turns off the set-user-id and set-group-id bits unless the user is the super-user. This makes the system somewhat more secure by protecting set-user-id (set-group-id) files from remaining set-user-id (set-group-id) if they are modified, at the expense of a degree of compatibility. .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn chmod system call will fail and the file mode will be unchanged if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user. .It Bq Er EPERM The effective user ID is not the super-user, the effective user ID do match the owner of the file, but the group ID of the file does not match the effective group ID nor one of the supplementary group IDs. .It Bq Er EPERM The named file has its immutable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFTYPE The effective user ID is not the super-user, the mode includes the sticky bit .Dv ( S_ISVTX ) , and path does not refer to a directory. .El .Pp The .Fn fchmod system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The descriptor is not valid. .It Bq Er EINVAL The .Fa fd argument refers to a socket, not to a file. .It Bq Er EROFS The file resides on a read-only file system. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp In addition to the .Fn chmod errors, .Fn fchmodat fails if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Fa AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fn fchmodat , and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Sh SEE ALSO .Xr chmod 1 , .Xr chflags 2 , .Xr chown 2 , .Xr open 2 , .Xr stat 2 , .Xr sticky 7 .Sh STANDARDS The .Fn chmod system call is expected to conform to .St -p1003.1-90 , except for the return of .Er EFTYPE . The .Dv S_ISVTX bit on directories is expected to conform to .St -susv3 . The .Fn fchmodat system call is expected to conform to .St -p1003.1-2008 . .Sh HISTORY The .Fn chmod function appeared in .At v1 . The .Fn fchmod system call appeared in .Bx 4.2 . The .Fn lchmod system call appeared in .Fx 3.0 . The .Fn fchmodat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/chown.2 =================================================================== --- head/lib/libc/sys/chown.2 (revision 359464) +++ head/lib/libc/sys/chown.2 (revision 359465) @@ -1,294 +1,298 @@ .\" Copyright (c) 1980, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)chown.2 8.4 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd November 11, 2018 +.Dd March 30, 2020 .Dt CHOWN 2 .Os .Sh NAME .Nm chown , .Nm fchown , .Nm lchown , .Nm fchownat .Nd change owner and group of a file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn chown "const char *path" "uid_t owner" "gid_t group" .Ft int .Fn fchown "int fd" "uid_t owner" "gid_t group" .Ft int .Fn lchown "const char *path" "uid_t owner" "gid_t group" .Ft int .Fn fchownat "int fd" "const char *path" "uid_t owner" "gid_t group" "int flag" .Sh DESCRIPTION The owner ID and group ID of the file named by .Fa path or referenced by .Fa fd is changed as specified by the arguments .Fa owner and .Fa group . The owner of a file may change the .Fa group to a group of which he or she is a member, but the change .Fa owner capability is restricted to the super-user. .Pp The .Fn chown system call clears the set-user-id and set-group-id bits on the file to prevent accidental or mischievous creation of set-user-id and set-group-id programs if not executed by the super-user. The .Fn chown system call follows symbolic links to operate on the target of the link rather than the link itself. .Pp The .Fn fchown system call is particularly useful when used in conjunction with the file locking primitives (see .Xr flock 2 ) . .Pp The .Fn lchown system call is similar to .Fn chown but does not follow symbolic links. .Pp The .Fn fchownat system call is equivalent to the .Fn chown and .Fn lchown except in the case where .Fa path specifies a relative path. In this case the file to be changed is determined relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. .Pp Values for .Fa flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_NOFOLLOW If .Fa path names a symbolic link, ownership of the symbolic link is changed. .It Dv AT_BENEATH Only allow to change ownership of a file which is beneath of the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn fchownat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn chown or .Fn lchown respectively, depending on whether or not the .Dv AT_SYMLINK_NOFOLLOW bit is set in the .Fa flag argument. .Pp One of the owner or group id's may be left unchanged by specifying it as -1. .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn chown and .Fn lchown will fail and the file will be unchanged if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The operation would change the ownership, but the effective user ID is not the super-user. .It Bq Er EPERM The named file has its immutable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp The .Fn fchown system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument does not refer to a valid descriptor. .It Bq Er EINVAL The .Fa fd argument refers to a socket, not a file. .It Bq Er EPERM The effective user ID is not the super-user. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp In addition to the errors specified for .Fn chown and .Fn lchown , the .Fn fchownat system call may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fn fchownat , and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Sh SEE ALSO .Xr chgrp 1 , .Xr chflags 2 , .Xr chmod 2 , .Xr flock 2 , .Xr chown 8 .Sh STANDARDS The .Fn chown system call is expected to conform to .St -p1003.1-90 . The .Fn fchownat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn chown function appeared in .At v1 . The .Fn fchown system call appeared in .Bx 4.2 . .Pp The .Fn chown system call was changed to follow symbolic links in .Bx 4.4 . The .Fn lchown system call was added in .Fx 3.0 to compensate for the loss of functionality. .Pp The .Fn fchownat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/chroot.2 =================================================================== --- head/lib/libc/sys/chroot.2 (revision 359464) +++ head/lib/libc/sys/chroot.2 (revision 359465) @@ -1,156 +1,158 @@ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)chroot.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 3, 2012 +.Dd March 30, 2020 .Dt CHROOT 2 .Os .Sh NAME .Nm chroot .Nd change root directory .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn chroot "const char *dirname" .Sh DESCRIPTION The .Fa dirname argument is the address of the pathname of a directory, terminated by an ASCII NUL. The .Fn chroot system call causes .Fa dirname to become the root directory, that is, the starting point for path searches of pathnames beginning with .Ql / . .Pp In order for a directory to become the root directory a process must have execute (search) access for that directory. .Pp It should be noted that .Fn chroot has no effect on the process's current directory. .Pp This call is restricted to the super-user. .Pp Depending on the setting of the .Ql kern.chroot_allow_open_directories sysctl variable, open filedescriptors which reference directories will make the .Fn chroot fail as follows: .Pp If .Ql kern.chroot_allow_open_directories is set to zero, .Fn chroot will always fail with .Er EPERM if there are any directories open. .Pp If .Ql kern.chroot_allow_open_directories is set to one (the default), .Fn chroot will fail with .Er EPERM if there are any directories open and the process is already subject to the .Fn chroot system call. .Pp Any other value for .Ql kern.chroot_allow_open_directories will bypass the check for open directories .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn chroot system call will fail and the root directory will be unchanged if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path name is not a directory. .It Bq Er EPERM The effective user ID is not the super-user, or one or more filedescriptors are open directories. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named directory does not exist. .It Bq Er EACCES Search permission is denied for any component of the path name. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EFAULT The .Fa dirname argument points outside the process's allocated address space. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr chdir 2 , .Xr jail 2 .Sh HISTORY The .Fn chroot system call appeared in .Bx 4.2 . It was marked as .Dq legacy in .St -susv2 , and was removed in subsequent standards. .Sh BUGS If the process is able to change its working directory to the target directory, but another access control check fails (such as a check for open directories, or a MAC check), it is possible that this system call may return an error, with the working directory of the process left changed. .Sh SECURITY CONSIDERATIONS The system have many hardcoded paths to files where it may load after the process starts. It is generally recommended to drop privileges immediately after a successful .Nm call, and restrict write access to a limited subtree of the .Nm root, for instance, setup the sandbox so that the sandboxed user will have no write access to any well-known system directories. Index: head/lib/libc/sys/copy_file_range.2 =================================================================== --- head/lib/libc/sys/copy_file_range.2 (revision 359464) +++ head/lib/libc/sys/copy_file_range.2 (revision 359465) @@ -1,205 +1,207 @@ .\" SPDX-License-Identifier: BSD-2-Clause .\" .\" Copyright (c) 2019 Rick Macklem .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd November 9, 2019 +.Dd March 30, 2020 .Dt COPY_FILE_RANGE 2 .Os .Sh NAME .Nm copy_file_range .Nd kernel copy of a byte range from one file to another or within one file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/types.h .In unistd.h .Ft ssize_t .Fo copy_file_range .Fa "int infd" .Fa "off_t *inoffp" .Fa "int outfd" .Fa "off_t *outoffp" .Fa "size_t len" .Fa "unsigned int flags" .Fc .Sh DESCRIPTION The .Fn copy_file_range system call copies up to .Fa len bytes from .Fa infd to .Fa outfd in the kernel. It may do this using a file system specific technique if .Fa infd and .Fa outfd are on the same file system. If .Fa infd and .Fa outfd refer to the same file, the byte ranges defined by the input file offset, output file offset and .Fa len cannot overlap. The .Fa infd argument must be opened for reading and the .Fa outfd argument must be opened for writing, but not .Dv O_APPEND . If .Fa inoffp or .Fa outoffp is .Dv NULL , the file offset for .Fa infd or .Fa outfd respectively will be used and updated by the number of bytes copied. If .Fa inoffp or .Fa outoffp is not .Dv NULL , the byte offset pointed to by .Fa inoffp or .Fa outoffp respectively will be used/updated and the file offset for .Fa infd or .Fa outfd respectively will not be affected. The .Fa flags argument must be 0. .Pp This system call attempts to maintain holes in the output file for the byte range being copied. However, this does not always work well. It is recommended that sparse files be copied in a loop using .Xr lseek 2 with .Dv SEEK_HOLE , .Dv SEEK_DATA arguments and this system call for the data ranges found. .Pp .Sh RETURN VALUES If it succeeds, the call returns the number of bytes copied, which can be fewer than .Fa len . Returning fewer bytes than .Fa len does not necessarily indicate that EOF was reached. However, a return of zero for a non-zero .Fa len argument indicates that the offset for .Fa infd is at or beyond EOF. .Fn copy_file_range should be used in a loop until copying of the desired byte range has been completed. If an error has occurred, a \-1 is returned and the error code is placed in the global variable .Va errno . .Sh ERRORS The .Fn copy_file_range system call will fail if: .Bl -tag -width Er .It Bq Er EBADF If .Fa infd is not open for reading or .Fa outfd is not open for writing, or opened for writing with .Dv O_APPEND , or if .Fa infd and .Fa outfd refer to the same file. .It Bq Er EFBIG If the copy exceeds the process's file size limit or the maximum file size for the file system .Fa outfd resides on. .It Bq Er EINTR A signal interrupted the system call before it could be completed. This may happen for files on some NFS mounts. When this happens, the values pointed to by .Fa inoffp and .Fa outoffp are reset to the initial values for the system call. .It Bq Er EINVAL .Fa infd and .Fa outfd refer to the same file and the byte ranges overlap or .Fa flags is not zero. .It Bq Er EIO An I/O error occurred while reading/writing the files. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from a file system. .It Bq Er EISDIR If either .Fa infd or .Fa outfd refers to a directory. .It Bq Er ENOSPC File system that stores .Fa outfd is full. .El .Sh SEE ALSO .Xr lseek 2 .Sh STANDARDS The .Fn copy_file_range system call is expected to be compatible with the Linux system call of the same name. .Sh HISTORY The .Fn copy_file_range function appeared in .Fx 13.0 . Index: head/lib/libc/sys/execve.2 =================================================================== --- head/lib/libc/sys/execve.2 (revision 359464) +++ head/lib/libc/sys/execve.2 (revision 359465) @@ -1,377 +1,379 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)execve.2 8.5 (Berkeley) 6/1/94 .\" $FreeBSD$ .\" -.Dd September 21, 2010 +.Dd March 30, 2020 .Dt EXECVE 2 .Os .Sh NAME .Nm execve , .Nm fexecve .Nd execute a file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn execve "const char *path" "char *const argv[]" "char *const envp[]" .Ft int .Fn fexecve "int fd" "char *const argv[]" "char *const envp[]" .Sh DESCRIPTION The .Fn execve system call transforms the calling process into a new process. The new process is constructed from an ordinary file, whose name is pointed to by .Fa path , called the .Em new process file . The .Fn fexecve system call is equivalent to .Fn execve except that the file to be executed is determined by the file descriptor .Fa fd instead of a .Fa path . This file is either an executable object file, or a file of data for an interpreter. An executable object file consists of an identifying header, followed by pages of data representing the initial program (text) and initialized data pages. Additional pages may be specified by the header to be initialized with zero data; see .Xr elf 5 and .Xr a.out 5 . .Pp An interpreter file begins with a line of the form: .Pp .Bd -ragged -offset indent -compact .Sy \&#! .Em interpreter .Bq Em arg .Ed .Pp When an interpreter file is .Sy execve Ap d , the system actually .Sy execve Ap s the specified .Em interpreter . If the optional .Em arg is specified, it becomes the first argument to the .Em interpreter , and the name of the originally .Sy execve Ap d file becomes the second argument; otherwise, the name of the originally .Sy execve Ap d file becomes the first argument. The original arguments are shifted over to become the subsequent arguments. The zeroth argument is set to the specified .Em interpreter . .Pp The argument .Fa argv is a pointer to a null-terminated array of character pointers to null-terminated character strings. These strings construct the argument list to be made available to the new process. At least one argument must be present in the array; by custom, the first element should be the name of the executed program (for example, the last component of .Fa path ) . .Pp The argument .Fa envp is also a pointer to a null-terminated array of character pointers to null-terminated strings. A pointer to this array is normally stored in the global variable .Va environ . These strings pass information to the new process that is not directly an argument to the command (see .Xr environ 7 ) . .Pp File descriptors open in the calling process image remain open in the new process image, except for those for which the close-on-exec flag is set (see .Xr close 2 and .Xr fcntl 2 ) . Descriptors that remain open are unaffected by .Fn execve . If any of the standard descriptors (0, 1, and/or 2) are closed at the time .Fn execve is called, and the process will gain privilege as a result of set-id semantics, those descriptors will be re-opened automatically. No programs, whether privileged or not, should assume that these descriptors will remain closed across a call to .Fn execve . .Pp Signals set to be ignored in the calling process are set to be ignored in the new process. Signals which are set to be caught in the calling process image are set to default action in the new process image. Blocked signals remain blocked regardless of changes to the signal action. The signal stack is reset to be undefined (see .Xr sigaction 2 for more information). .Pp If the set-user-ID mode bit of the new process image file is set (see .Xr chmod 2 ) , the effective user ID of the new process image is set to the owner ID of the new process image file. If the set-group-ID mode bit of the new process image file is set, the effective group ID of the new process image is set to the group ID of the new process image file. (The effective group ID is the first element of the group list.) The real user ID, real group ID and other group IDs of the new process image remain the same as the calling process image. After any set-user-ID and set-group-ID processing, the effective user ID is recorded as the saved set-user-ID, and the effective group ID is recorded as the saved set-group-ID. These values may be used in changing the effective IDs later (see .Xr setuid 2 ) . .Pp The set-ID bits are not honored if the respective file system has the .Cm nosuid option enabled or if the new process file is an interpreter file. Syscall tracing is disabled if effective IDs are changed. .Pp The new process also inherits the following attributes from the calling process: .Pp .Bl -column parent_process_ID -offset indent -compact .It process ID Ta see Xr getpid 2 .It parent process ID Ta see Xr getppid 2 .It process group ID Ta see Xr getpgrp 2 .It access groups Ta see Xr getgroups 2 .It working directory Ta see Xr chdir 2 .It root directory Ta see Xr chroot 2 .It control terminal Ta see Xr termios 4 .It resource usages Ta see Xr getrusage 2 .It interval timers Ta see Xr getitimer 2 .It resource limits Ta see Xr getrlimit 2 .It file mode mask Ta see Xr umask 2 .It signal mask Ta see Xr sigaction 2 , .Xr sigprocmask 2 .El .Pp When a program is executed as a result of an .Fn execve system call, it is entered as follows: .Bd -literal -offset indent main(argc, argv, envp) int argc; char **argv, **envp; .Ed .Pp where .Fa argc is the number of elements in .Fa argv (the ``arg count'') and .Fa argv points to the array of character pointers to the arguments themselves. .Pp The .Fn fexecve ignores the file offset of .Fa fd . Since execute permission is checked by .Fn fexecve , the file descriptor .Fa fd need not have been opened with the .Dv O_EXEC flag. However, if the file to be executed denies read permission for the process preparing to do the exec, the only way to provide the .Fa fd to .Fn fexecve is to use the .Dv O_EXEC flag when opening .Fa fd . Note that the file to be executed can not be open for writing. .Sh RETURN VALUES As the .Fn execve system call overlays the current process image with a new process image the successful call has no process to return to. If .Fn execve does return to the calling process an error has occurred; the return value will be -1 and the global variable .Va errno is set to indicate the error. .Sh ERRORS The .Fn execve system call will fail and return to the calling process if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOEXEC When invoking an interpreted script, the length of the first line, inclusive of the .Sy \&#! prefix and terminating newline, exceeds .Dv MAXSHELLCMDLEN characters. .It Bq Er ENOENT The new process file does not exist. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EACCES The new process file is not an ordinary file. .It Bq Er EACCES The new process file mode denies execute permission. .It Bq Er ENOEXEC The new process file has the appropriate access permission, but has an invalid magic number in its header. .It Bq Er ETXTBSY The new process file is a pure procedure (shared text) file that is currently open for writing by some process. .It Bq Er ENOMEM The new process requires more virtual memory than is allowed by the imposed maximum .Pq Xr getrlimit 2 . .It Bq Er E2BIG The number of bytes in the new process' argument list is larger than the system-imposed limit. This limit is specified by the .Xr sysctl 3 MIB variable .Dv KERN_ARGMAX . .It Bq Er EFAULT The new process file is not as long as indicated by the size values in its header. .It Bq Er EFAULT The .Fa path , .Fa argv , or .Fa envp arguments point to an illegal address. .It Bq Er EIO An I/O error occurred while reading from the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp In addition, the .Fn fexecve will fail and return to the calling process if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor open for executing. .El .Sh SEE ALSO .Xr ktrace 1 , .Xr _exit 2 , .Xr fork 2 , .Xr open 2 , .Xr execl 3 , .Xr exit 3 , .Xr sysctl 3 , .Xr a.out 5 , .Xr elf 5 , .Xr fdescfs 5 , .Xr environ 7 , .Xr mount 8 .Sh STANDARDS The .Fn execve system call conforms to .St -p1003.1-2001 , with the exception of reopening descriptors 0, 1, and/or 2 in certain circumstances. A future update of the Standard is expected to require this behavior, and it may become the default for non-privileged processes as well. .\" NB: update this caveat when TC1 is blessed. The support for executing interpreted programs is an extension. The .Fn fexecve system call conforms to The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn execve system call appeared in .At V7 . The .Fn fexecve system call appeared in .Fx 8.0 . .Sh CAVEATS If a program is .Em setuid to a non-super-user, but is executed when the real .Em uid is ``root'', then the program has some of the powers of a super-user as well. .Pp When executing an interpreted program through .Fn fexecve , kernel supplies .Pa /dev/fd/n as a second argument to the interpreter, where .Ar n is the file descriptor passed in the .Fa fd argument to .Fn fexecve . For this construction to work correctly, the .Xr fdescfs 5 filesystem shall be mounted on .Pa /dev/fd . Index: head/lib/libc/sys/fhlink.2 =================================================================== --- head/lib/libc/sys/fhlink.2 (revision 359464) +++ head/lib/libc/sys/fhlink.2 (revision 359465) @@ -1,268 +1,270 @@ .\" SPDX-License-Identifier: BSD-2-Clause .\" .\" Copyright (c) 2018 Gandi .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd November 29, 2018 +.Dd March 30, 2020 .Dt FHLINK 2 .Os .Sh NAME .Nm fhlink , .Nm fhlinkat .Nd make a hard file link .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn fhlink "fhandle_t *fhp" "const char *to" .Ft int .Fn fhlinkat "fhandle_t *fhp" "int tofd" "const char *to" .Fc .Sh DESCRIPTION The .Fn fhlink system call atomically creates the specified directory entry (hard link) .Fa to with the attributes of the underlying object pointed at by .Fa fhp . If the link is successful: the link count of the underlying object is incremented; .Fa fhp and .Fa to share equal access and rights to the underlying object. .Pp If .Fa fhp is removed, the file .Fa to is not deleted and the link count of the underlying object is decremented. .Pp The object pointed at by the .Fa fhp argument must exist for the hard link to succeed and both .Fa fhp and .Fa to must be in the same file system. The .Fa fhp argument may not be a directory. .Pp The .Fn fhlinkat system call is equivalent to .Fa fhlink except in the case where .Fa to is a relative paths. In this case a relative path .Fa to is interpreted relative to the directory associated with the file descriptor .Fa tofd instead of the current working directory. .Pp Values for .Fa flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_FOLLOW If .Fa fhp names a symbolic link, a new link for the target of the symbolic link is created. .It Dv AT_BENEATH Only allow to link to a file which is beneath of the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn fhlinkat is passed the special value .Dv AT_FDCWD in the .Fa tofd parameter, the current working directory is used for the .Fa to argument. If .Fa tofd has value .Dv AT_FDCWD , the behavior is identical to a call to .Fn link . Unless .Fa flag contains the .Dv AT_SYMLINK_FOLLOW flag, if .Fa fhp names a symbolic link, a new link is created for the symbolic link .Fa fhp and not its target. .Sh RETURN VALUES .Rv -std link .Sh ERRORS The .Fn fhlink system call will fail and no link will be created if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of .Fa to prefix is not a directory. .It Bq Er ENAMETOOLONG A component of .Fa to exceeded 255 characters, or entire length of .Fa to name exceeded 1023 characters. .It Bq Er ENOENT A component of .Fa to prefix does not exist. .It Bq Er EOPNOTSUPP The file system containing the file pointed at by .Fa fhp does not support links. .It Bq Er EMLINK The link count of the file pointed at by .Fa fhp would exceed 32767. .It Bq Er EACCES A component of .Fa to prefix denies search permission. .It Bq Er EACCES The requested link requires writing in a directory with a mode that denies write permission. .It Bq Er ELOOP Too many symbolic links were encountered in translating one of the pathnames. .It Bq Er ENOENT The file pointed at by .Fa fhp does not exist. .It Bq Er EEXIST The link named by .Fa to does exist. .It Bq Er EPERM The file pointed at by .Fa fhp is a directory. .It Bq Er EPERM The file pointed at by .Fa fhp has its immutable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EPERM The parent directory of the file named by .Fa to has its immutable flag set. .It Bq Er EXDEV The link named by .Fa to and the file pointed at by .Fa fhp are on different file systems. .It Bq Er ENOSPC The directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory. .It Bq Er EDQUOT The directory in which the entry for the new link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system to make the directory entry. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EROFS The requested link requires writing in a directory on a read-only file system. .It Bq Er EFAULT One of the pathnames specified is outside the process's allocated address space. .It Bq Er ESTALE The file handle .Fa fhp is no longer valid .El .Pp In addition to the errors returned by the .Fn fhlink , the .Fn fhlinkat system call may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fhp or .Fa to argument does not specify an absolute path and the .Fa tofd argument, is not .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa fhp or .Fa to argument is not an absolute path and .Fa tofd is not .Dv AT_FDCWD nor a file descriptor associated with a directory. .El .Sh SEE ALSO .Xr fhstat 2 , .Xr fhreadlink 2 , .Xr fhopen 2 , Index: head/lib/libc/sys/fhreadlink.2 =================================================================== --- head/lib/libc/sys/fhreadlink.2 (revision 359464) +++ head/lib/libc/sys/fhreadlink.2 (revision 359465) @@ -1,92 +1,94 @@ .\" SPDX-License-Identifier: BSD-2-Clause .\" .\" Copyright (c) 2018 Gandi .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd November 29, 2018 +.Dd March 30, 2020 .Dt FHREADLINK 2 .Os .Sh NAME .Nm fhreadlink .Nd read value of a symbolic link .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/mount.h .Ft int .Fn fhreadlink "fhandle_t *fhp" "char *buf" "size_t bufsize" .Fc .Sh DESCRIPTION The .Fn fhreadlink system call places the contents of the symbolic link .Fa fhp in the buffer .Fa buf , which has size .Fa bufsiz . The .Fn fhreadlink system call does not append a .Dv NUL character to .Fa buf . .Pp .Sh RETURN VALUES The call returns the count of characters placed in the buffer if it succeeds, or a \-1 if an error occurs, placing the error code in the global variable .Va errno . .Sh ERRORS The .Fn readlink system call will fail if: .Bl -tag -width Er .It Bq Er ENOENT The named file does not exist. .It Bq Er ELOOP Too many symbolic links were encountered in translating the file handle .Fa fhp . .It Bq Er EINVAL The named file is not a symbolic link. .It Bq Er EIO An I/O error occurred while reading from the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFAULT The .Fa buf argument extends outside the process's allocated address space. .It Bq Er ESTALE The file handle .Fa fhp is no longer valid .El .El .Sh SEE ALSO .Xr fhstat 2 , .Xr fhlink 2 , Index: head/lib/libc/sys/fsync.2 =================================================================== --- head/lib/libc/sys/fsync.2 (revision 359464) +++ head/lib/libc/sys/fsync.2 (revision 359465) @@ -1,132 +1,134 @@ .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. .\" Copyright (c) 2016 The FreeBSD Foundation, Inc. .\" All rights reserved. .\" .\" Parts of this documentation were written by .\" Konstantin Belousov under sponsorship .\" from the FreeBSD Foundation. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)fsync.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd February 6, 2018 +.Dd March 30, 2020 .Dt FSYNC 2 .Os .Sh NAME .Nm fdatasync , .Nm fsync .Nd "synchronise changes to a file" .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn fdatasync "int fd" .Ft int .Fn fsync "int fd" .Sh DESCRIPTION The .Fn fsync system call causes all modified data and attributes of the file referenced by the file descriptor .Fa fd to be moved to a permanent storage device. This normally results in all in-core modified copies of buffers for the associated file to be written to a disk. .Pp The .Fn fdatasync system call causes all modified data of .Fa fd to be moved to a permanent storage device. Unlike .Fn fsync , the system call does not guarantee that file attributes or metadata necessary to access the file are committed to the permanent storage. .Pp The .Fn fsync system call should be used by programs that require a file to be in a known state, for example, in building a simple transaction facility. If the file metadata has already been committed, using .Fn fdatasync can be more efficient than .Fn fsync . .Pp Both .Fn fdatasync and .Fn fsync calls are cancellation points. .Sh RETURN VALUES .Rv -std fsync .Sh ERRORS The .Fn fsync and .Fn fdatasync calls fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid descriptor. .It Bq Er EINVAL The .Fa fd argument refers to a socket, not to a file. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr fsync 1 , .Xr sync 2 , .Xr syncer 4 , .Xr sync 8 .Sh HISTORY The .Fn fsync system call appeared in .Bx 4.2 . The .Fn fdatasync system call appeared in .Fx 11.1 . .Sh BUGS The .Fn fdatasync system call currently does not guarantee that enqueued .Xr aio 4 requests for the file referenced by .Fa fd are completed before the syscall returns. Index: head/lib/libc/sys/getdirentries.2 =================================================================== --- head/lib/libc/sys/getdirentries.2 (revision 359464) +++ head/lib/libc/sys/getdirentries.2 (revision 359465) @@ -1,204 +1,206 @@ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getdirentries.2 8.2 (Berkeley) 5/3/95 .\" $FreeBSD$ .\" -.Dd Nov 14, 2018 +.Dd March 30, 2020 .Dt GETDIRENTRIES 2 .Os .Sh NAME .Nm getdirentries , .Nm getdents .Nd "get directory entries in a file system independent format" .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/types.h .In dirent.h .Ft ssize_t .Fn getdirentries "int fd" "char *buf" "size_t nbytes" "off_t *basep" .Ft ssize_t .Fn getdents "int fd" "char *buf" "size_t nbytes" .Sh DESCRIPTION The .Fn getdirentries and .Fn getdents system calls read directory entries from the directory referenced by the file descriptor .Fa fd into the buffer pointed to by .Fa buf , in a file system independent format. Up to .Fa nbytes of data will be transferred. The .Fa nbytes argument must be greater than or equal to the block size associated with the file, see .Xr stat 2 . Some file systems may not support these system calls with buffers smaller than this size. .Pp The data in the buffer is a series of .Vt dirent structures each containing the following entries: .Bd -literal -offset indent ino_t d_fileno; off_t d_off; uint16_t d_reclen; uint8_t d_type; uint16_t d_namlen; char d_name[MAXNAMLEN + 1]; /* see below */ .Ed .Pp The .Fa d_fileno entry is a number which is unique for each distinct file in the file system. Files that are linked by hard links (see .Xr link 2 ) have the same .Fa d_fileno . The .Fa d_off field returns a cookie which can be used with .Xr lseek 2 to position the directory descriptor to the next entry. The .Fa d_reclen entry is the length, in bytes, of the directory record. The .Fa d_type entry is the type of the file pointed to by the directory record. The file type values are defined in .Fa . The .Fa d_name entry contains a null terminated file name. The .Fa d_namlen entry specifies the length of the file name excluding the null byte. Thus the actual size of .Fa d_name may vary from 1 to .Dv MAXNAMLEN \&+ 1. .Pp Entries may be separated by extra space. The .Fa d_reclen entry may be used as an offset from the start of a .Fa dirent structure to the next structure, if any. .Pp The actual number of bytes transferred is returned. The current position pointer associated with .Fa fd is set to point to the next block of entries. The pointer may not advance by the number of bytes returned by .Fn getdirentries or .Fn getdents . A value of zero is returned when the end of the directory has been reached. .Pp If the .Fa basep pointer value is non-NULL , the .Fn getdirentries system call writes the position of the block read into the location pointed to by .Fa basep . Alternatively, the current position pointer may be set and retrieved by .Xr lseek 2 . The current position pointer should only be set to a value returned by .Xr lseek 2 , a value returned in the location pointed to by .Fa basep .Po Fn getdirentries only .Pc , a value returned in the .Fa d_off field, or zero. .Sh IMPLEMENTATION NOTES The .Fa d_off field is being used as a cookie to readdir for nfs servers. These cookies can be cached and allow to read directory entries at a specific offset on demand. .Sh RETURN VALUES If successful, the number of bytes actually transferred is returned. Otherwise, -1 is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS The .Fn getdirentries system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor open for reading. .It Bq Er EFAULT Either .Fa buf or non-NULL .Fa basep point outside the allocated address space. .It Bq Er EINVAL The file referenced by .Fa fd is not a directory, or .Fa nbytes is too small for returning a directory entry or block of entries, or the current position pointer is invalid. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr lseek 2 , .Xr open 2 .Sh HISTORY The .Fn getdirentries system call first appeared in .Bx 4.4 . The .Fn getdents system call first appeared in .Fx 3.0 . Index: head/lib/libc/sys/getfh.2 =================================================================== --- head/lib/libc/sys/getfh.2 (revision 359464) +++ head/lib/libc/sys/getfh.2 (revision 359465) @@ -1,237 +1,239 @@ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" Copyright (c) 2018 Gandi .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getfh.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd December 11, 2018 +.Dd March 30, 2020 .Dt GETFH 2 .Os .Sh NAME .Nm getfh , .Nm lgetfh , .Nm getfhat .Nd get file handle .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/mount.h .Ft int .Fn getfh "const char *path" "fhandle_t *fhp" .Ft int .Fn lgetfh "const char *path" "fhandle_t *fhp" .Ft int .Fn getfhat "int fd" "const char *path" "fhandle_t *fhp" "int flag" .Sh DESCRIPTION The .Fn getfh system call returns a file handle for the specified file or directory in the file handle pointed to by .Fa fhp . .Pp The .Fn lgetfh system call is like .Fn getfh except in the case where the named file is a symbolic link, in which case .Fn lgetfh returns information about the link, while .Fn getfh returns information about the file the link references. .Pp The .Fn getfhat system call is equivalent to .Fn getfh and .Fn lgetfh except when the .Fa path specifies a relative path, or the .Dv AT_BENEATH flag is provided. For .Fn getfhat and relative .Fa path , the status is retrieved from a file relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. For .Dv AT_BENEATH and absolute .Fa path , the status is retrieved from a file specified by the .Fa path , but additional permission checks are performed, see below. .Pp The values for the .Fa flag are constructed by a bitwise-inclusive OR of flags from this list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_NOFOLLOW If .Fa path names a symbolic link, the status of the symbolic link is returned. .It Dv AT_BENEATH Only stat files and directories below the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn getfhat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn getfth or .Fn lgetfh respectively, depending on whether or not the .Dv AT_SYMLINK_NOFOLLOW bit is set in .Fa flag . .Pp When .Fn getfhat is called with an absolute .Fa path without the .Dv AT_BENEATH flag, it ignores the .Fa fd argument. When .Dv AT_BENEATH is specified with an absolute .Fa path , a directory passed by the .Fa fd argument is used as the topping point for the resolution. These system calls are restricted to the superuser. .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn getfh and .Fn lgetfh system calls fail if one or more of the following are true: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix of .Fa path is not a directory. .It Bq Er ENAMETOOLONG The length of a component of .Fa path exceeds 255 characters, or the length of .Fa path exceeds 1023 characters. .It Bq Er ENOENT The file referred to by .Fa path does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix of .Fa path . .It Bq Er ELOOP Too many symbolic links were encountered in translating .Fa path . .It Bq Er EFAULT The .Fa fhp argument points to an invalid address. .It Bq Er EFAULT The .Fa path argument points to an invalid address. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er ESTALE The file handle .Fa fhp is no longer valid. .El .Pp In addition to the errors returned by .Fn getfh , and .Fn lgetfh , the .Fn getfhat system call may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument, is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .Sh SEE ALSO .Xr fhopen 2 , .Xr open 2 , .Xr stat 2 .Sh HISTORY The .Fn getfh system call first appeared in .Bx 4.4 . Index: head/lib/libc/sys/getfsstat.2 =================================================================== --- head/lib/libc/sys/getfsstat.2 (revision 359464) +++ head/lib/libc/sys/getfsstat.2 (revision 359465) @@ -1,130 +1,132 @@ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getfsstat.2 8.3 (Berkeley) 5/25/95 .\" $FreeBSD$ .\" -.Dd December 27, 2016 +.Dd March 30, 2020 .Dt GETFSSTAT 2 .Os .Sh NAME .Nm getfsstat .Nd get list of all mounted file systems .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/ucred.h .In sys/mount.h .Ft int .Fn getfsstat "struct statfs *buf" "long bufsize" "int mode" .Sh DESCRIPTION The .Fn getfsstat system call returns information about all mounted file systems. The .Fa buf argument is a pointer to .Vt statfs structures, as described in .Xr statfs 2 . .Pp Fields that are undefined for a particular file system are set to -1. The buffer is filled with an array of .Fa statfs structures, one for each mounted file system up to the byte count specified by .Fa bufsize . Note, the .Fa bufsize argument is the number of bytes that .Fa buf can hold, not the count of statfs structures it will hold. .Pp If .Fa buf is given as NULL, .Fn getfsstat returns just the number of mounted file systems. .Pp Normally .Fa mode should be specified as .Dv MNT_WAIT . If .Fa mode is set to .Dv MNT_NOWAIT , .Fn getfsstat will return the information it has available without requesting an update from each file system. Thus, some of the information will be out of date, but .Fn getfsstat will not block waiting for information from a file system that is unable to respond. It will also skip any file system that is in the process of being unmounted, even if the unmount would eventually fail. .Sh RETURN VALUES Upon successful completion, the number of .Fa statfs structures is returned. Otherwise, -1 is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS The .Fn getfsstat system call fails if one or more of the following are true: .Bl -tag -width Er .It Bq Er EFAULT The .Fa buf argument points to an invalid address. .It Bq Er EINVAL .Fa mode is set to a value other than .Dv MNT_WAIT or .Dv MNT_NOWAIT . .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr statfs 2 , .Xr fstab 5 , .Xr mount 8 .Sh HISTORY The .Fn getfsstat system call first appeared in .Bx 4.4 . Index: head/lib/libc/sys/ktrace.2 =================================================================== --- head/lib/libc/sys/ktrace.2 (revision 359464) +++ head/lib/libc/sys/ktrace.2 (revision 359465) @@ -1,204 +1,206 @@ .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd March 31, 2016 +.Dd March 30, 2020 .Dt KTRACE 2 .Os .Sh NAME .Nm ktrace .Nd process tracing .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/time.h .In sys/uio.h .In sys/ktrace.h .Ft int .Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid" .Sh DESCRIPTION The .Fn ktrace system call enables or disables tracing of one or more processes. Users may only trace their own processes. Only the super-user can trace setuid or setgid programs. .Pp The .Fa tracefile argument gives the pathname of the file to be used for tracing. The file must exist and be a regular file writable by the calling process. All trace records are always appended to the file, so the file must be truncated to zero length to discard previous trace data. If tracing points are being disabled (see KTROP_CLEAR below), .Fa tracefile may be NULL. .Pp The .Fa ops argument specifies the requested ktrace operation. The defined operations are: .Bl -column KTRFLAG_DESCENDXXX -offset indent .It KTROP_SET Ta "Enable trace points specified in" .Fa trpoints . .It KTROP_CLEAR Ta "Disable trace points specified in" .Fa trpoints . .It KTROP_CLEARFILE Ta "Stop all tracing." .It KTRFLAG_DESCEND Ta "The tracing change should apply to the" specified process and all its current children. .El .Pp The .Fa trpoints argument specifies the trace points of interest. The defined trace points are: .Bl -column KTRFAC_PROCCTORXXX -offset indent .It KTRFAC_SYSCALL Ta "Trace system calls." .It KTRFAC_SYSRET Ta "Trace return values from system calls." .It KTRFAC_NAMEI Ta "Trace name lookup operations." .It KTRFAC_GENIO Ta "Trace all I/O (note that this option can" generate much output). .It KTRFAC_PSIG Ta "Trace posted signals." .It KTRFAC_CSW Ta "Trace context switch points." .It KTRFAC_USER Ta "Trace application-specific events." .It KTRFAC_STRUCT Ta "Trace certain data structures." .It KTRFAC_SYSCTL Ta "Trace sysctls." .It KTRFAC_PROCCTOR Ta "Trace process construction." .It KTRFAC_PROCDTOR Ta "Trace process destruction." .It KTRFAC_CAPFAIL Ta "Trace capability failures." .It KTRFAC_FAULT Ta "Trace page faults." .It KTRFAC_FAULTEND Ta "Trace the end of page faults." .It KTRFAC_INHERIT Ta "Inherit tracing to future children." .El .Pp Each tracing event outputs a record composed of a generic header followed by a trace point specific structure. The generic header is: .Bd -literal struct ktr_header { int ktr_len; /* length of buf */ short ktr_type; /* trace record type */ pid_t ktr_pid; /* process id */ char ktr_comm[MAXCOMLEN+1]; /* command name */ struct timeval ktr_time; /* timestamp */ intptr_t ktr_tid; /* was ktr_buffer */ }; .Ed .Pp The .Va ktr_len field specifies the length of the .Va ktr_type data that follows this header. The .Va ktr_pid and .Va ktr_comm fields specify the process and command generating the record. The .Va ktr_time field gives the time (with microsecond resolution) that the record was generated. The .Va ktr_tid field holds a thread id. .Pp The generic header is followed by .Va ktr_len bytes of a .Va ktr_type record. The type specific records are defined in the .In sys/ktrace.h include file. .Sh SYSCTL TUNABLES The following .Xr sysctl 8 tunables influence the behaviour of .Fn ktrace : .Bl -tag -width indent .It Va kern.ktrace.geniosize bounds the amount of data a traced I/O request will log to the trace file. .It Va kern.ktrace.request_pool bounds the number of trace events being logged at a time. .El .Pp Sysctl tunables that control process debuggability (as determined by .Xr p_candebug 9 ) also affect the operation of .Fn ktrace . .Sh RETURN VALUES .Rv -std ktrace .Sh ERRORS The .Fn ktrace system call will fail if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named tracefile does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er ENOSYS The kernel was not compiled with .Nm support. .El .Pp A thread may be unable to log one or more tracing events due to a temporary shortage of resources. This condition is remembered by the kernel, and the next tracing request that succeeds will have the flag .Li KTR_DROP set in its .Va ktr_type field. .Sh SEE ALSO .Xr kdump 1 , .Xr ktrace 1 , .Xr utrace 2 , .Xr sysctl 8 , .Xr p_candebug 9 .Sh HISTORY The .Fn ktrace system call first appeared in .Bx 4.4 . Index: head/lib/libc/sys/link.2 =================================================================== --- head/lib/libc/sys/link.2 (revision 359464) +++ head/lib/libc/sys/link.2 (revision 359465) @@ -1,315 +1,317 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)link.2 8.3 (Berkeley) 1/12/94 .\" $FreeBSD$ .\" -.Dd November 11, 2018 +.Dd March 30, 2020 .Dt LINK 2 .Os .Sh NAME .Nm link , .Nm linkat .Nd make a hard file link .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn link "const char *name1" "const char *name2" .Ft int .Fo linkat .Fa "int fd1" "const char *name1" "int fd2" "const char *name2" "int flag" .Fc .Sh DESCRIPTION The .Fn link system call atomically creates the specified directory entry (hard link) .Fa name2 with the attributes of the underlying object pointed at by .Fa name1 . If the link is successful: the link count of the underlying object is incremented; .Fa name1 and .Fa name2 share equal access and rights to the underlying object. .Pp If .Fa name1 is removed, the file .Fa name2 is not deleted and the link count of the underlying object is decremented. .Pp The object pointed at by the .Fa name1 argument must exist for the hard link to succeed and both .Fa name1 and .Fa name2 must be in the same file system. The .Fa name1 argument may not be a directory. .Pp The .Fn linkat system call is equivalent to .Fa link except in the case where either .Fa name1 or .Fa name2 or both are relative paths. In this case a relative path .Fa name1 is interpreted relative to the directory associated with the file descriptor .Fa fd1 instead of the current working directory and similarly for .Fa name2 and the file descriptor .Fa fd2 . .Pp Values for .Fa flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_FOLLOW If .Fa name1 names a symbolic link, a new link for the target of the symbolic link is created. .It Dv AT_BENEATH Only allow to link to a file which is beneath of the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn linkat is passed the special value .Dv AT_FDCWD in the .Fa fd1 or .Fa fd2 parameter, the current working directory is used for the respective .Fa name argument. If both .Fa fd1 and .Fa fd2 have value .Dv AT_FDCWD , the behavior is identical to a call to .Fn link . Unless .Fa flag contains the .Dv AT_SYMLINK_FOLLOW flag, if .Fa name1 names a symbolic link, a new link is created for the symbolic link .Fa name1 and not its target. .Sh RETURN VALUES .Rv -std link .Sh ERRORS The .Fn link system call will fail and no link will be created if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of either path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of either pathname exceeded 255 characters, or entire length of either path name exceeded 1023 characters. .It Bq Er ENOENT A component of either path prefix does not exist. .It Bq Er EOPNOTSUPP The file system containing the file named by .Fa name1 does not support links. .It Bq Er EMLINK The link count of the file named by .Fa name1 would exceed 32767. .It Bq Er EACCES A component of either path prefix denies search permission. .It Bq Er EACCES The requested link requires writing in a directory with a mode that denies write permission. .It Bq Er ELOOP Too many symbolic links were encountered in translating one of the pathnames. .It Bq Er ENOENT The file named by .Fa name1 does not exist. .It Bq Er EEXIST The link named by .Fa name2 does exist. .It Bq Er EPERM The file named by .Fa name1 is a directory. .It Bq Er EPERM The file named by .Fa name1 has its immutable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EPERM The parent directory of the file named by .Fa name2 has its immutable flag set. .It Bq Er EXDEV The link named by .Fa name2 and the file named by .Fa name1 are on different file systems. .It Bq Er ENOSPC The directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory. .It Bq Er EDQUOT The directory in which the entry for the new link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system to make the directory entry. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EROFS The requested link requires writing in a directory on a read-only file system. .It Bq Er EFAULT One of the pathnames specified is outside the process's allocated address space. .El .Pp In addition to the errors returned by the .Fn link , the .Fn linkat system call may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa name1 or .Fa name2 argument does not specify an absolute path and the .Fa fd1 or .Fa fd2 argument, respectively, is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa name1 or .Fa name2 argument is not an absolute path and .Fa fd1 or .Fa fd2 , respectively, is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTCAPABLE .Fa name1 is not strictly relative to the starting directory. For example, .Fa name1 is absolute or includes a ".." component that escapes the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fa linkat and the absolute path .Fa name1 does not have its tail fully contained under the topping directory, or the relative path .Fa name1 escapes it. .El .Sh SEE ALSO .Xr chflags 2 , .Xr readlink 2 , .Xr symlink 2 , .Xr unlink 2 .Sh STANDARDS The .Fn link system call is expected to conform to .St -p1003.1-90 . The .Fn linkat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn link function appeared in .At v1 . The .Fn linkat system call appeared in .Fx 8.0 . .Pp The .Fn link system call traditionally allows the super-user to link directories which corrupts the file system coherency. This implementation no longer permits it. Index: head/lib/libc/sys/mkdir.2 =================================================================== --- head/lib/libc/sys/mkdir.2 (revision 359464) +++ head/lib/libc/sys/mkdir.2 (revision 359465) @@ -1,180 +1,182 @@ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)mkdir.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd June 26, 2008 +.Dd March 30, 2020 .Dt MKDIR 2 .Os .Sh NAME .Nm mkdir , .Nm mkdirat .Nd make a directory file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/stat.h .Ft int .Fn mkdir "const char *path" "mode_t mode" .Ft int .Fn mkdirat "int fd" "const char *path" "mode_t mode" .Sh DESCRIPTION The directory .Fa path is created with the access permissions specified by .Fa mode and restricted by the .Xr umask 2 of the calling process. .Pp The directory's owner ID is set to the process's effective user ID. The directory's group ID is set to that of the parent directory in which it is created. .Pp The .Fn mkdirat system call is equivalent to .Fn mkdir except in the case where .Fa path specifies a relative path. In this case the newly created directory is created relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. If .Fn mkdirat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn mkdir . .Sh RETURN VALUES .Rv -std mkdir .Sh ERRORS The .Fn mkdir system call will fail and no directory will be created if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT A component of the path prefix does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix, or write permission is denied on the parent directory of the directory to be created. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The parent directory of the directory to be created has its immutable flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EROFS The named directory would reside on a read-only file system. .It Bq Er EMLINK The new directory cannot be created because the parent directory contains too many subdirectories. .It Bq Er EEXIST The named file exists. .It Bq Er ENOSPC The new directory cannot be created because there is no space left on the file system that will contain the directory. .It Bq Er ENOSPC There are no free inodes on the file system on which the directory is being created. .It Bq Er EDQUOT The new directory cannot be created because the user's quota of disk blocks on the file system that will contain the directory has been exhausted. .It Bq Er EDQUOT The user's quota of inodes on the file system on which the directory is being created has been exhausted. .It Bq Er EIO An I/O error occurred while making the directory entry or allocating the inode. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .El .Pp In addition to the errors returned by the .Fn mkdir , the .Fn mkdirat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .El .Sh SEE ALSO .Xr chflags 2 , .Xr chmod 2 , .Xr stat 2 , .Xr umask 2 .Sh STANDARDS The .Fn mkdir system call is expected to conform to .St -p1003.1-90 . The .Fn mkdirat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn mkdirat system call appeared in .Fx 8.0 . The .Fn mkdir system call appeared in .At v1 . Index: head/lib/libc/sys/mkfifo.2 =================================================================== --- head/lib/libc/sys/mkfifo.2 (revision 359464) +++ head/lib/libc/sys/mkfifo.2 (revision 359465) @@ -1,185 +1,187 @@ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)mkfifo.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 10, 2008 +.Dd March 30, 2020 .Dt MKFIFO 2 .Os .Sh NAME .Nm mkfifo , .Nm mkfifoat .Nd make a fifo file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/types.h .In sys/stat.h .Ft int .Fn mkfifo "const char *path" "mode_t mode" .Ft int .Fn mkfifoat "int fd" "const char *path" "mode_t mode" .Sh DESCRIPTION The .Fn mkfifo system call creates a new fifo file with name .Fa path . The access permissions are specified by .Fa mode and restricted by the .Xr umask 2 of the calling process. .Pp The fifo's owner ID is set to the process's effective user ID. The fifo's group ID is set to that of the parent directory in which it is created. .Pp The .Fn mkfifoat system call is equivalent to .Fn mkfifo except in the case where .Fa path specifies a relative path. In this case the newly created FIFO is created relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. If .Fn mkfifoat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn mkfifo . .Sh RETURN VALUES .Rv -std mkfifo .Sh ERRORS The .Fn mkfifo system call will fail and no fifo will be created if: .Bl -tag -width Er .It Bq Er ENOTSUP The kernel has not been configured to support fifo's. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT A component of the path prefix does not exist. .It Bq Er EACCES A component of the path prefix denies search permission, or write permission is denied on the parent directory of the fifo to be created. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EROFS The named file would reside on a read-only file system. .It Bq Er EEXIST The named file exists. .It Bq Er EPERM The parent directory of the named file has its immutable flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er ENOSPC The directory in which the entry for the new fifo is being placed cannot be extended because there is no space left on the file system containing the directory. .It Bq Er ENOSPC There are no free inodes on the file system on which the fifo is being created. .It Bq Er EDQUOT The directory in which the entry for the new fifo is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .It Bq Er EDQUOT The user's quota of inodes on the file system on which the fifo is being created has been exhausted. .It Bq Er EIO An .Tn I/O error occurred while making the directory entry or allocating the inode. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .El .Pp In addition to the errors returned by the .Fn mkfifo , the .Fn mkfifoat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .El .Sh SEE ALSO .Xr chflags 2 , .Xr chmod 2 , .Xr mknod 2 , .Xr stat 2 , .Xr umask 2 .Sh STANDARDS The .Fn mkfifo system call is expected to conform to .St -p1003.1-90 . The .Fn mkfifoat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn mkfifoat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/mknod.2 =================================================================== --- head/lib/libc/sys/mknod.2 (revision 359464) +++ head/lib/libc/sys/mknod.2 (revision 359465) @@ -1,182 +1,184 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)mknod.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd December 1, 2017 +.Dd March 30, 2020 .Dt MKNOD 2 .Os .Sh NAME .Nm mknod , .Nm mknodat .Nd make a special file node .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/stat.h .Ft int .Fn mknod "const char *path" "mode_t mode" "dev_t dev" .Ft int .Fn mknodat "int fd" "const char *path" "mode_t mode" "dev_t dev" .Sh DESCRIPTION The file system node .Fa path is created with the file type and access permissions specified in .Fa mode . The access permissions are modified by the process's umask value. .Pp If .Fa mode indicates a block or character special file, .Fa dev is a configuration dependent specification denoting a particular device on the system. Otherwise, .Fa dev is ignored. .Pp The .Fn mknod system call requires super-user privileges. .Pp The .Fn mknodat system call is equivalent to .Fn mknod except in the case where .Fa path specifies a relative path. In this case the newly created device node is created relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. If .Fn mknodat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn mknod . .Sh RETURN VALUES .Rv -std mknod .Sh ERRORS The .Fn mknod system call will fail and the file will be not created if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT A component of the path prefix does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The process's effective user ID is not super-user. .It Bq Er EIO An I/O error occurred while making the directory entry or allocating the inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er ENOSPC The directory in which the entry for the new node is being placed cannot be extended because there is no space left on the file system containing the directory. .It Bq Er ENOSPC There are no free inodes on the file system on which the node is being created. .It Bq Er EDQUOT The directory in which the entry for the new node is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .It Bq Er EDQUOT The user's quota of inodes on the file system on which the node is being created has been exhausted. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er EEXIST The named file exists. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EINVAL Creating anything else than a block or character special file (or a .Em whiteout ) is not supported. .El .Pp In addition to the errors returned by the .Fn mknod , the .Fn mknodat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .El .Sh SEE ALSO .Xr chmod 2 , .Xr mkfifo 2 , .Xr stat 2 , .Xr umask 2 .Sh STANDARDS The .Fn mknodat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn mknod function appeared in .At v4 . The .Fn mknodat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/mount.2 =================================================================== --- head/lib/libc/sys/mount.2 (revision 359464) +++ head/lib/libc/sys/mount.2 (revision 359465) @@ -1,396 +1,403 @@ .\" Copyright (c) 1980, 1989, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)mount.2 8.3 (Berkeley) 5/24/95 .\" $FreeBSD$ .\" -.Dd August 28, 2019 +.Dd March 30, 2020 .Dt MOUNT 2 .Os .Sh NAME .Nm mount , .Nm nmount , .Nm unmount .Nd mount or dismount a file system .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/mount.h .Ft int .Fn mount "const char *type" "const char *dir" "int flags" "void *data" .Ft int .Fn unmount "const char *dir" "int flags" .In sys/uio.h .Ft int .Fn nmount "struct iovec *iov" "u_int niov" "int flags" .Sh DESCRIPTION The .Fn mount system call grafts a file system object onto the system file tree at the point .Fa dir . The argument .Fa data describes the file system object to be mounted. The argument .Fa type tells the kernel how to interpret .Fa data (See .Fa type below). The contents of the file system become available through the new mount point .Fa dir . Any files in .Fa dir at the time of a successful mount are swept under the carpet so to speak, and are unavailable until the file system is unmounted. .Pp The .Fn nmount system call behaves similarly to .Fn mount , except that the mount options (file system type name, device to mount, mount-point name, etc.) are passed as an array of name-value pairs in the array .Fa iov , containing .Fa niov elements. The following options are required by all file systems: .Bl -column fstype -offset indent .It .Li fstype Ta file system type name (e.g., Dq Li procfs ) .It .Li fspath Ta mount point pathname (e.g., Dq Li /proc ) .El .Pp Depending on the file system type, other options may be recognized or required; for example, most disk-based file systems require a .Dq Li from option containing the pathname of a special device in addition to the options listed above. .Pp By default only the super-user may call the .Fn mount system call. This restriction can be removed by setting the .Va vfs.usermount .Xr sysctl 8 variable to a non-zero value; see the BUGS section for more information. .Pp The following .Fa flags may be specified to suppress default semantics which affect file system access. .Bl -tag -width MNT_SYNCHRONOUS .It Dv MNT_RDONLY The file system should be treated as read-only; even the super-user may not write on it. Specifying MNT_UPDATE without this option will upgrade a read-only file system to read/write. .It Dv MNT_NOEXEC Do not allow files to be executed from the file system. .It Dv MNT_NOSUID Do not honor setuid or setgid bits on files when executing them. This flag is set automatically when the caller is not the super-user. .It Dv MNT_NOATIME Disable update of file access times. .It Dv MNT_SNAPSHOT Create a snapshot of the file system. This is currently only supported on UFS2 file systems, see .Xr mksnap_ffs 8 for more information. .It Dv MNT_SUIDDIR Directories with the SUID bit set chown new files to their own owner. This flag requires the SUIDDIR option to have been compiled into the kernel to have any effect. See the .Xr mount 8 and .Xr chmod 2 pages for more information. .It Dv MNT_SYNCHRONOUS All I/O to the file system should be done synchronously. .It Dv MNT_ASYNC All I/O to the file system should be done asynchronously. .It Dv MNT_FORCE Force a read-write mount even if the file system appears to be unclean. Dangerous. Together with .Dv MNT_UPDATE and .Dv MNT_RDONLY , specify that the file system is to be forcibly downgraded to a read-only mount even if some files are open for writing. .It Dv MNT_NOCLUSTERR Disable read clustering. .It Dv MNT_NOCLUSTERW Disable write clustering. .It Dv MNT_NOCOVER Do not mount over the root of another mount point. .It Dv MNT_EMPTYDIR Require an empty directory for the mount point directory. .El .Pp The flag .Dv MNT_UPDATE indicates that the mount command is being applied to an already mounted file system. This allows the mount flags to be changed without requiring that the file system be unmounted and remounted. Some file systems may not allow all flags to be changed. For example, many file systems will not allow a change from read-write to read-only. .Pp The flag .Dv MNT_RELOAD causes the vfs subsystem to update its data structures pertaining to the specified already mounted file system. .Pp The .Fa type argument names the file system. The types of file systems known to the system can be obtained with .Xr lsvfs 1 . .Pp The .Fa data argument is a pointer to a structure that contains the type specific arguments to mount. The format for these argument structures is described in the manual page for each file system. By convention file system manual pages are named by prefixing ``mount_'' to the name of the file system as returned by .Xr lsvfs 1 . Thus the .Tn NFS file system is described by the .Xr mount_nfs 8 manual page. It should be noted that a manual page for default file systems, known as UFS and UFS2, does not exist. .Pp The .Fn unmount system call disassociates the file system from the specified mount point .Fa dir . .Pp The .Fa flags argument may include .Dv MNT_FORCE to specify that the file system should be forcibly unmounted even if files are still active. Active special devices continue to work, but any further accesses to any other active files result in errors even if the file system is later remounted. .Pp If the .Dv MNT_BYFSID flag is specified, .Fa dir should instead be a file system ID encoded as .Dq Li FSID : Ns Ar val0 : Ns Ar val1 , where .Ar val0 and .Ar val1 are the contents of the .Vt fsid_t .Va val[] array in decimal. The file system that has the specified file system ID will be unmounted. .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn mount and .Fn nmount system calls will fail when one of the following occurs: .Bl -tag -width Er .It Bq Er EPERM The caller is neither the super-user nor the owner of .Fa dir . .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or the entire length of a path name exceeded 1023 characters. .It Bq Er ELOOP Too many symbolic links were encountered in translating a pathname. .It Bq Er ENOENT A component of .Fa dir does not exist. .It Bq Er ENOTDIR A component of .Fa name is not a directory, or a path prefix of .Fa special is not a directory. .It Bq Er EBUSY Another process currently holds a reference to .Fa dir . .It Bq Er EBUSY The .Dv MNT_NOCOVER option was given, and the requested mount point is already the root of another mount point. .It Bq Er EFAULT The .Fa dir argument points outside the process's allocated address space. +.It Bq Er EIO +An I/O error occurred while reading data from +.Fa special . +.It Bq Er EINTEGRITY +The backing store for +.Fa special +detected corrupted data while reading. .El .Pp The following errors can occur for a .Em ufs file system mount: .Bl -tag -width Er .It Bq Er ENODEV A component of ufs_args .Fa fspec does not exist. .It Bq Er ENOTBLK The .Fa fspec argument is not a block device. .It Bq Er ENOTEMPTY The .Dv MNT_EMPTYDIR option was specified, and the requested mount point is not an empty directory. .It Bq Er ENXIO The major device number of .Fa fspec is out of range (this indicates no device driver exists for the associated hardware). .It Bq Er EBUSY .Fa fspec is already mounted. .It Bq Er EMFILE No space remains in the mount table. .It Bq Er EINVAL The super block for the file system had a bad magic number or an out of range block size. .It Bq Er EINTEGRITY The super block for the file system had a bad check hash. The check hash can usually be corrected by running .Xr fsck 8 . .It Bq Er ENOMEM Not enough memory was available to read the cylinder group information for the file system. .It Bq Er EIO An I/O error occurred while reading the super block or cylinder group information. .It Bq Er EFAULT The .Fa fspec argument points outside the process's allocated address space. .El .Pp The following errors can occur for a .Em nfs file system mount: .Bl -tag -width Er .It Bq Er ETIMEDOUT .Em Nfs timed out trying to contact the server. .It Bq Er EFAULT Some part of the information described by nfs_args points outside the process's allocated address space. .El .Pp The .Fn unmount system call may fail with one of the following errors: .Bl -tag -width Er .It Bq Er EPERM The caller is neither the super-user nor the user who issued the corresponding .Fn mount call. .It Bq Er ENAMETOOLONG The length of the path name exceeded 1023 characters. .It Bq Er EINVAL The requested directory is not in the mount table. .It Bq Er ENOENT The file system ID specified using .Dv MNT_BYFSID was not found in the mount table. .It Bq Er EINVAL The file system ID specified using .Dv MNT_BYFSID could not be decoded. .It Bq Er EINVAL The specified file system is the root file system. .It Bq Er EBUSY A process is holding a reference to a file located on the file system. .It Bq Er EIO An I/O error occurred while writing cached file system information. .It Bq Er EFAULT The .Fa dir argument points outside the process's allocated address space. .El .Sh SEE ALSO .Xr lsvfs 1 , .Xr mksnap_ffs 8 , .Xr mount 8 , .Xr umount 8 .Sh HISTORY The .Fn mount and .Fn unmount functions appeared in .At v1 . The .Fn nmount system call first appeared in .Fx 5.0 . .Sh BUGS Some of the error codes need translation to more obvious messages. .Pp Allowing untrusted users to mount arbitrary media, e.g. by enabling .Va vfs.usermount , should not be considered safe. Most file systems in .Fx were not built to safeguard against malicious devices. Index: head/lib/libc/sys/open.2 =================================================================== --- head/lib/libc/sys/open.2 (revision 359464) +++ head/lib/libc/sys/open.2 (revision 359465) @@ -1,639 +1,641 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd January 31, 2020 +.Dd March 30, 2020 .Dt OPEN 2 .Os .Sh NAME .Nm open , openat .Nd open or create a file for reading, writing or executing .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In fcntl.h .Ft int .Fn open "const char *path" "int flags" "..." .Ft int .Fn openat "int fd" "const char *path" "int flags" "..." .Sh DESCRIPTION The file name specified by .Fa path is opened for either execution or reading and/or writing as specified by the argument .Fa flags and the file descriptor returned to the calling process. The .Fa flags argument may indicate the file is to be created if it does not exist (by specifying the .Dv O_CREAT flag). In this case .Fn open and .Fn openat require an additional argument .Fa "mode_t mode" , and the file is created with mode .Fa mode as described in .Xr chmod 2 and modified by the process' umask value (see .Xr umask 2 ) . .Pp The .Fn openat function is equivalent to the .Fn open function except in the case where the .Fa path specifies a relative path, or the .Dv O_BENEATH flag is provided. For .Fn openat and relative .Fa path , the file to be opened is determined relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. The .Fa flag parameter and the optional fourth parameter correspond exactly to the parameters of .Fn open . If .Fn openat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn open . .Pp When .Fn openat is called with an absolute .Fa path without the .Dv O_BENEATH flag, it ignores the .Fa fd argument. When .Dv O_BENEATH is specified with an absolute .Fa path , a directory passed by the .Fa fd argument is used as the topping point for the resolution. See the definition of the .Dv O_BENEATH flag below. .Pp In .Xr capsicum 4 capability mode, .Fn open is not permitted. The .Fa path argument to .Fn openat must be strictly relative to a file descriptor .Fa fd , as defined in .Pa sys/kern/vfs_lookup.c . .Fa path must not be an absolute path and must not contain ".." components which cause the path resolution to escape the directory hierarchy starting at .Fa fd . Additionally, no symbolic link in .Fa path may target absolute path or contain escaping ".." components. .Fa fd must not be .Dv AT_FDCWD . .Pp If the .Dv vfs.lookup_cap_dotdot .Xr sysctl 3 MIB is set to zero, ".." components in the paths, used in capability mode, or with the .Dv O_BENEATH flag, are completely disabled. If the .Dv vfs.lookup_cap_dotdot_nonlocal MIB is set to zero, ".." is not allowed if found on non-local filesystem. .Pp The flags specified are formed by .Em or Ns 'ing the following values .Pp .Bd -literal -offset indent -compact O_RDONLY open for reading only O_WRONLY open for writing only O_RDWR open for reading and writing O_EXEC open for execute only O_SEARCH open for search only, an alias for O_EXEC O_NONBLOCK do not block on open O_APPEND append on each write O_CREAT create file if it does not exist O_TRUNC truncate size to 0 O_EXCL error if create and file exists O_SHLOCK atomically obtain a shared lock O_EXLOCK atomically obtain an exclusive lock O_DIRECT eliminate or reduce cache effects O_FSYNC synchronous writes O_SYNC synchronous writes O_NOFOLLOW do not follow symlinks O_NOCTTY ignored O_TTY_INIT ignored O_DIRECTORY error if file is not a directory O_CLOEXEC set FD_CLOEXEC upon open O_VERIFY verify the contents of the file O_BENEATH require path to be strictly relative to topping directory .Ed .Pp Opening a file with .Dv O_APPEND set causes each write on the file to be appended to the end. If .Dv O_TRUNC is specified and the file exists, the file is truncated to zero length. If .Dv O_EXCL is set with .Dv O_CREAT and the file already exists, .Fn open returns an error. This may be used to implement a simple exclusive access locking mechanism. If .Dv O_EXCL is set and the last component of the pathname is a symbolic link, .Fn open will fail even if the symbolic link points to a non-existent name. If the .Dv O_NONBLOCK flag is specified and the .Fn open system call would result in the process being blocked for some reason (e.g., waiting for carrier on a dialup line), .Fn open returns immediately. The descriptor remains in non-blocking mode for subsequent operations. .Pp If .Dv O_FSYNC is used in the mask, all writes will immediately and synchronously be written to disk. .Pp .Dv O_SYNC is a synonym for .Dv O_FSYNC required by .Tn POSIX . .Pp If .Dv O_NOFOLLOW is used in the mask and the target file passed to .Fn open is a symbolic link then the .Fn open will fail. .Pp When opening a file, a lock with .Xr flock 2 semantics can be obtained by setting .Dv O_SHLOCK for a shared lock, or .Dv O_EXLOCK for an exclusive lock. If creating a file with .Dv O_CREAT , the request for the lock will never fail (provided that the underlying file system supports locking). .Pp .Dv O_DIRECT may be used to minimize or eliminate the cache effects of reading and writing. The system will attempt to avoid caching the data you read or write. If it cannot avoid caching the data, it will minimize the impact the data has on the cache. Use of this flag can drastically reduce performance if not used with care. .Pp .Dv O_NOCTTY may be used to ensure the OS does not assign this file as the controlling terminal when it opens a tty device. This is the default on .Fx , but is present for .Tn POSIX compatibility. The .Fn open system call will not assign controlling terminals on .Fx . .Pp .Dv O_TTY_INIT may be used to ensure the OS restores the terminal attributes when initially opening a TTY. This is the default on .Fx , but is present for .Tn POSIX compatibility. The initial call to .Fn open on a TTY will always restore default terminal attributes on .Fx . .Pp .Dv O_DIRECTORY may be used to ensure the resulting file descriptor refers to a directory. This flag can be used to prevent applications with elevated privileges from opening files which are even unsafe to open with .Dv O_RDONLY , such as device nodes. .Pp .Dv O_CLOEXEC may be used to set .Dv FD_CLOEXEC flag for the newly returned file descriptor. .Pp .Dv O_VERIFY may be used to indicate to the kernel that the contents of the file should be verified before allowing the open to proceed. The details of what .Dq verified means is implementation specific. The run-time linker (rtld) uses this flag to ensure shared objects have been verified before operating on them. .Pp .Dv O_BENEATH returns .Er ENOTCAPABLE if the specified relative path, after resolving all symlinks and ".." references, does not reside in the directory hierarchy of children beneath the topping directory. Topping directory is the process current directory if relative .Fa path is used for .Fn open , and the directory referenced by the .Fa fd argument when using .Fn openat . If the specified path is absolute, .Dv O_BENEATH allows arbitrary prefix that ends up at the topping directory, after which all further resolved components must be under it. .Pp When .Fa fd is opened with .Dv O_SEARCH , execute permissions are checked at open time. The .Fa fd may not be used for any read operations like .Xr getdirentries 2 . The primary use for this descriptor will be as the lookup descriptor for the .Fn *at family of functions. .Pp If successful, .Fn open returns a non-negative integer, termed a file descriptor. It returns \-1 on failure. The file pointer used to mark the current position within the file is set to the beginning of the file. .Pp If a sleeping open of a device node from .Xr devfs 5 is interrupted by a signal, the call always fails with .Er EINTR , even if the .Dv SA_RESTART flag is set for the signal. A sleeping open of a fifo (see .Xr mkfifo 2 ) is restarted as normal. .Pp When a new file is created it is given the group of the directory which contains it. .Pp Unless .Dv O_CLOEXEC flag was specified, the new descriptor is set to remain open across .Xr execve 2 system calls; see .Xr close 2 , .Xr fcntl 2 and .Dv O_CLOEXEC description. .Pp The system imposes a limit on the number of file descriptors open simultaneously by one process. The .Xr getdtablesize 2 system call returns the current system limit. .Sh RETURN VALUES If successful, .Fn open and .Fn openat return a non-negative integer, termed a file descriptor. They return \-1 on failure, and set .Va errno to indicate the error. .Sh ERRORS The named file is opened unless: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT .Dv O_CREAT is not set and the named file does not exist. .It Bq Er ENOENT A component of the path name that must exist does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EACCES The required permissions (for reading and/or writing) are denied for the given flags. .It Bq Er EACCES .Dv O_TRUNC is specified and write permission is denied. .It Bq Er EACCES .Dv O_CREAT is specified, the file does not exist, and the directory in which it is to be created does not permit writing. .It Bq Er EPERM .Dv O_CREAT is specified, the file does not exist, and the directory in which it is to be created has its immutable flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EPERM The named file has its immutable flag set and the file is to be modified. .It Bq Er EPERM The named file has its append-only flag set, the file is to be modified, and .Dv O_TRUNC is specified or .Dv O_APPEND is not specified. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EISDIR The named file is a directory, and the arguments specify it is to be modified. .It Bq Er EISDIR The named file is a directory, and the flags specified .Dv O_CREAT without .Dv O_DIRECTORY . .It Bq Er EROFS The named file resides on a read-only file system, and the file is to be modified. .It Bq Er EROFS .Dv O_CREAT is specified and the named file would reside on a read-only file system. .It Bq Er EMFILE The process has already reached its limit for open file descriptors. .It Bq Er ENFILE The system file table is full. .It Bq Er EMLINK .Dv O_NOFOLLOW was specified and the target is a symbolic link. .It Bq Er ENXIO The named file is a character special or block special file, and the device associated with this special file does not exist. .It Bq Er ENXIO .Dv O_NONBLOCK is set, the named file is a fifo, .Dv O_WRONLY is set, and no process has the file open for reading. .It Bq Er EINTR The .Fn open operation was interrupted by a signal. .It Bq Er EOPNOTSUPP .Dv O_SHLOCK or .Dv O_EXLOCK is specified but the underlying file system does not support locking. .It Bq Er EOPNOTSUPP The named file is a special file mounted through a file system that does not support access to it (e.g.\& NFS). .It Bq Er EWOULDBLOCK .Dv O_NONBLOCK and one of .Dv O_SHLOCK or .Dv O_EXLOCK is specified and the file is locked. .It Bq Er ENOSPC .Dv O_CREAT is specified, the file does not exist, and the directory in which the entry for the new file is being placed cannot be extended because there is no space left on the file system containing the directory. .It Bq Er ENOSPC .Dv O_CREAT is specified, the file does not exist, and there are no free inodes on the file system on which the file is being created. .It Bq Er EDQUOT .Dv O_CREAT is specified, the file does not exist, and the directory in which the entry for the new file is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .It Bq Er EDQUOT .Dv O_CREAT is specified, the file does not exist, and the user's quota of inodes on the file system on which the file is being created has been exhausted. .It Bq Er EIO An I/O error occurred while making the directory entry or allocating the inode for .Dv O_CREAT . +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er ETXTBSY The file is a pure procedure (shared text) file that is being executed and the .Fn open system call requests write access. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EEXIST .Dv O_CREAT and .Dv O_EXCL were specified and the file exists. .It Bq Er EOPNOTSUPP An attempt was made to open a socket (not currently implemented). .It Bq Er EINVAL An attempt was made to open a descriptor with an illegal combination of .Dv O_RDONLY , .Dv O_WRONLY , or .Dv O_RDWR , and .Dv O_EXEC or .Dv O_SEARCH . .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTDIR .Dv O_DIRECTORY is specified and the file is not a directory. .It Bq Er ECAPMODE .Dv AT_FDCWD is specified and the process is in capability mode. .It Bq Er ECAPMODE .Fn open was called and the process is in capability mode. .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv O_BENEATH flag was provided, and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Sh SEE ALSO .Xr chmod 2 , .Xr close 2 , .Xr dup 2 , .Xr fexecve 2 , .Xr fhopen 2 , .Xr getdtablesize 2 , .Xr getfh 2 , .Xr lgetfh 2 , .Xr lseek 2 , .Xr read 2 , .Xr umask 2 , .Xr write 2 , .Xr fopen 3 , .Xr capsicum 4 .Sh STANDARDS These functions are specified by .St -p1003.1-2008 . .Fx sets .Va errno to .Er EMLINK instead of .Er ELOOP as specified by .Tn POSIX when .Dv O_NOFOLLOW is set in flags and the final component of pathname is a symbolic link to distinguish it from the case of too many symbolic link traversals in one of its non-final components. .Sh HISTORY The .Fn open function appeared in .At v1 . The .Fn openat function was introduced in .Fx 8.0 . .Sh BUGS The Open Group Extended API Set 2 specification requires that the test for whether .Fa fd is searchable is based on whether .Fa fd is open for searching, not whether the underlying directory currently permits searches. The present implementation of the .Fa openat checks the current permissions of directory instead. .Pp The .Fa mode argument is variadic and may result in different calling conventions than might otherwise be expected. Index: head/lib/libc/sys/pathconf.2 =================================================================== --- head/lib/libc/sys/pathconf.2 (revision 359464) +++ head/lib/libc/sys/pathconf.2 (revision 359465) @@ -1,261 +1,265 @@ .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)pathconf.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 7, 2009 +.Dd March 30, 2020 .Dt PATHCONF 2 .Os .Sh NAME .Nm pathconf , .Nm lpathconf , .Nm fpathconf .Nd get configurable pathname variables .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft long .Fn pathconf "const char *path" "int name" .Ft long .Fn lpathconf "const char *path" "int name" .Ft long .Fn fpathconf "int fd" "int name" .Sh DESCRIPTION The .Fn pathconf , .Fn lpathconf and .Fn fpathconf system calls provide a method for applications to determine the current value of a configurable system limit or option variable associated with a pathname or file descriptor. .Pp For .Fn pathconf and .Fn lpathconf , the .Fa path argument is the name of a file or directory. For .Fn fpathconf , the .Fa fd argument is an open file descriptor. The .Fa name argument specifies the system variable to be queried. Symbolic constants for each name value are found in the include file .Li . .Pp The .Fn lpathconf system call is like .Fn pathconf except in the case where the named file is a symbolic link, in which case .Fn lpathconf returns information about the link, while .Fn pathconf returns information about the file the link references. .Pp The available values are as follows: .Bl -tag -width 6n .It Li _PC_LINK_MAX The maximum file link count. .It Li _PC_MAX_CANON The maximum number of bytes in terminal canonical input line. .It Li _PC_MAX_INPUT The minimum maximum number of bytes for which space is available in a terminal input queue. .It Li _PC_NAME_MAX The maximum number of bytes in a file name. .It Li _PC_PATH_MAX The maximum number of bytes in a pathname. .It Li _PC_PIPE_BUF The maximum number of bytes which will be written atomically to a pipe. .It Li _PC_CHOWN_RESTRICTED Return 1 if appropriate privilege is required for the .Xr chown 2 system call, otherwise 0. .St -p1003.1-2001 requires appropriate privilege in all cases, but this behavior was optional in prior editions of the standard. .It Li _PC_NO_TRUNC Return greater than zero if attempts to use pathname components longer than .Brq Dv NAME_MAX will result in an .Bq Er ENAMETOOLONG error; otherwise, such components will be truncated to .Brq Dv NAME_MAX . .St -p1003.1-2001 requires the error in all cases, but this behavior was optional in prior editions of the standard, and some .No non- Ns Tn POSIX Ns -compliant file systems do not support this behavior. .It Li _PC_VDISABLE Returns the terminal character disabling value. .It Li _PC_ASYNC_IO Return 1 if asynchronous I/O is supported, otherwise 0. .It Li _PC_PRIO_IO Returns 1 if prioritised I/O is supported for this file, otherwise 0. .It Li _PC_SYNC_IO Returns 1 if synchronised I/O is supported for this file, otherwise 0. .It Li _PC_ALLOC_SIZE_MIN Minimum number of bytes of storage allocated for any portion of a file. .It Li _PC_FILESIZEBITS Number of bits needed to represent the maximum file size. .It Li _PC_REC_INCR_XFER_SIZE Recommended increment for file transfer sizes between .Dv _PC_REC_MIN_XFER_SIZE and .Dv _PC_REC_MAX_XFER_SIZE . .It Li _PC_REC_MAX_XFER_SIZE Maximum recommended file transfer size. .It Li _PC_REC_MIN_XFER_SIZE Minimum recommended file transfer size. .It Li _PC_REC_XFER_ALIGN Recommended file transfer buffer alignment. .It Li _PC_SYMLINK_MAX Maximum number of bytes in a symbolic link. .It Li _PC_ACL_EXTENDED Returns 1 if an Access Control List (ACL) can be set on the specified file, otherwise 0. .It Li _PC_ACL_NFS4 Returns 1 if an NFSv4 ACLs can be set on the specified file, otherwise 0. .It Li _PC_ACL_PATH_MAX Maximum number of ACL entries per file. .It Li _PC_CAP_PRESENT Returns 1 if a capability state can be set on the specified file, otherwise 0. .It Li _PC_INF_PRESENT Returns 1 if an information label can be set on the specified file, otherwise 0. .It Li _PC_MAC_PRESENT Returns 1 if a Mandatory Access Control (MAC) label can be set on the specified file, otherwise 0. .It Li _PC_MIN_HOLE_SIZE If a file system supports the reporting of holes (see .Xr lseek 2 ) , .Fn pathconf and .Fn fpathconf return a positive number that represents the minimum hole size returned in bytes. The offsets of holes returned will be aligned to this same value. A special value of 1 is returned if the file system does not specify the minimum hole size but still reports holes. .El .Sh RETURN VALUES If the call to .Fn pathconf or .Fn fpathconf is not successful, \-1 is returned and .Va errno is set appropriately. Otherwise, if the variable is associated with functionality that does not have a limit in the system, \-1 is returned and .Va errno is not modified. Otherwise, the current variable value is returned. .Sh ERRORS If any of the following conditions occur, the .Fn pathconf and .Fn fpathconf system calls shall return -1 and set .Va errno to the corresponding value. .Bl -tag -width Er .It Bq Er EINVAL The value of the .Fa name argument is invalid. .It Bq Er EINVAL The implementation does not support an association of the variable name with the associated file. .El .Pp The .Fn pathconf system call will fail if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded .Brq Dv NAME_MAX characters (but see .Dv _PC_NO_TRUNC above), or an entire path name exceeded .Brq Dv PATH_MAX characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp The .Fn fpathconf system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid open file descriptor. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr lseek 2 , .Xr sysctl 3 .Sh HISTORY The .Fn pathconf and .Fn fpathconf system calls first appeared in .Bx 4.4 . The .Fn lpathconf system call first appeared in .Fx 8.0 . Index: head/lib/libc/sys/posix_fadvise.2 =================================================================== --- head/lib/libc/sys/posix_fadvise.2 (revision 359464) +++ head/lib/libc/sys/posix_fadvise.2 (revision 359465) @@ -1,139 +1,143 @@ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)madvise.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd October 3, 2015 +.Dd March 30, 2020 .Dt POSIX_FADVISE 2 .Os .Sh NAME .Nm posix_fadvise .Nd give advice about use of file data .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In fcntl.h .Ft int .Fn posix_fadvise "int fd" "off_t offset" "off_t len" "int advice" .Sh DESCRIPTION The .Fn posix_fadvise system call allows a process to describe to the system its data access behavior for an open file descriptor .Fa fd . The advice covers the data starting at offset .Fa offset and continuing for .Fa len bytes. If .Fa len is zero, all data from .Fa offset to the end of the file is covered. .Pp The behavior is specified by the .Fa advice parameter and may be one of: .Bl -tag -width POSIX_FADV_SEQUENTIAL .It Dv POSIX_FADV_NORMAL Tells the system to revert to the default data access behavior. .It Dv POSIX_FADV_RANDOM Is a hint that file data will be accessed randomly, and prefetching is likely not advantageous. .It Dv POSIX_FADV_SEQUENTIAL Tells the system that file data will be accessed sequentially. This currently does nothing as the default behavior uses heuristics to detect sequential behavior. .It Dv POSIX_FADV_WILLNEED Tells the system that the specified data will be accessed in the near future. The system may initiate an asynchronous read of the data if it is not already present in memory. .It Dv POSIX_FADV_DONTNEED Tells the system that the specified data will not be accessed in the near future. The system may decrease the in-memory priority of clean data within the specified range and future access to this data may require a read operation. .It Dv POSIX_FADV_NOREUSE Tells the system that the specified data will only be accessed once and then not reused. The system may decrease the in-memory priority of data once it has been read or written. Future access to this data may require a read operation. .El .Sh RETURN VALUES If successful, .Fn posix_fadvise returns zero. It returns an error on failure, without setting .Va errno . .Sh ERRORS Possible failure conditions: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor. .It Bq Er EINVAL The .Fa advice argument is not valid. .It Bq Er EINVAL The .Fa offset or .Fa len arguments are negative, or .Fa offset + .Fa len is greater than the maximum file size. .It Bq Er ENODEV The .Fa fd argument does not refer to a regular file. .It Bq Er ESPIPE The .Fa fd argument is associated with a pipe or FIFO. +.It Bq Er EIO +An I/O error occurred while reading from or writing to a file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr madvise 2 .Sh STANDARDS The .Fn posix_fadvise interface conforms to .St -p1003.1-2001 . .Sh HISTORY The .Fn posix_fadvise system call first appeared in .Fx 9.1 . Index: head/lib/libc/sys/posix_fallocate.2 =================================================================== --- head/lib/libc/sys/posix_fallocate.2 (revision 359464) +++ head/lib/libc/sys/posix_fallocate.2 (revision 359465) @@ -1,150 +1,152 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd January 5, 2020 +.Dd March 30, 2020 .Dt POSIX_FALLOCATE 2 .Os .Sh NAME .Nm posix_fallocate .Nd pre-allocate storage for a range in a file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In fcntl.h .Ft int .Fn posix_fallocate "int fd" "off_t offset" "off_t len" .Sh DESCRIPTION Required storage for the range .Fa offset to .Fa offset + .Fa len in the file referenced by .Fa fd is guaranteed to be allocated upon successful return. That is, if .Fn posix_fallocate returns successfully, subsequent writes to the specified file data will not fail due to lack of free space on the file system storage media. Any existing file data in the specified range is unmodified. If .Fa offset + .Fa len is beyond the current file size, then .Fn posix_fallocate will adjust the file size to .Fa offset + .Fa len . Otherwise, the file size will not be changed. .Pp Space allocated by .Fn posix_fallocate will be freed by a successful call to .Xr creat 2 or .Xr open 2 that truncates the size of the file. Space allocated via .Fn posix_fallocate may be freed by a successful call to .Xr ftruncate 2 that reduces the file size to a size smaller than .Fa offset + .Fa len . .Sh RETURN VALUES If successful, .Fn posix_fallocate returns zero. It returns an error on failure, without setting .Va errno . .Sh ERRORS Possible failure conditions: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor. .It Bq Er EBADF The .Fa fd argument references a file that was opened without write permission. .It Bq Er EFBIG The value of .Fa offset + .Fa len is greater than the maximum file size. .It Bq Er EINTR A signal was caught during execution. .It Bq Er EINVAL 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. .It Bq Er EIO An I/O error occurred while reading from or writing to a file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er ENODEV The .Fa fd argument does not refer to a file that supports .Nm . .It Bq Er ENOSPC There is insufficient free space remaining on the file system storage media. .It Bq Er ENOTCAPABLE The file descriptor .Fa fd has insufficient rights. .It Bq Er ESPIPE The .Fa fd argument is associated with a pipe or FIFO. .El .Sh SEE ALSO .Xr creat 2 , .Xr ftruncate 2 , .Xr open 2 , .Xr unlink 2 .Sh STANDARDS The .Fn posix_fallocate system call conforms to .St -p1003.1-2004 . .Sh HISTORY The .Fn posix_fallocate function appeared in .Fx 9.0 . .Sh AUTHORS .Fn posix_fallocate and this manual page were initially written by .An Matthew Fleming Aq Mt mdf@FreeBSD.org . Index: head/lib/libc/sys/quotactl.2 =================================================================== --- head/lib/libc/sys/quotactl.2 (revision 359464) +++ head/lib/libc/sys/quotactl.2 (revision 359465) @@ -1,261 +1,263 @@ .\" Copyright (c) 1983, 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Robert Elz at The University of Melbourne. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)quotactl.2 8.2 (Berkeley) 3/10/95 .\" $FreeBSD$ .\" -.Dd March 5, 1999 +.Dd March 30, 2020 .Dt QUOTACTL 2 .Os .Sh NAME .Nm quotactl .Nd manipulate file system quotas .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/types.h .In ufs/ufs/quota.h .Ft int .Fn quotactl "const char *path" "int cmd" "int id" "void *addr" .Sh DESCRIPTION The .Fn quotactl system call enables, disables and manipulates file system quotas. A quota control command given by .Fa cmd operates on the given filename .Fa path for the given user or group .Fa id . (NOTE: One should use the QCMD macro defined in .In ufs/ufs/quota.h to formulate the value for .Fa cmd . ) The address of an optional command specific data structure, .Fa addr , may be given; its interpretation is discussed below with each command. .Pp For commands that use the .Fa id identifier, it must be either -1 or any positive value. The value of -1 indicates that the current UID or GID should be used. Any other negative value will return an error. .Pp Currently quotas are supported only for the .Dq ufs file system. For .Dq ufs , a command is composed of a primary command (see below) and a command type used to interpret the .Fa id . Types are supported for interpretation of user identifiers (USRQUOTA) and group identifiers (GRPQUOTA). The .Dq ufs specific commands are: .Bl -tag -width Q_GETQUOTASIZEx .It Dv Q_QUOTAON Enable disk quotas for the file system specified by .Fa path . The command type specifies the type of the quotas being enabled. The .Fa addr argument specifies a file from which to take the quotas. The quota file must exist; it is normally created with the .Xr quotacheck 8 program. The .Fa id argument is unused. Only the super-user may turn quotas on. .It Dv Q_QUOTAOFF Disable disk quotas for the file system specified by .Fa path . The command type specifies the type of the quotas being disabled. The .Fa addr and .Fa id arguments are unused. Only the super-user may turn quotas off. .It Dv Q_GETQUOTASIZE Get the wordsize used to represent the quotas for the user or group (as determined by the command type). Possible values are 32 for the old-style quota file and 64 for the new-style quota file. The .Fa addr argument is a pointer to an integer into which the size is stored. The identifier .Fa id is not used. .It Dv Q_GETQUOTA Get disk quota limits and current usage for the user or group (as determined by the command type) with identifier .Fa id . The .Fa addr argument is a pointer to a .Fa struct dqblk structure (defined in .In ufs/ufs/quota.h ) . .It Dv Q_SETQUOTA Set disk quota limits for the user or group (as determined by the command type) with identifier .Fa id . The .Fa addr argument is a pointer to a .Fa struct dqblk structure (defined in .In ufs/ufs/quota.h ) . The usage fields of the .Fa dqblk structure are ignored. This system call is restricted to the super-user. .It Dv Q_SETUSE Set disk usage limits for the user or group (as determined by the command type) with identifier .Fa id . The .Fa addr argument is a pointer to a .Fa struct dqblk structure (defined in .In ufs/ufs/quota.h ) . Only the usage fields are used. This system call is restricted to the super-user. .It Dv Q_SYNC Update the on-disk copy of quota usages. The command type specifies which type of quotas are to be updated. The .Fa id and .Fa addr arguments are ignored. .El .Sh RETURN VALUES .Rv -std quotactl .Sh ERRORS The .Fn quotactl system call will fail if: .Bl -tag -width Er .It Bq Er EOPNOTSUPP The kernel has not been compiled with the .Dv QUOTA option. .It Bq Er EUSERS The quota table cannot be expanded. .It Bq Er EINVAL The .Fa cmd argument or the command type is invalid. In .Dv Q_GETQUOTASIZE , .Dv Q_GETQUOTA , .Dv Q_SETQUOTA , and .Dv Q_SETUSE , quotas are not currently enabled for this file system. .Pp The .Fa id argument to .Dv Q_GETQUOTA , .Dv Q_SETQUOTA or .Dv Q_SETUSE is a negative value. .It Bq Er EACCES In .Dv Q_QUOTAON , the quota file is not a plain file. .It Bq Er EACCES Search permission is denied for a component of a path prefix. .It Bq Er ENOTDIR A component of a path prefix was not a directory. .It Bq Er ENAMETOOLONG A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. .It Bq Er ENOENT A filename does not exist. .It Bq Er ELOOP Too many symbolic links were encountered in translating a pathname. .It Bq Er EROFS In .Dv Q_QUOTAON , either the file system on which quotas are to be enabled is mounted read-only or the quota file resides on a read-only file system. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to a file containing quotas. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFAULT An invalid .Fa addr was supplied; the associated structure could not be copied in or out of the kernel. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er EPERM The call was privileged and the caller was not the super-user. .El .Sh SEE ALSO .Xr quota 1 , .Xr fstab 5 , .Xr edquota 8 , .Xr quotacheck 8 , .Xr quotaon 8 , .Xr repquota 8 .Sh HISTORY The .Fn quotactl system call appeared in .Bx 4.3 Reno . .Sh BUGS There should be some way to integrate this call with the resource limit interface provided by .Xr setrlimit 2 and .Xr getrlimit 2 . Index: head/lib/libc/sys/read.2 =================================================================== --- head/lib/libc/sys/read.2 (revision 359464) +++ head/lib/libc/sys/read.2 (revision 359465) @@ -1,303 +1,305 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)read.2 8.4 (Berkeley) 2/26/94 .\" $FreeBSD$ .\" -.Dd July 6, 2019 +.Dd March 30, 2020 .Dt READ 2 .Os .Sh NAME .Nm read , .Nm readv , .Nm pread , .Nm preadv .Nd read input .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft ssize_t .Fn read "int fd" "void *buf" "size_t nbytes" .Ft ssize_t .Fn pread "int fd" "void *buf" "size_t nbytes" "off_t offset" .In sys/uio.h .Ft ssize_t .Fn readv "int fd" "const struct iovec *iov" "int iovcnt" .Ft ssize_t .Fn preadv "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset" .Sh DESCRIPTION The .Fn read system call attempts to read .Fa nbytes of data from the object referenced by the descriptor .Fa fd into the buffer pointed to by .Fa buf . The .Fn readv system call performs the same action, but scatters the input data into the .Fa iovcnt buffers specified by the members of the .Fa iov array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1]. The .Fn pread and .Fn preadv system calls perform the same functions, but read from the specified position in the file without modifying the file pointer. .Pp For .Fn readv and .Fn preadv , the .Fa iovec structure is defined as: .Pp .Bd -literal -offset indent -compact struct iovec { void *iov_base; /* Base address. */ size_t iov_len; /* Length. */ }; .Ed .Pp Each .Fa iovec entry specifies the base address and length of an area in memory where data should be placed. The .Fn readv system call will always fill an area completely before proceeding to the next. .Pp On objects capable of seeking, the .Fn read starts at a position given by the pointer associated with .Fa fd (see .Xr lseek 2 ) . Upon return from .Fn read , the pointer is incremented by the number of bytes actually read. .Pp Objects that are not capable of seeking always read from the current position. The value of the pointer associated with such an object is undefined. .Pp Upon successful completion, .Fn read , .Fn readv , .Fn pread and .Fn preadv return the number of bytes actually read and placed in the buffer. The system guarantees to read the number of bytes requested if the descriptor references a normal file that has that many bytes left before the end-of-file, but in no other case. .Pp In accordance with .St -p1003.1-2004 , both .Xr read 2 and .Xr write 2 syscalls are atomic with respect to each other in the effects on file content, when they operate on regular files. If two threads each call one of the .Xr read 2 or .Xr write 2 , syscalls, each call will see either all of the changes of the other call, or none of them. The .Fx kernel implements this guarantee by locking the file ranges affected by the calls. .Sh RETURN VALUES If successful, the number of bytes actually read is returned. Upon reading end-of-file, zero is returned. Otherwise, a -1 is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS The .Fn read , .Fn readv , .Fn pread and .Fn preadv system calls will succeed unless: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file or socket descriptor open for reading. .It Bq Er ECONNRESET The .Fa fd argument refers to a socket, and the remote socket end is forcibly closed. .It Bq Er EFAULT The .Fa buf argument points outside the allocated address space. .It Bq Er EIO An I/O error occurred while reading from the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EBUSY Failed to read from a file, e.g. /proc//regs while is not stopped .It Bq Er EINTR A read from a slow device (i.e.\& one that might block for an arbitrary amount of time) was interrupted by the delivery of a signal before any data arrived. .It Bq Er EINVAL The pointer associated with .Fa fd was negative. .It Bq Er EAGAIN The file was marked for non-blocking I/O, and no data were ready to be read. .It Bq Er EISDIR The file descriptor is associated with a directory residing on a file system that does not allow regular read operations on directories (e.g.\& NFS). .It Bq Er EOPNOTSUPP The file descriptor is associated with a file system and file type that do not allow regular read operations on it. .It Bq Er EOVERFLOW The file descriptor is associated with a regular file, .Fa nbytes is greater than 0, .Fa offset is before the end-of-file, and .Fa offset is greater than or equal to the offset maximum established for this file system. .It Bq Er EINVAL The value .Fa nbytes is greater than .Dv INT_MAX . .El .Pp In addition, .Fn readv and .Fn preadv may return one of the following errors: .Bl -tag -width Er .It Bq Er EINVAL The .Fa iovcnt argument was less than or equal to 0, or greater than .Dv IOV_MAX . .It Bq Er EINVAL One of the .Fa iov_len values in the .Fa iov array was negative. .It Bq Er EINVAL The sum of the .Fa iov_len values in the .Fa iov array overflowed a 32-bit integer. .It Bq Er EFAULT Part of the .Fa iov array points outside the process's allocated address space. .El .Pp The .Fn pread and .Fn preadv system calls may also return the following errors: .Bl -tag -width Er .It Bq Er EINVAL The .Fa offset value was negative. .It Bq Er ESPIPE The file descriptor is associated with a pipe, socket, or FIFO. .El .Sh SEE ALSO .Xr dup 2 , .Xr fcntl 2 , .Xr getdirentries 2 , .Xr open 2 , .Xr pipe 2 , .Xr select 2 , .Xr socket 2 , .Xr socketpair 2 , .Xr fread 3 , .Xr readdir 3 .Sh STANDARDS The .Fn read system call is expected to conform to .St -p1003.1-90 . The .Fn readv and .Fn pread system calls are expected to conform to .St -xpg4.2 . .Sh HISTORY The .Fn preadv system call appeared in .Fx 6.0 . The .Fn pread function appeared in .At V.4 . The .Fn readv system call appeared in .Bx 4.2 . The .Fn read function appeared in .At v1 . Index: head/lib/libc/sys/readlink.2 =================================================================== --- head/lib/libc/sys/readlink.2 (revision 359464) +++ head/lib/libc/sys/readlink.2 (revision 359465) @@ -1,158 +1,160 @@ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)readlink.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 10, 2008 +.Dd March 30, 2020 .Dt READLINK 2 .Os .Sh NAME .Nm readlink , .Nm readlinkat .Nd read value of a symbolic link .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft ssize_t .Fn readlink "const char *restrict path" "char *restrict buf" "size_t bufsiz" .Ft ssize_t .Fo readlinkat .Fa "int fd" "const char *restrict path" "char *restrict buf" "size_t bufsize" .Fc .Sh DESCRIPTION The .Fn readlink system call places the contents of the symbolic link .Fa path in the buffer .Fa buf , which has size .Fa bufsiz . The .Fn readlink system call does not append a .Dv NUL character to .Fa buf . .Pp The .Fn readlinkat system call is equivalent to .Fn readlink except in the case where .Fa path specifies a relative path. In this case the symbolic link whose content is read relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. If .Fn readlinkat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn readlink . .Sh RETURN VALUES The call returns the count of characters placed in the buffer if it succeeds, or a \-1 if an error occurs, placing the error code in the global variable .Va errno . .Sh ERRORS The .Fn readlink system call will fail if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EINVAL The named file is not a symbolic link. .It Bq Er EIO An I/O error occurred while reading from the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFAULT The .Fa buf argument extends outside the process's allocated address space. .El .Pp In addition to the errors returned by the .Fn readlink , the .Fn readlinkat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .El .Sh SEE ALSO .Xr lstat 2 , .Xr stat 2 , .Xr symlink 2 , .Xr symlink 7 .Sh STANDARDS The .Fn readlinkat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn readlink system call appeared in .Bx 4.2 . The .Fn readlinkat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/rename.2 =================================================================== --- head/lib/libc/sys/rename.2 (revision 359464) +++ head/lib/libc/sys/rename.2 (revision 359465) @@ -1,340 +1,342 @@ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)rename.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 21, 2018 +.Dd March 30, 2020 .Dt RENAME 2 .Os .Sh NAME .Nm rename .Nd change the name of a file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In stdio.h .Ft int .Fn rename "const char *from" "const char *to" .Ft int .Fn renameat "int fromfd" "const char *from" "int tofd" "const char *to" .Sh DESCRIPTION The .Fn rename system call causes the link named .Fa from to be renamed as .Fa to . If .Fa to exists, it is first removed. Both .Fa from and .Fa to must be of the same type (that is, both directories or both non-directories), and must reside on the same file system. .Pp The .Fn rename system call guarantees that if .Fa to already exists, an instance of .Fa to will always exist, even if the system should crash in the middle of the operation. .Pp If the final component of .Fa from is a symbolic link, the symbolic link is renamed, not the file or directory to which it points. .Pp If .Fa from and .Fa to resolve to the same directory entry, or to different directory entries for the same existing file, .Fn rename returns success without taking any further action. .Pp The .Fn renameat system call is equivalent to .Fn rename except in the case where either .Fa from or .Fa to specifies a relative path. If .Fa from is a relative path, the file to be renamed is located relative to the directory associated with the file descriptor .Fa fromfd instead of the current working directory. If the .Fa to is a relative path, the same happens only relative to the directory associated with .Fa tofd . If the .Fn renameat is passed the special value .Dv AT_FDCWD in the .Fa fromfd or .Fa tofd parameter, the current working directory is used in the determination of the file for the respective path parameter. .\".Sh CAVEAT .\"The system can deadlock if a loop in the file system graph is present. .\"This loop takes the form of an entry in directory .\".Pa a , .\"say .\".Pa a/foo , .\"being a hard link to directory .\".Pa b , .\"and an entry in .\"directory .\".Pa b , .\"say .\".Pa b/bar , .\"being a hard link .\"to directory .\".Pa a . .\"When such a loop exists and two separate processes attempt to .\"perform .\".Ql rename a/foo b/bar .\"and .\".Ql rename b/bar a/foo , .\"respectively, .\"the system may deadlock attempting to lock .\"both directories for modification. .\"Hard links to directories should be .\"replaced by symbolic links by the system administrator. .Sh RETURN VALUES .Rv -std rename .Sh ERRORS The .Fn rename system call will fail and neither of the argument files will be affected if: .Bl -tag -width Er .It Bq Er ENAMETOOLONG A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. .It Bq Er ENOENT A component of the .Fa from path does not exist, or a path prefix of .Fa to does not exist. .It Bq Er EACCES A component of either path prefix denies search permission. .It Bq Er EACCES The requested link requires writing in a directory with a mode that denies write permission. .It Bq Er EACCES The directory pointed at by the .Fa from argument denies write permission, and the operation would move it to another parent directory. .It Bq Er EPERM The file pointed at by the .Fa from argument has its immutable, undeletable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EPERM The parent directory of the file pointed at by the .Fa from argument has its immutable or append-only flag set. .It Bq Er EPERM The parent directory of the file pointed at by the .Fa to argument has its immutable flag set. .It Bq Er EPERM The directory containing .Fa from is marked sticky, and neither the containing directory nor .Fa from are owned by the effective user ID. .It Bq Er EPERM The file pointed at by the .Fa to argument exists, the directory containing .Fa to is marked sticky, and neither the containing directory nor .Fa to are owned by the effective user ID. .It Bq Er ELOOP Too many symbolic links were encountered in translating either pathname. .It Bq Er ENOTDIR A component of either path prefix is not a directory. .It Bq Er ENOTDIR The .Fa from argument is a directory, but .Fa to is not a directory. .It Bq Er EISDIR The .Fa to argument is a directory, but .Fa from is not a directory. .It Bq Er EXDEV The link named by .Fa to and the file named by .Fa from are on different logical devices (file systems). Note that this error code will not be returned if the implementation permits cross-device links. .It Bq Er ENOSPC The directory in which the entry for the new name is being placed cannot be extended because there is no space left on the file system containing the directory. .It Bq Er EDQUOT The directory in which the entry for the new name is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .It Bq Er EIO An I/O error occurred while making or updating a directory entry. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EROFS The requested link requires writing in a directory on a read-only file system. .It Bq Er EFAULT Path points outside the process's allocated address space. .It Bq Er EINVAL The .Fa from argument is a parent directory of .Fa to , or an attempt is made to rename .Ql .\& or .Ql \&.. . .It Bq Er ENOTEMPTY The .Fa to argument is a directory and is not empty. .It Bq Er ECAPMODE .Fn rename was called and the process is in capability mode. .El .Pp In addition to the errors returned by the .Fn rename , the .Fn renameat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa from argument does not specify an absolute path and the .Fa fromfd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching, or the .Fa to argument does not specify an absolute path and the .Fa tofd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa from argument is not an absolute path and .Fa fromfd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory, or the .Fa to argument is not an absolute path and .Fa tofd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ECAPMODE .Dv AT_FDCWD is specified and the process is in capability mode. .It Bq Er ENOTCAPABLE .Fa path is an absolute path or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fromfd or .Fa tofd . .It Bq Er ENOTCAPABLE The .Fa fromfd file descriptor lacks the .Dv CAP_RENAMEAT_SOURCE right, or the .Fa tofd file descriptor lacks the .Dv CAP_RENAMEAT_TARGET right. .El .Sh SEE ALSO .Xr chflags 2 , .Xr open 2 , .Xr symlink 7 .Sh STANDARDS The .Fn rename system call is expected to conform to .St -p1003.1-96 . The .Fn renameat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn renameat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/rmdir.2 =================================================================== --- head/lib/libc/sys/rmdir.2 (revision 359464) +++ head/lib/libc/sys/rmdir.2 (revision 359465) @@ -1,118 +1,120 @@ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)rmdir.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd December 9, 2006 +.Dd March 30, 2020 .Dt RMDIR 2 .Os .Sh NAME .Nm rmdir .Nd remove a directory file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn rmdir "const char *path" .Sh DESCRIPTION The .Fn rmdir system call removes a directory file whose name is given by .Fa path . The directory must not have any entries other than .Ql .\& and .Ql \&.. . .Sh RETURN VALUES .Rv -std rmdir .Sh ERRORS The named file is removed unless: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named directory does not exist. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er ENOTEMPTY The named directory contains files other than .Ql .\& and .Ql ..\& in it. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EACCES Write permission is denied on the directory containing the link to be removed. .It Bq Er EPERM The directory to be removed has its immutable, undeletable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EPERM The parent directory of the directory to be removed has its immutable or append-only flag set. .It Bq Er EPERM The directory containing the directory to be removed is marked sticky, and neither the containing directory nor the directory to be removed are owned by the effective user ID. .It Bq Er EINVAL The last component of the path is .Ql .\& or .Ql .. . .It Bq Er EBUSY The directory to be removed is the mount point for a mounted file system. .It Bq Er EIO An I/O error occurred while deleting the directory entry or deallocating the inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EROFS The directory entry to be removed resides on a read-only file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .El .Sh SEE ALSO .Xr mkdir 2 , .Xr unlink 2 .Sh HISTORY The .Fn rmdir system call appeared in .Bx 4.2 . Index: head/lib/libc/sys/sendfile.2 =================================================================== --- head/lib/libc/sys/sendfile.2 (revision 359464) +++ head/lib/libc/sys/sendfile.2 (revision 359465) @@ -1,442 +1,445 @@ .\" Copyright (c) 2003, David G. Lawrence .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice unmodified, this list of conditions, and the following .\" disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd February 15, 2019 +.Dd March 30, 2020 .Dt SENDFILE 2 .Os .Sh NAME .Nm sendfile .Nd send a file to a socket .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/types.h .In sys/socket.h .In sys/uio.h .Ft int .Fo sendfile .Fa "int fd" "int s" "off_t offset" "size_t nbytes" .Fa "struct sf_hdtr *hdtr" "off_t *sbytes" "int flags" .Fc .Sh DESCRIPTION The .Fn sendfile system call sends a regular file or shared memory object specified by descriptor .Fa fd out a stream socket specified by descriptor .Fa s . .Pp The .Fa offset argument specifies where to begin in the file. Should .Fa offset fall beyond the end of file, the system will return success and report 0 bytes sent as described below. The .Fa nbytes argument specifies how many bytes of the file should be sent, with 0 having the special meaning of send until the end of file has been reached. .Pp An optional header and/or trailer can be sent before and after the file data by specifying a pointer to a .Vt "struct sf_hdtr" , which has the following structure: .Pp .Bd -literal -offset indent -compact struct sf_hdtr { struct iovec *headers; /* pointer to header iovecs */ int hdr_cnt; /* number of header iovecs */ struct iovec *trailers; /* pointer to trailer iovecs */ int trl_cnt; /* number of trailer iovecs */ }; .Ed .Pp The .Fa headers and .Fa trailers pointers, if .Pf non- Dv NULL , point to arrays of .Vt "struct iovec" structures. See the .Fn writev system call for information on the iovec structure. The number of iovecs in these arrays is specified by .Fa hdr_cnt and .Fa trl_cnt . .Pp If .Pf non- Dv NULL , the system will write the total number of bytes sent on the socket to the variable pointed to by .Fa sbytes . .Pp The least significant 16 bits of .Fa flags argument is a bitmap of these values: .Bl -tag -offset indent -width "SF_USER_READAHEAD" .It Dv SF_NODISKIO This flag causes .Nm to return .Er EBUSY instead of blocking when a busy page is encountered. This rare situation can happen if some other process is now working with the same region of the file. It is advised to retry the operation after a short period. .Pp Note that in older .Fx versions the .Dv SF_NODISKIO had slightly different notion. The flag prevented .Nm to run I/O operations in case if an invalid (not cached) page is encountered, thus avoiding blocking on I/O. Starting with .Fx 11 .Nm sending files off the .Xr ffs 7 filesystem does not block on I/O (see .Sx IMPLEMENTATION NOTES ), so the condition no longer applies. However, it is safe if an application utilizes .Dv SF_NODISKIO and on .Er EBUSY performs the same action as it did in older .Fx versions, e.g., .Xr aio_read 2 , .Xr read 2 or .Nm in a different context. .It Dv SF_NOCACHE The data sent to socket will not be cached by the virtual memory system, and will be freed directly to the pool of free pages. .It Dv SF_SYNC .Nm sleeps until the network stack no longer references the VM pages of the file, making subsequent modifications to it safe. Please note that this is not a guarantee that the data has actually been sent. .It Dv SF_USER_READAHEAD .Nm has some internal heuristics to do readahead when sending data. This flag forces .Nm to override any heuristically calculated readahead and use exactly the application specified readahead. See .Sx SETTING READAHEAD for more details on readahead. .El .Pp When using a socket marked for non-blocking I/O, .Fn sendfile may send fewer bytes than requested. In this case, the number of bytes successfully written is returned in .Fa *sbytes (if specified), and the error .Er EAGAIN is returned. .Sh SETTING READAHEAD .Nm uses internal heuristics based on request size and file system layout to do readahead. Additionally application may request extra readahead. The most significant 16 bits of .Fa flags specify amount of pages that .Nm may read ahead when reading the file. A macro .Fn SF_FLAGS is provided to combine readahead amount and flags. An example showing specifying readahead of 16 pages and .Dv SF_NOCACHE flag: .Pp .Bd -literal -offset indent -compact SF_FLAGS(16, SF_NOCACHE) .Ed .Pp .Nm will use either application specified readahead or internally calculated, whichever is bigger. Setting flag .Dv SF_USER_READAHEAD would turn off any heuristics and set maximum possible readahead length to the number of pages specified via flags. .Sh IMPLEMENTATION NOTES The .Fx implementation of .Fn sendfile does not block on disk I/O when it sends a file off the .Xr ffs 7 filesystem. The syscall returns success before the actual I/O completes, and data is put into the socket later unattended. However, the order of data in the socket is preserved, so it is safe to do further writes to the socket. .Pp The .Fx implementation of .Fn sendfile is "zero-copy", meaning that it has been optimized so that copying of the file data is avoided. .Sh TUNING .Ss physical paging buffers .Fn sendfile uses vnode pager to read file pages into memory. The pager uses a pool of physical buffers to run its I/O operations. When system runs out of pbufs, sendfile will block and report state .Dq Li zonelimit . Size of the pool can be tuned with .Va vm.vnode_pbufs .Xr loader.conf 5 tunable and can be checked with .Xr sysctl 8 OID of the same name at runtime. .Ss sendfile(2) buffers On some architectures, this system call internally uses a special .Fn sendfile buffer .Pq Vt "struct sf_buf" to handle sending file data to the client. If the sending socket is blocking, and there are not enough .Fn sendfile buffers available, .Fn sendfile will block and report a state of .Dq Li sfbufa . If the sending socket is non-blocking and there are not enough .Fn sendfile buffers available, the call will block and wait for the necessary buffers to become available before finishing the call. .Pp The number of .Vt sf_buf Ns 's allocated should be proportional to the number of nmbclusters used to send data to a client via .Fn sendfile . Tune accordingly to avoid blocking! Busy installations that make extensive use of .Fn sendfile may want to increase these values to be inline with their .Va kern.ipc.nmbclusters (see .Xr tuning 7 for details). .Pp The number of .Fn sendfile buffers available is determined at boot time by either the .Va kern.ipc.nsfbufs .Xr loader.conf 5 variable or the .Dv NSFBUFS kernel configuration tunable. The number of .Fn sendfile buffers scales with .Va kern.maxusers . The .Va kern.ipc.nsfbufsused and .Va kern.ipc.nsfbufspeak read-only .Xr sysctl 8 variables show current and peak .Fn sendfile buffers usage respectively. These values may also be viewed through .Nm netstat Fl m . .Pp If .Xr sysctl 8 OID .Va kern.ipc.nsfbufs doesn't exist, your architecture does not need to use .Fn sendfile buffers because their task can be efficiently performed by the generic virtual memory structures. .Sh RETURN VALUES .Rv -std sendfile .Sh ERRORS .Bl -tag -width Er .It Bq Er EAGAIN The socket is marked for non-blocking I/O and not all data was sent due to the socket buffer being filled. If specified, the number of bytes successfully sent will be returned in .Fa *sbytes . .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor. .It Bq Er EBADF The .Fa s argument is not a valid socket descriptor. .It Bq Er EBUSY A busy page was encountered and .Dv SF_NODISKIO had been specified. Partial data may have been sent. .It Bq Er EFAULT An invalid address was specified for an argument. .It Bq Er EINTR A signal interrupted .Fn sendfile before it could be completed. If specified, the number of bytes successfully sent will be returned in .Fa *sbytes . .It Bq Er EINVAL The .Fa fd argument is not a regular file. .It Bq Er EINVAL The .Fa s argument is not a SOCK_STREAM type socket. .It Bq Er EINVAL The .Fa offset argument is negative. .It Bq Er EIO An error occurred while reading from +.Fa fd . +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from .Fa fd . .It Bq Er ENOTCAPABLE The .Fa fd or the .Fa s argument has insufficient rights. .It Bq Er ENOBUFS The system was unable to allocate an internal buffer. .It Bq Er ENOTCONN The .Fa s argument points to an unconnected socket. .It Bq Er ENOTSOCK The .Fa s argument is not a socket. .It Bq Er EOPNOTSUPP The file system for descriptor .Fa fd does not support .Fn sendfile . .It Bq Er EPIPE The socket peer has closed the connection. .El .Sh SEE ALSO .Xr loader.conf 5 , .Xr netstat 1 , .Xr open 2 , .Xr send 2 , .Xr socket 2 , .Xr writev 2 , .Xr sysctl 8 , .Xr tuning 7 .Rs .%A K. Elmeleegy .%A A. Chanda .%A A. L. Cox .%A W. Zwaenepoel .%T A Portable Kernel Abstraction for Low-Overhead Ephemeral Mapping Management .%J The Proceedings of the 2005 USENIX Annual Technical Conference .%P pp 223-236 .%D 2005 .Re .Sh HISTORY The .Fn sendfile system call first appeared in .Fx 3.0 . This manual page first appeared in .Fx 3.1 . In .Fx 10 support for sending shared memory descriptors had been introduced. In .Fx 11 a non-blocking implementation had been introduced. .Sh AUTHORS The initial implementation of .Fn sendfile system call and this manual page were written by .An David G. Lawrence Aq Mt dg@dglawrence.com . The .Fx 11 implementation was written by .An Gleb Smirnoff Aq Mt glebius@FreeBSD.org . .Sh BUGS The .Fn sendfile system call will not fail, i.e., return .Dv -1 and set .Va errno to .Er EFAULT , if provided an invalid address for .Fa sbytes . The .Fn sendfile system call does not support SCTP sockets, it will return .Dv -1 and set .Va errno to .Er EINVAL. Index: head/lib/libc/sys/stat.2 =================================================================== --- head/lib/libc/sys/stat.2 (revision 359464) +++ head/lib/libc/sys/stat.2 (revision 359465) @@ -1,504 +1,508 @@ .\" Copyright (c) 1980, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)stat.2 8.4 (Berkeley) 5/1/95 .\" $FreeBSD$ .\" -.Dd December 5, 2018 +.Dd March 30, 2020 .Dt STAT 2 .Os .Sh NAME .Nm stat , .Nm lstat , .Nm fstat , .Nm fstatat .Nd get file status .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/stat.h .Ft int .Fn stat "const char * restrict path" "struct stat * restrict sb" .Ft int .Fn lstat "const char * restrict path" "struct stat * restrict sb" .Ft int .Fn fstat "int fd" "struct stat *sb" .Ft int .Fn fstatat "int fd" "const char *path" "struct stat *sb" "int flag" .Sh DESCRIPTION The .Fn stat system call obtains information about the file pointed to by .Fa path . Read, write or execute permission of the named file is not required, but all directories listed in the path name leading to the file must be searchable. .Pp The .Fn lstat system call is like .Fn stat except when the named file is a symbolic link, in which case .Fn lstat returns information about the link, while .Fn stat returns information about the file the link references. .Pp The .Fn fstat system call obtains the same information about an open file known by the file descriptor .Fa fd . .Pp The .Fn fstatat system call is equivalent to .Fn stat and .Fn lstat except when the .Fa path specifies a relative path, or the .Dv AT_BENEATH flag is provided. For .Fn fstatat and relative .Fa path , the status is retrieved from a file relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. For .Dv AT_BENEATH and absolute .Fa path , the status is retrieved from a file specified by the .Fa path , but additional permission checks are performed, see below. .Pp The values for the .Fa flag are constructed by a bitwise-inclusive OR of flags from this list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_NOFOLLOW If .Fa path names a symbolic link, the status of the symbolic link is returned. .It Dv AT_BENEATH Only stat files and directories below the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn fstatat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn stat or .Fn lstat respectively, depending on whether or not the .Dv AT_SYMLINK_NOFOLLOW bit is set in .Fa flag . .Pp When .Fn fstatat is called with an absolute .Fa path without the .Dv AT_BENEATH flag, it ignores the .Fa fd argument. When .Dv AT_BENEATH is specified with an absolute .Fa path , a directory passed by the .Fa fd argument is used as the topping point for the resolution. .Pp The .Fa sb argument is a pointer to a .Vt stat structure as defined by .In sys/stat.h and into which information is placed concerning the file. .Pp The fields of .Vt "struct stat" related to the file system are: .Bl -tag -width ".Va st_nlink" .It Va st_dev Numeric ID of the device containing the file. .It Va st_ino The file's inode number. .It Va st_nlink Number of hard links to the file. .It Va st_flags Flags enabled for the file. See .Xr chflags 2 for the list of flags and their description. .El .Pp The .Va st_dev and .Va st_ino fields together identify the file uniquely within the system. .Pp The time-related fields of .Vt "struct stat" are: .Bl -tag -width ".Va st_birthtim" .It Va st_atim Time when file data was last accessed. Changed implicitly by syscalls such as .Xr read 2 and .Xr readv 2 , and explicitly by .Xr utimes 2 . .It Va st_mtim Time when file data was last modified. Changed implicitly by syscalls such as .Xr truncate 2 , .Xr write 2 , and .Xr writev 2 , and explicitly by .Xr utimes 2 . Also, any syscall which modifies directory content changes the .Va st_mtim for the affected directory. For instance, .Xr creat 2 , .Xr mkdir 2 , .Xr rename 2 , .Xr link 2 , and .Xr unlink 2 . .It Va st_ctim Time when file status was last changed (inode data modification). Changed implicitly by any syscall that affects file metadata, including .Va st_mtim , such as .Xr chflags 2 , .Xr chmod 2 , .Xr chown 2 , .Xr truncate 2 , .Xr utimes 2 , and .Xr write 2 . Also, any syscall which modifies directory content changes the .Va st_ctim for the affected directory. For instance, .Xr creat 2 , .Xr mkdir 2 , .Xr rename 2 , .Xr link 2 , and .Xr unlink 2 . .It Va st_birthtim Time when the inode was created. .El .Pp These time-related macros are defined for compatibility: .Bd -literal #define st_atime st_atim.tv_sec #define st_mtime st_mtim.tv_sec #define st_ctime st_ctim.tv_sec #ifndef _POSIX_SOURCE #define st_birthtime st_birthtim.tv_sec #endif #ifndef _POSIX_SOURCE #define st_atimespec st_atim #define st_mtimespec st_mtim #define st_ctimespec st_ctim #define st_birthtimespec st_birthtim #endif .Ed .Pp Size-related fields of the .Vt "struct stat" are: .Bl -tag -width ".Va st_blksize" .It Va st_size File size in bytes. .It Va st_blksize Optimal I/O block size for the file. .It Va st_blocks Actual number of blocks allocated for the file in 512-byte units. As short symbolic links are stored in the inode, this number may be zero. .El .Pp The access-related fields of .Vt "struct stat" are: .Bl -tag -width ".Va st_mode" .It Va st_uid User ID of the file's owner. .It Va st_gid Group ID of the file. .It Va st_mode Status of the file (see below). .El .Pp The status information word .Fa st_mode has these bits: .Bd -literal #define S_IFMT 0170000 /* type of file mask */ #define S_IFIFO 0010000 /* named pipe (fifo) */ #define S_IFCHR 0020000 /* character special */ #define S_IFDIR 0040000 /* directory */ #define S_IFBLK 0060000 /* block special */ #define S_IFREG 0100000 /* regular */ #define S_IFLNK 0120000 /* symbolic link */ #define S_IFSOCK 0140000 /* socket */ #define S_IFWHT 0160000 /* whiteout */ #define S_ISUID 0004000 /* set user id on execution */ #define S_ISGID 0002000 /* set group id on execution */ #define S_ISVTX 0001000 /* save swapped text even after use */ #define S_IRWXU 0000700 /* RWX mask for owner */ #define S_IRUSR 0000400 /* read permission, owner */ #define S_IWUSR 0000200 /* write permission, owner */ #define S_IXUSR 0000100 /* execute/search permission, owner */ #define S_IRWXG 0000070 /* RWX mask for group */ #define S_IRGRP 0000040 /* read permission, group */ #define S_IWGRP 0000020 /* write permission, group */ #define S_IXGRP 0000010 /* execute/search permission, group */ #define S_IRWXO 0000007 /* RWX mask for other */ #define S_IROTH 0000004 /* read permission, other */ #define S_IWOTH 0000002 /* write permission, other */ #define S_IXOTH 0000001 /* execute/search permission, other */ .Ed .Pp For a list of access modes, see .In sys/stat.h , .Xr access 2 and .Xr chmod 2 . These macros are available to test whether a .Va st_mode value passed in the .Fa m argument corresponds to a file of the specified type: .Bl -tag -width ".Fn S_ISFIFO m" .It Fn S_ISBLK m Test for a block special file. .It Fn S_ISCHR m Test for a character special file. .It Fn S_ISDIR m Test for a directory. .It Fn S_ISFIFO m Test for a pipe or FIFO special file. .It Fn S_ISLNK m Test for a symbolic link. .It Fn S_ISREG m Test for a regular file. .It Fn S_ISSOCK m Test for a socket. .It Fn S_ISWHT m Test for a whiteout. .El .Pp The macros evaluate to a non-zero value if the test is true or to the value 0 if the test is false. .Sh RETURN VALUES .Rv -std .Sh COMPATIBILITY Previous versions of the system used different types for the .Va st_dev , .Va st_uid , .Va st_gid , .Va st_rdev , .Va st_size , .Va st_blksize and .Va st_blocks fields. .Sh ERRORS The .Fn stat and .Fn lstat system calls will fail if: .Bl -tag -width Er .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EFAULT The .Fa sb or .Fa path argument points to an invalid address. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er EOVERFLOW The file size in bytes cannot be represented correctly in the structure pointed to by .Fa sb . .El .Pp The .Fn fstat system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid open file descriptor. .It Bq Er EFAULT The .Fa sb argument points to an invalid address. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EOVERFLOW The file size in bytes cannot be represented correctly in the structure pointed to by .Fa sb . .El .Pp In addition to the errors returned by the .Fn lstat , the .Fn fstatat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fn fstatat , and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Sh SEE ALSO .Xr access 2 , .Xr chmod 2 , .Xr chown 2 , .Xr fhstat 2 , .Xr statfs 2 , .Xr utimes 2 , .Xr sticky 7 , .Xr symlink 7 .Sh STANDARDS The .Fn stat and .Fn fstat system calls are expected to conform to .St -p1003.1-90 . The .Fn fstatat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn stat and .Fn fstat system calls appeared in .At v1 . The .Fn lstat system call appeared in .Bx 4.2 . The .Fn fstatat system call appeared in .Fx 8.0 . .Sh BUGS Applying .Fn fstat to a socket returns a zeroed buffer, except for the blocksize field, and a unique device and inode number. Index: head/lib/libc/sys/statfs.2 =================================================================== --- head/lib/libc/sys/statfs.2 (revision 359464) +++ head/lib/libc/sys/statfs.2 (revision 359465) @@ -1,236 +1,240 @@ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)statfs.2 8.5 (Berkeley) 5/24/95 .\" $FreeBSD$ .\" -.Dd February 13, 2017 +.Dd March 30, 2020 .Dt STATFS 2 .Os .Sh NAME .Nm statfs .Nd get file system statistics .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/mount.h .Ft int .Fn statfs "const char *path" "struct statfs *buf" .Ft int .Fn fstatfs "int fd" "struct statfs *buf" .Sh DESCRIPTION The .Fn statfs system call returns information about a mounted file system. The .Fa path argument is the path name of any file within the mounted file system. The .Fa buf argument is a pointer to a .Vt statfs structure defined as follows: .Bd -literal typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ /* * filesystem statistics */ #define MFSNAMELEN 16 /* length of type name including null */ #define MNAMELEN 1024 /* size of on/from name bufs */ #define STATFS_VERSION 0x20140518 /* current version number */ struct statfs { uint32_t f_version; /* structure version number */ uint32_t f_type; /* type of filesystem */ uint64_t f_flags; /* copy of mount exported flags */ uint64_t f_bsize; /* filesystem fragment size */ uint64_t f_iosize; /* optimal transfer block size */ uint64_t f_blocks; /* total data blocks in filesystem */ uint64_t f_bfree; /* free blocks in filesystem */ int64_t f_bavail; /* free blocks avail to non-superuser */ uint64_t f_files; /* total file nodes in filesystem */ int64_t f_ffree; /* free nodes avail to non-superuser */ uint64_t f_syncwrites; /* count of sync writes since mount */ uint64_t f_asyncwrites; /* count of async writes since mount */ uint64_t f_syncreads; /* count of sync reads since mount */ uint64_t f_asyncreads; /* count of async reads since mount */ uint64_t f_spare[10]; /* unused spare */ uint32_t f_namemax; /* maximum filename length */ uid_t f_owner; /* user that mounted the filesystem */ fsid_t f_fsid; /* filesystem id */ char f_charspare[80]; /* spare string space */ char f_fstypename[MFSNAMELEN]; /* filesystem type name */ char f_mntfromname[MNAMELEN]; /* mounted filesystem */ char f_mntonname[MNAMELEN]; /* directory on which mounted */ }; .Ed .Pp The flags that may be returned include: .Bl -tag -width MNT_SYNCHRONOUS .It Dv MNT_RDONLY The file system is mounted read-only; Even the super-user may not write on it. .It Dv MNT_NOEXEC Files may not be executed from the file system. .It Dv MNT_NOSUID Setuid and setgid bits on files are not honored when they are executed. .It Dv MNT_SYNCHRONOUS All I/O to the file system is done synchronously. .It Dv MNT_ASYNC No file system I/O is done synchronously. .It Dv MNT_SOFTDEP Soft updates being done (see .Xr ffs 7 ) . .It Dv MNT_GJOURNAL Journaling with gjournal is enabled (see .Xr gjournal 8 ) . .It Dv MNT_SUIDDIR Special handling of SUID bit on directories. .It Dv MNT_UNION Union with underlying file system. .It Dv MNT_NOSYMFOLLOW Symbolic links are not followed. .It Dv MNT_NOCLUSTERR Read clustering is disabled. .It Dv MNT_NOCLUSTERW Write clustering is disabled. .\".It Dv MNT_JAILDEVFS .\"XXX .It Dv MNT_MULTILABEL Mandatory Access Control (MAC) support for individual objects (see .Xr mac 4 ) . .It Dv MNT_ACLS Access Control List (ACL) support enabled. .It Dv MNT_LOCAL The file system resides locally. .It Dv MNT_QUOTA The file system has quotas enabled on it. .It Dv MNT_ROOTFS Identifies the root file system. .It Dv MNT_EXRDONLY The file system is exported read-only. .It Dv MNT_NOATIME Updating of file access times is disabled. .It Dv MNT_USER The file system has been mounted by a user. .\".It Dv MNT_IGNORE .\"XXX .It Dv MNT_EXPORTED The file system is exported for both reading and writing. .It Dv MNT_DEFEXPORTED The file system is exported for both reading and writing to any Internet host. .It Dv MNT_EXPORTANON The file system maps all remote accesses to the anonymous user. .It Dv MNT_EXKERB The file system is exported with Kerberos uid mapping. .It Dv MNT_EXPUBLIC The file system is exported publicly (WebNFS). .El .Pp Fields that are undefined for a particular file system are set to -1. The .Fn fstatfs system call returns the same information about an open file referenced by descriptor .Fa fd . .Sh RETURN VALUES .Rv -std .Sh ERRORS The .Fn statfs system call fails if one or more of the following are true: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix of .Fa path is not a directory. .It Bq Er ENAMETOOLONG The length of a component of .Fa path exceeds 255 characters, or the length of .Fa path exceeds 1023 characters. .It Bq Er ENOENT The file referred to by .Fa path does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix of .Fa path . .It Bq Er ELOOP Too many symbolic links were encountered in translating .Fa path . .It Bq Er EFAULT The .Fa buf or .Fa path argument points to an invalid address. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Pp The .Fn fstatfs system call fails if one or more of the following are true: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid open file descriptor. .It Bq Er EFAULT The .Fa buf argument points to an invalid address. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .El .Sh SEE ALSO .Xr fhstatfs 2 , .Xr getfsstat 2 .Sh HISTORY The .Fn statfs system call first appeared in .Bx 4.4 . Index: head/lib/libc/sys/swapon.2 =================================================================== --- head/lib/libc/sys/swapon.2 (revision 359464) +++ head/lib/libc/sys/swapon.2 (revision 359465) @@ -1,143 +1,146 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)swapon.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd October 4, 2013 +.Dd March 30, 2020 .Dt SWAPON 2 .Os .Sh NAME .Nm swapon , swapoff .Nd control devices for interleaved paging/swapping .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn swapon "const char *special" .Ft int .Fn swapoff "const char *special" .Sh DESCRIPTION The .Fn swapon system call makes the block device .Fa special available to the system for allocation for paging and swapping. The names of potentially available devices are known to the system and defined at system configuration time. The size of the swap area on .Fa special is calculated at the time the device is first made available for swapping. .Pp The .Fn swapoff system call disables paging and swapping on the given device. All associated swap metadata are deallocated, and the device is made available for other purposes. .Sh RETURN VALUES If an error has occurred, a value of -1 is returned and .Va errno is set to indicate the error. .Sh ERRORS Both .Fn swapon and .Fn swapoff can fail if: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named device does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The caller is not the super-user. .It Bq Er EFAULT The .Fa special argument points outside the process's allocated address space. .El .Pp Additionally, .Fn swapon can fail for the following reasons: .Bl -tag -width Er .It Bq Er ENOTBLK The .Fa special argument is not a block device. .It Bq Er EBUSY The device specified by .Fa special has already been made available for swapping .It Bq Er ENXIO The major device number of .Fa special is out of range (this indicates no device driver exists for the associated hardware). .It Bq Er EIO An I/O error occurred while opening the swap device. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system to open the +swap device. .El .Pp Lastly, .Fn swapoff can fail if: .Bl -tag -width Er .It Bq Er EINVAL The system is not currently swapping to .Fa special . .It Bq Er ENOMEM Not enough virtual memory is available to safely disable paging and swapping to the given device. .El .Sh SEE ALSO .Xr config 8 , .Xr swapon 8 , .Xr sysctl 8 .Sh HISTORY The .Fn swapon system call appeared in .Bx 4.0 . The .Fn swapoff system call appeared in .Fx 5.0 . Index: head/lib/libc/sys/symlink.2 =================================================================== --- head/lib/libc/sys/symlink.2 (revision 359464) +++ head/lib/libc/sys/symlink.2 (revision 359465) @@ -1,206 +1,208 @@ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)symlink.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 10, 2008 +.Dd March 30, 2020 .Dt SYMLINK 2 .Os .Sh NAME .Nm symlink , .Nm symlinkat .Nd make symbolic link to a file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn symlink "const char *name1" "const char *name2" .Ft int .Fn symlinkat "const char *name1" "int fd" "const char *name2" .Sh DESCRIPTION A symbolic link .Fa name2 is created to .Fa name1 .Fa ( name2 is the name of the file created, .Fa name1 is the string used in creating the symbolic link). Either name may be an arbitrary path name; the files need not be on the same file system. .Pp The .Fn symlinkat system call is equivalent to .Fn symlink except in the case where .Fa name2 specifies a relative path. In this case the symbolic link is created relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. If .Fn symlinkat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn symlink . .Sh RETURN VALUES .Rv -std symlink .Sh ERRORS The symbolic link succeeds unless: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the .Fa name2 path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of the .Fa name2 pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. .It Bq Er ENOENT A component of the .Fa name2 path prefix does not exist. .It Bq Er EACCES A component of the .Fa name2 path prefix denies search permission, or write permission is denied on the parent directory of the file to be created. .It Bq Er ELOOP Too many symbolic links were encountered in translating the .Fa name2 path name. .It Bq Er EEXIST The path name pointed at by the .Fa name2 argument already exists. .It Bq Er EPERM The parent directory of the file named by .Fa name2 has its immutable flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EIO An I/O error occurred while making the directory entry for .Fa name2 , or allocating the inode for .Fa name2 , or writing out the link contents of .Fa name2 . .It Bq Er EROFS The file .Fa name2 would reside on a read-only file system. .It Bq Er ENOSPC The directory in which the entry for the new symbolic link is being placed cannot be extended because there is no space left on the file system containing the directory. .It Bq Er ENOSPC The new symbolic link cannot be created because there is no space left on the file system that will contain the symbolic link. .It Bq Er ENOSPC There are no free inodes on the file system on which the symbolic link is being created. .It Bq Er EDQUOT The directory in which the entry for the new symbolic link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .It Bq Er EDQUOT The new symbolic link cannot be created because the user's quota of disk blocks on the file system that will contain the symbolic link has been exhausted. .It Bq Er EDQUOT The user's quota of inodes on the file system on which the symbolic link is being created has been exhausted. .It Bq Er EIO An I/O error occurred while making the directory entry or allocating the inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFAULT The .Fa name1 or .Fa name2 argument points outside the process's allocated address space. .El .Pp In addition to the errors returned by the .Fn symlink , the .Fn symlinkat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa name2 argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa name2 argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .El .Sh SEE ALSO .Xr ln 1 , .Xr chflags 2 , .Xr link 2 , .Xr lstat 2 , .Xr readlink 2 , .Xr unlink 2 , .Xr symlink 7 .Sh STANDARDS The .Fn symlinkat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn symlink system call appeared in .Bx 4.2 . The .Fn symlinkat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/truncate.2 =================================================================== --- head/lib/libc/sys/truncate.2 (revision 359464) +++ head/lib/libc/sys/truncate.2 (revision 359465) @@ -1,168 +1,170 @@ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)truncate.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 24, 2020 +.Dd March 30, 2020 .Dt TRUNCATE 2 .Os .Sh NAME .Nm truncate , .Nm ftruncate .Nd truncate or extend a file to a specified length .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn truncate "const char *path" "off_t length" .Ft int .Fn ftruncate "int fd" "off_t length" .Sh DESCRIPTION The .Fn truncate system call causes the file named by .Fa path or referenced by .Fa fd to be truncated or extended to .Fa length bytes in size. If the file was larger than this size, the extra data is lost. If the file was smaller than this size, it will be extended as if by writing bytes with the value zero. .Pp The .Fn ftruncate system call causes the file or shared memory object backing the file descriptor .Fa fd to be truncated or extended to .Fa length bytes in size. The file descriptor must be a valid file descriptor open for writing. The file position pointer associated with the file descriptor .Fa fd will not be modified. .Sh RETURN VALUES .Rv -std If the file to be modified is not a directory or a regular file, the .Fn truncate call has no effect and returns the value 0. .Sh ERRORS The .Fn truncate system call succeeds unless: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EACCES The named file is not writable by the user. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The named file has its immutable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EISDIR The named file is a directory. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er ETXTBSY The file is a pure procedure (shared text) file that is being executed. .It Bq Er EFBIG The .Fa length argument was greater than the maximum file size. .It Bq Er EINVAL The .Fa length argument was less than 0. .It Bq Er EIO An I/O error occurred updating the inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .El .Pp The .Fn ftruncate system call succeeds unless: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid descriptor. .It Bq Er EINVAL The .Fa fd argument references a file descriptor that is not a regular file or shared memory object. .It Bq Er EINVAL The .Fa fd descriptor is not open for writing. .El .Sh SEE ALSO .Xr chflags 2 , .Xr open 2 , .Xr shm_open 2 .Sh HISTORY The .Fn truncate and .Fn ftruncate system calls appeared in .Bx 4.2 . .Sh BUGS These calls should be generalized to allow ranges of bytes in a file to be discarded. .Pp Historically, the use of .Fn truncate or .Fn ftruncate to extend a file was not portable, but this behavior became required in .St -p1003.1-2008 . Index: head/lib/libc/sys/undelete.2 =================================================================== --- head/lib/libc/sys/undelete.2 (revision 359464) +++ head/lib/libc/sys/undelete.2 (revision 359465) @@ -1,105 +1,107 @@ .\" Copyright (c) 1994 .\" Jan-Simon Pendry .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)undelete.2 8.4 (Berkeley) 10/18/94 .\" $FreeBSD$ .\" -.Dd January 22, 2006 +.Dd March 30, 2020 .Dt UNDELETE 2 .Os .Sh NAME .Nm undelete .Nd attempt to recover a deleted file .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn undelete "const char *path" .Sh DESCRIPTION The .Fn undelete system call attempts to recover the deleted file named by .Fa path . Currently, this works only when the named object is a whiteout in a union file system. The system call removes the whiteout causing any objects in a lower layer of the union stack to become visible once more. .Pp Eventually, the .Fn undelete functionality may be expanded to other file systems able to recover deleted files such as the log-structured file system. .Sh RETURN VALUES .Rv -std undelete .Sh ERRORS The .Fn undelete succeeds unless: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er EEXIST The path does not reference a whiteout. .It Bq Er ENOENT The named whiteout does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EACCES Write permission is denied on the directory containing the name to be undeleted. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The directory containing the name is marked sticky, and the containing directory is not owned by the effective user ID. .It Bq Er EINVAL The last component of the path is .Ql .. . .It Bq Er EIO An I/O error occurred while updating the directory entry. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EROFS The name resides on a read-only file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .El .Sh SEE ALSO .Xr unlink 2 , .Xr mount_unionfs 8 .Sh HISTORY The .Fn undelete system call first appeared in .Bx 4.4 Lite . Index: head/lib/libc/sys/unlink.2 =================================================================== --- head/lib/libc/sys/unlink.2 (revision 359464) +++ head/lib/libc/sys/unlink.2 (revision 359465) @@ -1,290 +1,292 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)unlink.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 6, 2019 +.Dd March 30, 2020 .Dt UNLINK 2 .Os .Sh NAME .Nm unlink , .Nm unlinkat , .Nm funlinkat .Nd remove directory entry .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft int .Fn unlink "const char *path" .Ft int .Fn unlinkat "int dfd" "const char *path" "int flag" .Ft int .Fn funlinkat "int dfd" "const char *path" "int fd" "int flag" .Sh DESCRIPTION The .Fn unlink system call removes the link named by .Fa path from its directory and decrements the link count of the file which was referenced by the link. If that decrement reduces the link count of the file to zero, and no process has the file open, then all resources associated with the file are reclaimed. If one or more process have the file open when the last link is removed, the link is removed, but the removal of the file is delayed until all references to it have been closed. The .Fa path argument may not be a directory. .Pp The .Fn unlinkat system call is equivalent to .Fn unlink or .Fn rmdir except in the case where .Fa path specifies a relative path. In this case the directory entry to be removed is determined relative to the directory associated with the file descriptor .Fa dfd instead of the current working directory. .Pp The values for .Fa flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_REMOVEDIR Remove the directory entry specified by .Fa fd and .Fa path as a directory, not a normal file. .It Dv AT_BENEATH Only unlink files and directories which are beneath of the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Pp If .Fn unlinkat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fa unlink or .Fa rmdir respectively, depending on whether or not the .Dv AT_REMOVEDIR bit is set in flag. .Pp The .Fn funlinkat system call can be used to unlink an already-opened file, unless that file has been replaced since it was opened. It is equivalent to .Fn unlinkat in the case where .Fa path is already open as the file descriptor .Fa fd . Otherwise, the path will not be removed and an error will be returned. The .Fa fd can be set the .Dv FD_NONE . In that case .Fn funlinkat behaves exactly like .Fn unlinkat . .Sh RETURN VALUES .Rv -std unlink .Sh ERRORS The .Fn unlink succeeds unless: .Bl -tag -width Er .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er EISDIR The named file is a directory. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EACCES Write permission is denied on the directory containing the link to be removed. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EPERM The named file is a directory. .It Bq Er EPERM The named file has its immutable, undeletable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EPERM The parent directory of the named file has its immutable or append-only flag set. .It Bq Er EPERM The directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID. .It Bq Er EIO An I/O error occurred while deleting the directory entry or deallocating the inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EROFS The named file resides on a read-only file system. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er ENOSPC On file systems supporting copy-on-write or snapshots, there was not enough free space to record metadata for the delete operation of the file. .El .Pp In addition to the errors returned by the .Fn unlink , the .Fn unlinkat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTEMPTY The .Fa flag parameter has the .Dv AT_REMOVEDIR bit set and the .Fa path argument names a directory that is not an empty directory, or there are hard links to the directory other than dot or a single entry in dot-dot. .It Bq Er ENOTDIR The .Fa flag parameter has the .Dv AT_REMOVEDIR bit set and .Fa path does not name a directory. .It Bq Er EINVAL The value of the .Fa flag argument is not valid. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fn unlinkat , and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Pp In addition to the errors returned by .Fn unlinkat , .Fn funlinkat may fail if: .Bl -tag -width Er .It Bq Er EDEADLK The file descriptor is not associated with the path. .El .Sh SEE ALSO .Xr chflags 2 , .Xr close 2 , .Xr link 2 , .Xr rmdir 2 , .Xr symlink 7 .Sh STANDARDS The .Fn unlinkat system call follows The Open Group Extended API Set 2 specification. .Sh HISTORY The .Fn unlink function appeared in .At v1 . The .Fn unlinkat system call appeared in .Fx 8.0 . The .Fn funlinkat system call appeared in .Fx 13.0 . .Pp The .Fn unlink system call traditionally allows the super-user to unlink directories which can damage the file system integrity. This implementation no longer permits it. Index: head/lib/libc/sys/utimensat.2 =================================================================== --- head/lib/libc/sys/utimensat.2 (revision 359464) +++ head/lib/libc/sys/utimensat.2 (revision 359465) @@ -1,317 +1,319 @@ .\" $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" Copyright (c) 2012, Jilles Tjoelker .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)utimes.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd November 11, 2018 +.Dd March 30, 2020 .Dt UTIMENSAT 2 .Os .Sh NAME .Nm futimens , .Nm utimensat .Nd set file access and modification times .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/stat.h .Ft int .Fn futimens "int fd" "const struct timespec times[2]" .Ft int .Fo utimensat .Fa "int fd" .Fa "const char *path" .Fa "const struct timespec times[2]" .Fa "int flag" .Fc .Sh DESCRIPTION The access and modification times of the file named by .Fa path or referenced by .Fa fd are changed as specified by the argument .Fa times . The inode-change-time of the file is set to the current time. .Pp If .Fa path specifies a relative path, it is relative to the current working directory if .Fa fd is .Dv AT_FDCWD and otherwise relative to the directory associated with the file descriptor .Fa fd . .Pp The .Va tv_nsec field of a .Vt timespec structure can be set to the special value .Dv UTIME_NOW to set the current time, or to .Dv UTIME_OMIT to leave the time unchanged. In either case, the .Va tv_sec field is ignored. .Pp If .Fa times is .No non- Ns Dv NULL , it is assumed to point to an array of two timespec structures. The access time is set to the value of the first element, and the modification time is set to the value of the second element. For file systems that support file birth (creation) times (such as .Dv UFS2 ) , the birth time will be set to the value of the second element if the second element is older than the currently set birth time. To set both a birth time and a modification time, two calls are required; the first to set the birth time and the second to set the (presumably newer) modification time. Ideally a new system call will be added that allows the setting of all three times at once. If .Fa times is .Dv NULL , this is equivalent to passing a pointer to an array of two timespec structures with both .Va tv_nsec fields set to .Dv UTIME_NOW . .Pp If both .Va tv_nsec fields are .Dv UTIME_OMIT , the timestamps remain unchanged and no permissions are needed for the file itself, although search permissions may be required for the path prefix. The call may or may not succeed if the named file does not exist. .Pp If both .Va tv_nsec fields are .Dv UTIME_NOW , the caller must be the owner of the file, have permission to write the file, or be the super-user. .Pp For all other values of the timestamps, the caller must be the owner of the file or be the super-user. .Pp The values for the .Fa flag argument of the .Fn utimensat system call are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : .Bl -tag -width indent .It Dv AT_SYMLINK_NOFOLLOW If .Fa path names a symbolic link, the symbolic link's times are changed. By default, .Fn utimensat changes the times of the file referenced by the symbolic link. .It Dv AT_BENEATH Only allow to change the times of a file which is beneath of the topping directory. See the description of the .Dv O_BENEATH flag in the .Xr open 2 manual page. .El .Sh RETURN VALUES .Rv -std .Sh COMPATIBILITY If the running kernel does not support this system call, a wrapper emulates it using .Xr fstatat 2 , .Xr futimesat 2 and .Xr lutimes 2 . As a result, timestamps will be rounded down to the nearest microsecond, .Dv UTIME_OMIT is not atomic and .Dv AT_SYMLINK_NOFOLLOW is not available with a path relative to a file descriptor. .Sh ERRORS These system calls will fail if: .Bl -tag -width Er .It Bq Er EACCES The .Fa times argument is .Dv NULL , or both .Va tv_nsec values are .Dv UTIME_NOW , and the effective user ID of the process does not match the owner of the file, and is not the super-user, and write access is denied. .It Bq Er EFAULT The .Fa times argument points outside the process's allocated address space. .It Bq Er EINVAL The .Va tv_nsec component of at least one of the values specified by the .Fa times argument has a value less than 0 or greater than 999999999 and is not equal to .Dv UTIME_NOW or .Dv UTIME_OMIT . .It Bq Er EIO An I/O error occurred while reading or writing the affected inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er EPERM The .Fa times argument is not .Dv NULL nor are both .Va tv_nsec values .Dv UTIME_NOW , nor are both .Va tv_nsec values .Dv UTIME_OMIT and the calling process's effective user ID does not match the owner of the file and is not the super-user. .It Bq Er EPERM The named file has its immutable or append-only flag set, see the .Xr chflags 2 manual page for more information. .It Bq Er EROFS The file system containing the file is mounted read-only. .El .Pp The .Fn futimens system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument does not refer to a valid descriptor. .El .Pp The .Fn utimensat system call will fail if: .Bl -tag -width Er .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor. .It Bq Er EFAULT The .Fa path argument points outside the process's allocated address space. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er ENAMETOOLONG A component of a pathname exceeded .Dv NAME_MAX characters, or an entire path name exceeded .Dv PATH_MAX characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .It Bq Er ENOTCAPABLE .Fa path is an absolute path, or contained a ".." component leading to a directory outside of the directory hierarchy specified by .Fa fd , and the process is in capability mode. .It Bq Er ENOTCAPABLE The .Dv AT_BENEATH flag was provided to .Fn utimensat , and the absolute .Fa path does not have its tail fully contained under the topping directory, or the relative .Fa path escapes it. .El .Sh SEE ALSO .Xr chflags 2 , .Xr stat 2 , .Xr symlink 2 , .Xr utimes 2 , .Xr utime 3 , .Xr symlink 7 .Sh STANDARDS The .Fn futimens and .Fn utimensat system calls are expected to conform to .St -p1003.1-2008 . .Sh HISTORY The .Fn futimens and .Fn utimensat system calls appeared in .Fx 10.3 . Index: head/lib/libc/sys/utimes.2 =================================================================== --- head/lib/libc/sys/utimes.2 (revision 359464) +++ head/lib/libc/sys/utimes.2 (revision 359465) @@ -1,262 +1,264 @@ .\" $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)utimes.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 9, 2016 +.Dd March 30, 2020 .Dt UTIMES 2 .Os .Sh NAME .Nm utimes , .Nm lutimes , .Nm futimes , .Nm futimesat .Nd set file access and modification times .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/time.h .Ft int .Fn utimes "const char *path" "const struct timeval *times" .Ft int .Fn lutimes "const char *path" "const struct timeval *times" .Ft int .Fn futimes "int fd" "const struct timeval *times" .Ft int .Fn futimesat "int fd" "const char *path" "const struct timeval times[2]" .Sh DESCRIPTION .Bf -symbolic These interfaces are obsoleted by .Xr futimens 2 and .Xr utimensat 2 because they are not accurate to nanoseconds. .Ef .Pp The access and modification times of the file named by .Fa path or referenced by .Fa fd are changed as specified by the argument .Fa times . .Pp If .Fa times is .Dv NULL , the access and modification times are set to the current time. The caller must be the owner of the file, have permission to write the file, or be the super-user. .Pp If .Fa times is .No non- Ns Dv NULL , it is assumed to point to an array of two timeval structures. The access time is set to the value of the first element, and the modification time is set to the value of the second element. For file systems that support file birth (creation) times (such as .Dv UFS2 ) , the birth time will be set to the value of the second element if the second element is older than the currently set birth time. To set both a birth time and a modification time, two calls are required; the first to set the birth time and the second to set the (presumably newer) modification time. Ideally a new system call will be added that allows the setting of all three times at once. The caller must be the owner of the file or be the super-user. .Pp In either case, the inode-change-time of the file is set to the current time. .Pp The .Fn lutimes system call is like .Fn utimes except in the case where the named file is a symbolic link, in which case .Fn lutimes changes the access and modification times of the link, while .Fn utimes changes the times of the file the link references. .Pp The .Fn futimesat system call is equivalent to .Fn utimes except in the case where .Fa path specifies a relative path. In this case the access and modification time is set to that of a file relative to the directory associated with the file descriptor .Fa fd instead of the current working directory. If .Fn futimesat is passed the special value .Dv AT_FDCWD in the .Fa fd parameter, the current working directory is used and the behavior is identical to a call to .Fn utimes . .Sh RETURN VALUES .Rv -std .Sh ERRORS All of the system call will fail if: .Bl -tag -width Er .It Bq Er EACCES Search permission is denied for a component of the path prefix. .It Bq Er EACCES The .Fa times argument is .Dv NULL and the effective user ID of the process does not match the owner of the file, and is not the super-user, and write access is denied. .It Bq Er EFAULT The .Fa path or .Fa times argument points outside the process's allocated address space. .It Bq Er EFAULT The .Fa times argument points outside the process's allocated address space. .It Bq Er EINVAL The .Va tv_usec component of at least one of the values specified by the .Fa times argument has a value less than 0 or greater than 999999. .It Bq Er EIO An I/O error occurred while reading or writing the affected inode. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the file system. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er ENAMETOOLONG A component of a pathname exceeded .Dv NAME_MAX characters, or an entire path name exceeded .Dv PATH_MAX characters. .It Bq Er ENOENT The named file does not exist. .It Bq Er ENOTDIR A component of the path prefix is not a directory. .It Bq Er EPERM The .Fa times argument is not .Dv NULL and the calling process's effective user ID does not match the owner of the file and is not the super-user. .It Bq Er EPERM The named file has its immutable or append-only flags set. See the .Xr chflags 2 manual page for more information. .It Bq Er EROFS The file system containing the file is mounted read-only. .El .Pp The .Fn futimes system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument does not refer to a valid descriptor. .El .Pp In addition to the errors returned by the .Fn utimes , the .Fn futimesat may fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa path argument does not specify an absolute path and the .Fa fd argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. .It Bq Er ENOTDIR The .Fa path argument is not an absolute path and .Fa fd is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. .El .Sh SEE ALSO .Xr chflags 2 , .Xr stat 2 , .Xr utimensat 2 , .Xr utime 3 .Sh STANDARDS The .Fn utimes function is expected to conform to .St -xpg4.2 . The .Fn futimesat system call follows The Open Group Extended API Set 2 specification but was replaced by .Fn utimensat in .St -p1003.1-2008 . .Sh HISTORY The .Fn utimes system call appeared in .Bx 4.2 . The .Fn futimes and .Fn lutimes system calls first appeared in .Fx 3.0 . The .Fn futimesat system call appeared in .Fx 8.0 . Index: head/lib/libc/sys/write.2 =================================================================== --- head/lib/libc/sys/write.2 (revision 359464) +++ head/lib/libc/sys/write.2 (revision 359465) @@ -1,290 +1,296 @@ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" -.Dd December 1, 2017 +.Dd March 30, 2020 .Dt WRITE 2 .Os .Sh NAME .Nm write , .Nm writev , .Nm pwrite , .Nm pwritev .Nd write output .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In unistd.h .Ft ssize_t .Fn write "int fd" "const void *buf" "size_t nbytes" .Ft ssize_t .Fn pwrite "int fd" "const void *buf" "size_t nbytes" "off_t offset" .In sys/uio.h .Ft ssize_t .Fn writev "int fd" "const struct iovec *iov" "int iovcnt" .Ft ssize_t .Fn pwritev "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset" .Sh DESCRIPTION The .Fn write system call attempts to write .Fa nbytes of data to the object referenced by the descriptor .Fa fd from the buffer pointed to by .Fa buf . The .Fn writev system call performs the same action, but gathers the output data from the .Fa iovcnt buffers specified by the members of the .Fa iov array: iov[0], iov[1], ..., iov[iovcnt\|-\|1]. The .Fn pwrite and .Fn pwritev system calls perform the same functions, but write to the specified position in the file without modifying the file pointer. .Pp For .Fn writev and .Fn pwritev , the .Fa iovec structure is defined as: .Pp .Bd -literal -offset indent -compact struct iovec { void *iov_base; /* Base address. */ size_t iov_len; /* Length. */ }; .Ed .Pp Each .Fa iovec entry specifies the base address and length of an area in memory from which data should be written. The .Fn writev system call will always write a complete area before proceeding to the next. .Pp On objects capable of seeking, the .Fn write starts at a position given by the pointer associated with .Fa fd , see .Xr lseek 2 . Upon return from .Fn write , the pointer is incremented by the number of bytes which were written. .Pp Objects that are not capable of seeking always write from the current position. The value of the pointer associated with such an object is undefined. .Pp If the real user is not the super-user, then .Fn write clears the set-user-id bit on a file. This prevents penetration of system security by a user who .Dq captures a writable set-user-id file owned by the super-user. .Pp When using non-blocking I/O on objects such as sockets that are subject to flow control, .Fn write and .Fn writev may write fewer bytes than requested; the return value must be noted, and the remainder of the operation should be retried when possible. .Sh RETURN VALUES Upon successful completion the number of bytes which were written is returned. Otherwise a -1 is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS The .Fn write , .Fn writev , .Fn pwrite and .Fn pwritev system calls will fail and the file pointer will remain unchanged if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid descriptor open for writing. .It Bq Er EPIPE An attempt is made to write to a pipe that is not open for reading by any process. .It Bq Er EPIPE An attempt is made to write to a socket of type .Dv SOCK_STREAM that is not connected to a peer socket. .It Bq Er EFBIG An attempt was made to write a file that exceeds the process's file size limit or the maximum file size. .It Bq Er EFAULT Part of .Fa iov or data to be written to the file points outside the process's allocated address space. .It Bq Er EINVAL The pointer associated with .Fa fd was negative. .It Bq Er ENOSPC There is no free space remaining on the file system containing the file. .It Bq Er EDQUOT The user's quota of disk blocks on the file system containing the file has been exhausted. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. .It Bq Er EINTR A signal interrupted the write before it could be completed. .It Bq Er EAGAIN The file was marked for non-blocking I/O, and no data could be written immediately. .It Bq Er EROFS An attempt was made to write over a disk label area at the beginning of a slice. Use .Xr disklabel 8 .Fl W to enable writing on the disk label area. .It Bq Er EINVAL The value .Fa nbytes is greater than .Dv SSIZE_MAX (or greater than .Dv INT_MAX , if the sysctl .Va debug.iosize_max_clamp is non-zero). +.It Bq Er EINTEGRITY +The backing store for +.Fa fd +detected corrupted data while reading. +(For example, writing a partial filesystem block may require first reading +the existing block which may trigger this error.) .El .Pp In addition, .Fn writev and .Fn pwritev may return one of the following errors: .Bl -tag -width Er .It Bq Er EDESTADDRREQ The destination is no longer available when writing to a .Ux domain datagram socket on which .Xr connect 2 had been used to set a destination address. .It Bq Er EINVAL The .Fa iovcnt argument was less than or equal to 0, or greater than .Dv IOV_MAX . .It Bq Er EINVAL One of the .Fa iov_len values in the .Fa iov array was negative. .It Bq Er EINVAL The sum of the .Fa iov_len values in the .Fa iov array overflowed a 32-bit integer. .It Bq Er ENOBUFS The mbuf pool has been completely exhausted when writing to a socket. .El .Pp The .Fn pwrite and .Fn pwritev system calls may also return the following errors: .Bl -tag -width Er .It Bq Er EINVAL The .Fa offset value was negative. .It Bq Er ESPIPE The file descriptor is associated with a pipe, socket, or FIFO. .El .Sh SEE ALSO .Xr fcntl 2 , .Xr lseek 2 , .Xr open 2 , .Xr pipe 2 , .Xr select 2 .Sh STANDARDS The .Fn write system call is expected to conform to .St -p1003.1-90 . The .Fn writev and .Fn pwrite system calls are expected to conform to .St -xpg4.2 . .Sh HISTORY The .Fn pwritev system call appeared in .Fx 6.0 . The .Fn pwrite function appeared in .At V.4 . The .Fn writev system call appeared in .Bx 4.2 . The .Fn write function appeared in .At v1 . Index: head/share/man/man9/VOP_COPY_FILE_RANGE.9 =================================================================== --- head/share/man/man9/VOP_COPY_FILE_RANGE.9 (revision 359464) +++ head/share/man/man9/VOP_COPY_FILE_RANGE.9 (revision 359465) @@ -1,141 +1,143 @@ .\" SPDX-License-Identifier: BSD-2-Clause .\" .\" Copyright (c) 2019 Rick Macklem .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd November 9, 2019 +.Dd March 30, 2020 .Dt VOP_COPY_FILE_RANGE 9 .Os .Sh NAME .Nm VOP_COPY_FILE_RANGE .Nd copy a byte range from one file to another or within one file in a single file system .Sh SYNOPSIS .In sys/param.h .In sys/vnode.h .Ft int .Fo VOP_COPY_FILE_RANGE .Fa "struct vnode *invp" .Fa "off_t *inoff" .Fa "struct vnode *outvp" .Fa "off_t *outoff" .Fa "size_t *len" .Fa "unsigned int flags" .Fa "struct ucred *incred" .Fa "struct ucred *outcred" .Fa "struct thread *fsize_td" .Sh DESCRIPTION This entry point copies a byte range from one regular file to another or within one file in a single file system. .Fa invp and .Fa outvp can refer to the same file. For this case, the byte ranges defined by .Fa *inoff , .Fa *outoff and .Fa *len will not overlap. .Pp The arguments are: .Bl -tag -width ioflag .It Fa invp The vnode of the input file. .It Fa inoff A pointer to the file offset for the input file. .It Fa outvp The vnode of the output file. .It Fa outoff A pointer to the file offset for the output file. .It Fa len A pointer to the byte count for the copy. .It Fa flags Flags, should be set to 0 for now. .It Fa incred The credentials used to read .Fa invp . .It Fa outcred The credentials used to write .Fa outvp . .It Fa fsize_td The thread pointer to be passed to vn_rlimit_fsize(). This will be .Dv NULL for a server thread without limits, such as for the NFS server or .Dv curthread otherwise. .El .Pp On entry and on return, the .Fa inoff and .Fa outoff arguments point to the locations of the file offsets. These file offsets should be updated by the number of bytes copied. The .Fa len argument points to the location that stores the number of bytes to be copied. Upon a successful return .Fa len will be updated to the number of bytes actually copied. Normally, this will be the number of bytes requested to be copied, however a copy of fewer bytes than requested is permitted. This does not necessarily indicate that the copy reached EOF on the input file. However, if the value pointed to by the .Fa len argument is zero upon a successful return, it indicates that the offset pointed to by .Fa inoff is at or beyond EOF on the input file. .Sh LOCKS The vnode are unlocked on entry and must be unlocked on return. The byte ranges for both .Fa invp and .Fa outvp should be range locked when this call is done. .Sh RETURN VALUES Zero is returned on success, otherwise an error code is returned. .Sh ERRORS .Bl -tag -width Er .It Bq Er EFBIG If the copy exceeds the process's file size limit or the maximum file size for the file system .Fa invp and .Fa outvp reside on. .It Bq Er EINTR A signal interrupted the VOP call before it could be completed. .It Bq Er EIO An I/O error occurred while reading/writing the files. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading/writing the files. .It Bq Er ENOSPC The file system is full. .El .Sh SEE ALSO .Xr vn_rdwr 9 , .Xr vnode 9 Index: head/share/man/man9/VOP_READDIR.9 =================================================================== --- head/share/man/man9/VOP_READDIR.9 (revision 359464) +++ head/share/man/man9/VOP_READDIR.9 (revision 359465) @@ -1,108 +1,110 @@ .\" -*- nroff -*- .\" .\" Copyright (c) 1996 Doug Rabson .\" .\" All rights reserved. .\" .\" This program is free software. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd July 24, 1996 +.Dd March 30, 2020 .Dt VOP_READDIR 9 .Os .Sh NAME .Nm VOP_READDIR .Nd read contents of a directory .Sh SYNOPSIS .In sys/param.h .In sys/dirent.h .In sys/vnode.h .Ft int .Fn VOP_READDIR "struct vnode *vp" "struct uio *uio" "struct ucred *cred" "int *eofflag" "int *ncookies" "u_long **cookies" .Sh DESCRIPTION Read directory entries. .Bl -tag -width ncookies .It Fa vp The vnode of the directory. .It Fa uio Where to read the directory contents. .It Fa cred The caller's credentials. .It Fa eofflag Return end of file status .Dv ( NULL if not wanted). .It Fa ncookies Number of directory cookies generated for NFS .Dv ( NULL if not wanted). .It Fa cookies Directory seek cookies generated for NFS .Dv ( NULL if not wanted). .El The directory contents are read into .Vt struct dirent structures. If the on-disc data structures differ from this then they should be translated. .Sh LOCKS The directory should be locked on entry and will still be locked on exit. .Sh RETURN VALUES Zero is returned on success, otherwise an error code is returned. .Pp If this is called from the NFS server, the extra arguments .Fa eofflag , .Fa ncookies and .Fa cookies are given. The value of .Fa *eofflag should be set to TRUE if the end of the directory is reached while reading. The directory seek cookies are returned to the NFS client and may be used later to restart a directory read part way through the directory. There should be one cookie returned per directory entry. The value of the cookie should be the offset within the directory where the on-disc version of the appropriate directory entry starts. Memory for the cookies should be allocated using: .Bd -literal ...; *ncookies = number of entries read; *cookies = malloc(*ncookies * sizeof(u_long), M_TEMP, M_WAITOK); .Ed .Sh ERRORS .Bl -tag -width Er .It Bq Er EINVAL An attempt was made to read from an illegal offset in the directory. .It Bq Er EIO A read error occurred while reading the directory. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading the directory. .El .Sh SEE ALSO .Xr vnode 9 .Sh AUTHORS This manual page was written by .An Doug Rabson . Index: head/share/man/man9/VOP_READLINK.9 =================================================================== --- head/share/man/man9/VOP_READLINK.9 (revision 359464) +++ head/share/man/man9/VOP_READLINK.9 (revision 359465) @@ -1,67 +1,69 @@ .\" -*- nroff -*- .\" .\" Copyright (c) 1996 Doug Rabson .\" .\" All rights reserved. .\" .\" This program is free software. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd July 24, 1996 +.Dd March 30, 2020 .Dt VOP_READLINK 9 .Os .Sh NAME .Nm VOP_READLINK .Nd read the target of a symbolic link .Sh SYNOPSIS .In sys/param.h .In sys/vnode.h .In sys/uio.h .Ft int .Fn VOP_READLINK "struct vnode *vp" "struct uio *uio" "struct ucred *cred" .Sh DESCRIPTION This reads the target pathname of a symbolic link .Bl -tag -width uio .It Fa vp The vnode of the symlink. .It Fa uio The location of the data to be read or written. .It Fa cred The credentials of the caller. .El .Sh LOCKS The vnode should be locked on entry and will still be locked on exit. .Sh RETURN VALUES Zero is returned on success, otherwise an error code is returned. .Sh ERRORS .Bl -tag -width Er .It Bq Er EIO A read error occurred while reading the contents of the symlink. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading the contents of the symlink. .El .Sh SEE ALSO .Xr uiomove 9 , .Xr vnode 9 .Sh AUTHORS This manual page was written by .An Doug Rabson . Index: head/share/man/man9/g_data.9 =================================================================== --- head/share/man/man9/g_data.9 (revision 359464) +++ head/share/man/man9/g_data.9 (revision 359465) @@ -1,122 +1,124 @@ .\" .\" Copyright (c) 2004-2005 Pawel Jakub Dawidek .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd January 16, 2004 +.Dd March 30, 2020 .Dt G_DATA 9 .Os .Sh NAME .Nm g_read_data , .Nm g_write_data .Nd "read/write data from/to GEOM consumer" .Sh SYNOPSIS .In geom/geom.h .Ft "void *" .Fo g_read_data .Fa "struct g_consumer *cp" "off_t offset" "off_t length" "int *error" .Fc .Ft int .Fo g_write_data .Fa "struct g_consumer *cp" "off_t offset" "void *ptr" "off_t length" .Fc .Sh DESCRIPTION The .Fn g_read_data function reads .Fa length bytes of data from the provider attached to consumer .Fa cp , starting at offset .Fa offset . The buffer returned from .Fn g_read_data is allocated with .Fn g_malloc , so it should be freed by the caller with .Fn g_free after use. If the operation fails, an error value will be stored in the .Fa error argument if it is not .Dv NULL . .Pp The .Fn g_write_data function writes .Fa length bytes of data from the buffer pointed to by .Fa ptr to the provider attached to consumer .Fa cp , starting at offset .Fa offset . .Sh RESTRICTIONS/CONDITIONS The .Fa length argument should be a multiple of the provider's sectorsize and less than or equal to .Dv DFLTPHYS .Dv ( DFLTPHYS is defined in .In sys/param.h ) . .Pp The topology lock must not be held. .Sh RETURN VALUES The .Fn g_read_data function returns a pointer to a data buffer or .Dv NULL if an error occurred. In that case an error value is stored in the .Fa error argument unless it is .Dv NULL . .Pp The .Fn g_write_data function returns 0 if successful; otherwise an error code is returned. .Sh ERRORS Possible errors: .Bl -tag -width Er .It Bq Er EIO An I/O error occurred while reading from or writing to the consumer. +.It Bq Er EINTEGRITY +Corrupted data was detected while reading from the consumer. .El .Sh SEE ALSO .Xr geom 4 , .Xr DECLARE_GEOM_CLASS 9 , .Xr g_access 9 , .Xr g_attach 9 , .Xr g_bio 9 , .Xr g_consumer 9 , .Xr g_event 9 , .Xr g_geom 9 , .Xr g_provider 9 , .Xr g_provider_by_name 9 , .Xr g_wither_geom 9 .Sh AUTHORS .An -nosplit This manual page was written by .An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .