1994-05-27 05:00:24 +00:00
|
|
|
.\" 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.
|
2017-02-28 23:42:47 +00:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1994-05-27 05:00:24 +00:00
|
|
|
.\" 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
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-27 05:00:24 +00:00
|
|
|
.\"
|
vfs: add restrictions to read(2) of a directory [1/2]
Historically, we've allowed read() of a directory and some filesystems will
accommodate (e.g. ufs/ffs, msdosfs). From the history department staffed by
Warner: <<EOF
pdp-7 unix seemed to allow reading directories, but they were weird, special
things there so I'm unsure (my pdp-7 assembler sucks).
1st Edition's sources are lost, mostly. The kernel allows it. The
reconstructed sources from 2nd or 3rd edition read it though.
V6 to V7 changed the filesystem format, and should have been a warning, but
reading directories weren't materially changed.
4.1b BSD introduced readdir because of UFS. UFS broke all directory reading
programs in 1983. ls, du, find, etc all had to be rewritten. readdir() and
friends were introduced here.
SysVr3 picked up readdir() in 1987 for the AT&T fork of Unix. SysVr4 updated
all the directory reading programs in 1988 because different filesystem
types were introduced.
In the 90s, these interfaces became completely ubiquitous as PDP-11s running
V7 faded from view and all the folks that initially started on V7 upgraded
to SysV. Linux never supported this (though I've not done the software
archeology to check) because it has always had a pathological diversity of
filesystems.
EOF
Disallowing read(2) on a directory has the side-effect of masking
application bugs from relying on other implementation's behavior
(e.g. Linux) of rejecting these with EISDIR across the board, but allowing
it has been a vector for at least one stack disclosure bug in the past[0].
By POSIX, this is implementation-defined whether read() handles directories
or not. Popular implementations have chosen to reject them, and this seems
sensible: the data you're reading from a directory is not structured in some
unified way across filesystem implementations like with readdir(2), so it is
impossible for applications to portably rely on this.
With this patch, we will reject most read(2) of a dirfd with EISDIR. Users
that know what they're doing can conscientiously set
bsd.security.allow_read_dir=1 to allow read(2) of directories, as it has
proven useful for debugging or recovery. A future commit will further limit
the sysctl to allow only the system root to read(2) directories, to make it
at least relatively safe to leave on for longer periods of time.
While we're adding logic pertaining to directory vnodes to vn_io_fault, an
additional assertion has also been added to ensure that we're not reaching
vn_io_fault with any write request on a directory vnode. Such request would
be a logical error in the kernel, and must be debugged rather than allowing
it to potentially silently error out.
Commented out shell aliases have been placed in root's chsrc/shrc to promote
awareness that grep may become noisy after this change, depending on your
usage.
A tentative MFC plan has been put together to try and make it as trivial as
possible to identify issues and collect reports; note that this will be
strongly re-evaluated. Tentatively, I will MFC this knob with the default as
it is in HEAD to improve our odds of actually getting reports. The future
priv(9) to further restrict the sysctl WILL NOT BE MERGED BACK, so the knob
will be a faithful reversion on stable/12. We will go into the merge
acknowledging that the sysctl default may be flipped back to restore
historical behavior at *any* point if it's warranted.
[0] https://www.freebsd.org/security/advisories/FreeBSD-SA-19:10.ufs.asc
PR: 246412
Reviewed by: mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by: rgrimes (latest version)
MFC after: 1 month (note the MFC plan mentioned above)
Relnotes: absolutely, but will amend previous RELNOTES entry
Differential Revision: https://reviews.freebsd.org/D24596
2020-06-04 18:09:55 +00:00
|
|
|
.Dd June 4, 2020
|
1994-05-27 05:00:24 +00:00
|
|
|
.Dt READ 2
|
2001-07-10 13:41:46 +00:00
|
|
|
.Os
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm read ,
|
1999-04-11 21:14:40 +00:00
|
|
|
.Nm readv ,
|
2005-07-07 18:17:55 +00:00
|
|
|
.Nm pread ,
|
|
|
|
.Nm preadv
|
1994-05-27 05:00:24 +00:00
|
|
|
.Nd read input
|
2000-04-21 09:42:15 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In unistd.h
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ft ssize_t
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fn read "int fd" "void *buf" "size_t nbytes"
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ft ssize_t
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fn pread "int fd" "void *buf" "size_t nbytes" "off_t offset"
|
2012-01-22 11:15:48 +00:00
|
|
|
.In sys/uio.h
|
2005-07-07 18:17:55 +00:00
|
|
|
.Ft ssize_t
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fn readv "int fd" "const struct iovec *iov" "int iovcnt"
|
1999-04-11 21:14:40 +00:00
|
|
|
.Ft ssize_t
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fn preadv "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset"
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
|
|
|
.Fn read
|
|
|
|
system call
|
1994-05-27 05:00:24 +00:00
|
|
|
attempts to read
|
|
|
|
.Fa nbytes
|
|
|
|
of data from the object referenced by the descriptor
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fa fd
|
1994-05-27 05:00:24 +00:00
|
|
|
into the buffer pointed to by
|
|
|
|
.Fa buf .
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
|
|
|
.Fn readv
|
|
|
|
system call
|
1994-05-27 05:00:24 +00:00
|
|
|
performs the same action, but scatters the input data
|
2001-07-15 07:53:42 +00:00
|
|
|
into the
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa iovcnt
|
|
|
|
buffers specified by the members of the
|
|
|
|
.Fa iov
|
|
|
|
array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1].
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
|
|
|
.Fn pread
|
2005-07-07 18:17:55 +00:00
|
|
|
and
|
|
|
|
.Fn preadv
|
|
|
|
system calls
|
|
|
|
perform the same functions, but read from the specified position in
|
1999-04-11 21:14:40 +00:00
|
|
|
the file without modifying the file pointer.
|
1994-05-27 05:00:24 +00:00
|
|
|
.Pp
|
2001-07-15 07:53:42 +00:00
|
|
|
For
|
2005-07-07 18:17:55 +00:00
|
|
|
.Fn readv
|
|
|
|
and
|
|
|
|
.Fn preadv ,
|
2001-07-15 07:53:42 +00:00
|
|
|
the
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa iovec
|
|
|
|
structure is defined as:
|
|
|
|
.Pp
|
|
|
|
.Bd -literal -offset indent -compact
|
|
|
|
struct iovec {
|
2003-01-12 15:18:47 +00:00
|
|
|
void *iov_base; /* Base address. */
|
1997-01-30 22:39:40 +00:00
|
|
|
size_t iov_len; /* Length. */
|
1994-05-27 05:00:24 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2001-07-15 07:53:42 +00:00
|
|
|
Each
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa iovec
|
|
|
|
entry specifies the base address and length of an area
|
2001-07-15 07:53:42 +00:00
|
|
|
in memory where data should be placed.
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
|
|
|
.Fn readv
|
|
|
|
system call
|
1994-05-27 05:00:24 +00:00
|
|
|
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
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fa fd
|
1994-05-27 05:00:24 +00:00
|
|
|
(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
|
2004-07-02 23:52:20 +00:00
|
|
|
position.
|
|
|
|
The value of the pointer associated with such an
|
1994-05-27 05:00:24 +00:00
|
|
|
object is undefined.
|
|
|
|
.Pp
|
|
|
|
Upon successful completion,
|
1999-04-11 21:14:40 +00:00
|
|
|
.Fn read ,
|
|
|
|
.Fn readv ,
|
|
|
|
.Fn pread
|
2005-07-07 18:17:55 +00:00
|
|
|
and
|
|
|
|
.Fn preadv
|
1994-05-27 05:00:24 +00:00
|
|
|
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.
|
2019-07-06 20:31:37 +00:00
|
|
|
.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.
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
If successful, the
|
2000-03-02 09:14:21 +00:00
|
|
|
number of bytes actually read is returned.
|
|
|
|
Upon reading end-of-file,
|
1994-05-27 05:00:24 +00:00
|
|
|
zero is returned.
|
|
|
|
Otherwise, a -1 is returned and the global variable
|
|
|
|
.Va errno
|
|
|
|
is set to indicate the error.
|
|
|
|
.Sh ERRORS
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
|
|
|
.Fn read ,
|
1999-04-11 21:14:40 +00:00
|
|
|
.Fn readv ,
|
|
|
|
.Fn pread
|
2005-07-07 18:17:55 +00:00
|
|
|
and
|
|
|
|
.Fn preadv
|
2002-12-18 09:22:32 +00:00
|
|
|
system calls
|
1994-05-27 05:00:24 +00:00
|
|
|
will succeed unless:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EBADF
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fa fd
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
1994-05-27 05:00:24 +00:00
|
|
|
is not a valid file or socket descriptor open for reading.
|
2005-07-29 07:42:10 +00:00
|
|
|
.It Bq Er ECONNRESET
|
|
|
|
The
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fa fd
|
2005-07-29 07:42:10 +00:00
|
|
|
argument refers to a socket, and the remote socket end is
|
|
|
|
forcibly closed.
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Bq Er EFAULT
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
|
|
|
.Fa buf
|
|
|
|
argument
|
1994-05-27 05:00:24 +00:00
|
|
|
points outside the allocated address space.
|
|
|
|
.It Bq Er EIO
|
|
|
|
An I/O error occurred while reading from the file system.
|
2020-03-30 21:44:00 +00:00
|
|
|
.It Bq Er EINTEGRITY
|
|
|
|
Corrupted data was detected while reading from the file system.
|
2012-04-29 22:23:00 +00:00
|
|
|
.It Bq Er EBUSY
|
|
|
|
Failed to read from a file, e.g. /proc/<pid>/regs while <pid> is not stopped
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Bq Er EINTR
|
2006-10-11 13:33:02 +00:00
|
|
|
A read from a slow device
|
2006-10-21 18:03:53 +00:00
|
|
|
(i.e.\& one that might block for an arbitrary amount of time)
|
2006-10-11 13:33:02 +00:00
|
|
|
was interrupted by the delivery of a signal
|
|
|
|
before any data arrived.
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
The pointer associated with
|
2013-09-12 00:53:38 +00:00
|
|
|
.Fa fd
|
1994-05-27 05:00:24 +00:00
|
|
|
was negative.
|
|
|
|
.It Bq Er EAGAIN
|
|
|
|
The file was marked for non-blocking I/O,
|
|
|
|
and no data were ready to be read.
|
2003-09-02 16:50:17 +00:00
|
|
|
.It Bq Er EISDIR
|
vfs: add restrictions to read(2) of a directory [1/2]
Historically, we've allowed read() of a directory and some filesystems will
accommodate (e.g. ufs/ffs, msdosfs). From the history department staffed by
Warner: <<EOF
pdp-7 unix seemed to allow reading directories, but they were weird, special
things there so I'm unsure (my pdp-7 assembler sucks).
1st Edition's sources are lost, mostly. The kernel allows it. The
reconstructed sources from 2nd or 3rd edition read it though.
V6 to V7 changed the filesystem format, and should have been a warning, but
reading directories weren't materially changed.
4.1b BSD introduced readdir because of UFS. UFS broke all directory reading
programs in 1983. ls, du, find, etc all had to be rewritten. readdir() and
friends were introduced here.
SysVr3 picked up readdir() in 1987 for the AT&T fork of Unix. SysVr4 updated
all the directory reading programs in 1988 because different filesystem
types were introduced.
In the 90s, these interfaces became completely ubiquitous as PDP-11s running
V7 faded from view and all the folks that initially started on V7 upgraded
to SysV. Linux never supported this (though I've not done the software
archeology to check) because it has always had a pathological diversity of
filesystems.
EOF
Disallowing read(2) on a directory has the side-effect of masking
application bugs from relying on other implementation's behavior
(e.g. Linux) of rejecting these with EISDIR across the board, but allowing
it has been a vector for at least one stack disclosure bug in the past[0].
By POSIX, this is implementation-defined whether read() handles directories
or not. Popular implementations have chosen to reject them, and this seems
sensible: the data you're reading from a directory is not structured in some
unified way across filesystem implementations like with readdir(2), so it is
impossible for applications to portably rely on this.
With this patch, we will reject most read(2) of a dirfd with EISDIR. Users
that know what they're doing can conscientiously set
bsd.security.allow_read_dir=1 to allow read(2) of directories, as it has
proven useful for debugging or recovery. A future commit will further limit
the sysctl to allow only the system root to read(2) directories, to make it
at least relatively safe to leave on for longer periods of time.
While we're adding logic pertaining to directory vnodes to vn_io_fault, an
additional assertion has also been added to ensure that we're not reaching
vn_io_fault with any write request on a directory vnode. Such request would
be a logical error in the kernel, and must be debugged rather than allowing
it to potentially silently error out.
Commented out shell aliases have been placed in root's chsrc/shrc to promote
awareness that grep may become noisy after this change, depending on your
usage.
A tentative MFC plan has been put together to try and make it as trivial as
possible to identify issues and collect reports; note that this will be
strongly re-evaluated. Tentatively, I will MFC this knob with the default as
it is in HEAD to improve our odds of actually getting reports. The future
priv(9) to further restrict the sysctl WILL NOT BE MERGED BACK, so the knob
will be a faithful reversion on stable/12. We will go into the merge
acknowledging that the sysctl default may be flipped back to restore
historical behavior at *any* point if it's warranted.
[0] https://www.freebsd.org/security/advisories/FreeBSD-SA-19:10.ufs.asc
PR: 246412
Reviewed by: mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by: rgrimes (latest version)
MFC after: 1 month (note the MFC plan mentioned above)
Relnotes: absolutely, but will amend previous RELNOTES entry
Differential Revision: https://reviews.freebsd.org/D24596
2020-06-04 18:09:55 +00:00
|
|
|
The file descriptor is associated with a directory.
|
vfs: add restrictions to read(2) of a directory [2/2]
This commit adds the priv(9) that waters down the sysctl to make it only
allow read(2) of a dirfd by the system root. Jailed root is not allowed, but
jail policy and superuser policy will abstain from allowing/denying it so
that a MAC module can fully control the policy.
Such a MAC module has been written, and can be found at:
https://people.freebsd.org/~kevans/mac_read_dir-0.1.0.tar.gz
It is expected that the MAC module won't be needed by many, as most only
need to do such diagnostics that require this behavior as system root
anyways. Interested parties are welcome to grab the MAC module above and
create a port or locally integrate it, and with enough support it could see
introduction to base. As noted in mac_read_dir.c, it is released under the
BSD 2 clause license and allows the restrictions to be lifted for only
jailed root or for all unprivileged users.
PR: 246412
Reviewed by: mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by: rgrimes (latest version)
Differential Revision: https://reviews.freebsd.org/D24596
2020-06-04 18:17:25 +00:00
|
|
|
Directories may only be read directly by root if the filesystem supports it and
|
vfs: add restrictions to read(2) of a directory [1/2]
Historically, we've allowed read() of a directory and some filesystems will
accommodate (e.g. ufs/ffs, msdosfs). From the history department staffed by
Warner: <<EOF
pdp-7 unix seemed to allow reading directories, but they were weird, special
things there so I'm unsure (my pdp-7 assembler sucks).
1st Edition's sources are lost, mostly. The kernel allows it. The
reconstructed sources from 2nd or 3rd edition read it though.
V6 to V7 changed the filesystem format, and should have been a warning, but
reading directories weren't materially changed.
4.1b BSD introduced readdir because of UFS. UFS broke all directory reading
programs in 1983. ls, du, find, etc all had to be rewritten. readdir() and
friends were introduced here.
SysVr3 picked up readdir() in 1987 for the AT&T fork of Unix. SysVr4 updated
all the directory reading programs in 1988 because different filesystem
types were introduced.
In the 90s, these interfaces became completely ubiquitous as PDP-11s running
V7 faded from view and all the folks that initially started on V7 upgraded
to SysV. Linux never supported this (though I've not done the software
archeology to check) because it has always had a pathological diversity of
filesystems.
EOF
Disallowing read(2) on a directory has the side-effect of masking
application bugs from relying on other implementation's behavior
(e.g. Linux) of rejecting these with EISDIR across the board, but allowing
it has been a vector for at least one stack disclosure bug in the past[0].
By POSIX, this is implementation-defined whether read() handles directories
or not. Popular implementations have chosen to reject them, and this seems
sensible: the data you're reading from a directory is not structured in some
unified way across filesystem implementations like with readdir(2), so it is
impossible for applications to portably rely on this.
With this patch, we will reject most read(2) of a dirfd with EISDIR. Users
that know what they're doing can conscientiously set
bsd.security.allow_read_dir=1 to allow read(2) of directories, as it has
proven useful for debugging or recovery. A future commit will further limit
the sysctl to allow only the system root to read(2) directories, to make it
at least relatively safe to leave on for longer periods of time.
While we're adding logic pertaining to directory vnodes to vn_io_fault, an
additional assertion has also been added to ensure that we're not reaching
vn_io_fault with any write request on a directory vnode. Such request would
be a logical error in the kernel, and must be debugged rather than allowing
it to potentially silently error out.
Commented out shell aliases have been placed in root's chsrc/shrc to promote
awareness that grep may become noisy after this change, depending on your
usage.
A tentative MFC plan has been put together to try and make it as trivial as
possible to identify issues and collect reports; note that this will be
strongly re-evaluated. Tentatively, I will MFC this knob with the default as
it is in HEAD to improve our odds of actually getting reports. The future
priv(9) to further restrict the sysctl WILL NOT BE MERGED BACK, so the knob
will be a faithful reversion on stable/12. We will go into the merge
acknowledging that the sysctl default may be flipped back to restore
historical behavior at *any* point if it's warranted.
[0] https://www.freebsd.org/security/advisories/FreeBSD-SA-19:10.ufs.asc
PR: 246412
Reviewed by: mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by: rgrimes (latest version)
MFC after: 1 month (note the MFC plan mentioned above)
Relnotes: absolutely, but will amend previous RELNOTES entry
Differential Revision: https://reviews.freebsd.org/D24596
2020-06-04 18:09:55 +00:00
|
|
|
the
|
|
|
|
.Dv security.bsd.allow_read_dir
|
|
|
|
sysctl MIB is set to a non-zero value.
|
|
|
|
For most scenarios, the
|
|
|
|
.Xr readdir 3
|
|
|
|
function should be used instead.
|
2003-09-02 16:50:17 +00:00
|
|
|
.It Bq Er EOPNOTSUPP
|
2004-06-30 20:09:10 +00:00
|
|
|
The file descriptor is associated with a file system and file type that
|
2003-09-02 16:50:17 +00:00
|
|
|
do not allow regular read operations on it.
|
2004-01-25 06:24:08 +00:00
|
|
|
.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
|
2004-06-30 20:09:10 +00:00
|
|
|
for this file system.
|
2005-02-10 20:09:01 +00:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
The value
|
|
|
|
.Fa nbytes
|
|
|
|
is greater than
|
|
|
|
.Dv INT_MAX .
|
1994-05-27 05:00:24 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2001-07-15 07:53:42 +00:00
|
|
|
In addition,
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fn readv
|
2005-07-07 18:17:55 +00:00
|
|
|
and
|
|
|
|
.Fn preadv
|
1994-05-27 05:00:24 +00:00
|
|
|
may return one of the following errors:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EINVAL
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
|
|
|
.Fa iovcnt
|
|
|
|
argument
|
2004-06-15 01:24:41 +00:00
|
|
|
was less than or equal to 0, or greater than
|
2004-06-30 20:09:10 +00:00
|
|
|
.Dv IOV_MAX .
|
1994-05-27 05:00:24 +00:00
|
|
|
.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
|
2004-11-15 13:55:33 +00:00
|
|
|
array points outside the process's allocated address space.
|
1994-05-27 05:00:24 +00:00
|
|
|
.El
|
1999-04-11 21:14:40 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn pread
|
2005-07-07 18:17:55 +00:00
|
|
|
and
|
|
|
|
.Fn preadv
|
|
|
|
system calls may also return the following errors:
|
1999-04-11 21:14:40 +00:00
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EINVAL
|
2004-10-25 13:35:03 +00:00
|
|
|
The
|
|
|
|
.Fa offset
|
|
|
|
value was negative.
|
1999-04-11 21:14:40 +00:00
|
|
|
.It Bq Er ESPIPE
|
|
|
|
The file descriptor is associated with a pipe, socket, or FIFO.
|
|
|
|
.El
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr dup 2 ,
|
|
|
|
.Xr fcntl 2 ,
|
2003-09-02 16:50:17 +00:00
|
|
|
.Xr getdirentries 2 ,
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr open 2 ,
|
|
|
|
.Xr pipe 2 ,
|
|
|
|
.Xr select 2 ,
|
|
|
|
.Xr socket 2 ,
|
2003-09-02 16:50:17 +00:00
|
|
|
.Xr socketpair 2 ,
|
|
|
|
.Xr fread 3 ,
|
|
|
|
.Xr readdir 3
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh STANDARDS
|
1996-12-02 20:03:58 +00:00
|
|
|
The
|
|
|
|
.Fn read
|
2002-12-18 09:22:32 +00:00
|
|
|
system call is expected to conform to
|
1996-12-02 20:03:58 +00:00
|
|
|
.St -p1003.1-90 .
|
1999-04-11 21:14:40 +00:00
|
|
|
The
|
|
|
|
.Fn readv
|
|
|
|
and
|
|
|
|
.Fn pread
|
2002-12-18 09:22:32 +00:00
|
|
|
system calls are expected to conform to
|
1999-04-11 21:14:40 +00:00
|
|
|
.St -xpg4.2 .
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2005-07-07 18:17:55 +00:00
|
|
|
.Fn preadv
|
|
|
|
system call appeared in
|
|
|
|
.Fx 6.0 .
|
|
|
|
The
|
1999-04-11 21:14:40 +00:00
|
|
|
.Fn pread
|
2002-12-18 09:22:32 +00:00
|
|
|
function appeared in
|
1999-04-11 21:14:40 +00:00
|
|
|
.At V.4 .
|
|
|
|
The
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fn readv
|
2002-12-18 09:22:32 +00:00
|
|
|
system call appeared in
|
1994-05-27 05:00:24 +00:00
|
|
|
.Bx 4.2 .
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
1996-08-22 23:31:07 +00:00
|
|
|
.Fn read
|
2002-12-18 09:22:32 +00:00
|
|
|
function appeared in
|
2017-12-01 22:26:36 +00:00
|
|
|
.At v1 .
|