PATCH preadv/pwritev
Chuck Tuffli
ctuffli at gmail.com
Thu Apr 27 06:07:47 PDT 2006
Sascha Wildner wrote:
. ..
Chuck,
could you include patches to the read(2) and write(2) man pages as well?
Here you go. The patch was calculated from the src/lib directory.
---chuck
Index: libc/sys/read.2
===================================================================
RCS file: /local/dcvs/src/lib/libc/sys/read.2,v
retrieving revision 1.2
diff -u -r1.2 read.2
--- libc/sys/read.2 17 Jun 2003 04:26:47 -0000 1.2
+++ libc/sys/read.2 25 Apr 2006 22:26:39 -0000
@@ -39,7 +39,8 @@
.Sh NAME
.Nm read ,
.Nm readv ,
-.Nm pread
+.Nm pread ,
+.Nm preadv
.Nd read input
.Sh LIBRARY
.Lb libc
@@ -53,6 +54,8 @@
.Fn readv "int d" "const struct iovec *iov" "int iovcnt"
.Ft ssize_t
.Fn pread "int d" "void *buf" "size_t nbytes" "off_t offset"
+.Ft ssize_t
+.Fn preadv "int d" "const struct iovec *iov" "int iovcnt" "off_t offset"
.Sh DESCRIPTION
.Fn Read
attempts to read
@@ -68,12 +71,17 @@
buffers specified by the members of the
.Fa iov
array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1].
-.Fn Pread
-performs the same function, but reads from the specified position in
+The
+.Fn pread
+and
+.Fn preadv
+calls perform the same function, but read from the specified position in
the file without modifying the file pointer.
.Pp
For
-.Fn readv ,
+.Fn readv
+and
+.Fn preadv ,
the
.Fa iovec
structure is defined as:
@@ -90,6 +98,8 @@
entry specifies the base address and length of an area
in memory where data should be placed.
.Fn Readv
+and
+.Fn preadv
will always fill an area completely before proceeding
to the next.
.Pp
@@ -111,8 +121,9 @@
Upon successful completion,
.Fn read ,
.Fn readv ,
+.Fn pread ,
and
-.Fn pread
+.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
@@ -128,8 +139,9 @@
.Sh ERRORS
.Fn Read ,
.Fn readv ,
+.Fn pread ,
and
-.Fn pread
+.Fn preadv
will succeed unless:
.Bl -tag -width Er
.It Bq Er EBADF
@@ -154,6 +166,8 @@
.Pp
In addition,
.Fn readv
+and
+.Fn preadv
may return one of the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
@@ -179,7 +193,9 @@
.Pp
The
.Fn pread
-call may also return the following errors:
+and
+.Fn preadv
+calls may also return the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The specified file offset is invalid.
Index: libc/sys/write.2
===================================================================
RCS file: /local/dcvs/src/lib/libc/sys/write.2,v
retrieving revision 1.2
diff -u -r1.2 write.2
--- libc/sys/write.2 17 Jun 2003 04:26:47 -0000 1.2
+++ libc/sys/write.2 25 Apr 2006 22:31:34 -0000
@@ -39,7 +39,8 @@
.Sh NAME
.Nm write ,
.Nm writev ,
-.Nm pwrite
+.Nm pwrite ,
+.Nm pwritev
.Nd write output
.Sh LIBRARY
.Lb libc
@@ -53,6 +54,8 @@
.Fn writev "int d" "const struct iovec *iov" "int iovcnt"
.Ft ssize_t
.Fn pwrite "int d" "const void *buf" "size_t nbytes" "off_t offset"
+.Ft ssize_t
+.Fn pwritev "int d" "const struct iovec *iov" "int iovcnt" "off_t offset"
.Sh DESCRIPTION
.Fn Write
attempts to write
@@ -62,18 +65,24 @@
from the buffer pointed to by
.Fa buf .
.Fn Writev
-performs the same action, but gathers the output data
+and
+.Fn pwritev
+perform the same action, but gather the output data
from the
.Fa iovcnt
buffers specified by the members of the
.Fa iov
array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
.Fn Pwrite
-performs the same function, but writes to the specified position in
+and
+.Fn pwritev
+perform the same function, but write to the specified position in
the file without modifying the file pointer.
.Pp
For
-.Fn writev ,
+.Fn writev
+and
+.Fn pwritev ,
the
.Fa iovec
structure is defined as:
@@ -90,6 +99,8 @@
entry specifies the base address and length of an area
in memory from which data should be written.
.Fn Writev
+and
+.Fn pwritev
will always write a complete area before proceeding
to the next.
.Pp
@@ -133,8 +144,9 @@
.Sh ERRORS
.Fn Write ,
.Fn writev ,
+.Fn pwrite ,
and
-.Fn pwrite
+.Fn pwritev
will fail and the file pointer will remain unchanged if:
.Bl -tag -width Er
.It Bq Er EBADF
@@ -183,6 +195,8 @@
.Pp
In addition,
.Fn writev
+and
+.Fn pwritev
may return one of the following errors:
.Bl -tag -width Er
.It Bq Er EDESTADDRREQ
@@ -213,7 +227,9 @@
.Pp
The
.Fn pwrite
-call may also return the following errors:
+and
+.Fn pwritev
+calls may also return the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The specified file offset is invalid.
Index: libcr/sys/read.2
===================================================================
RCS file: /local/dcvs/src/lib/libcr/sys/read.2,v
retrieving revision 1.2
diff -u -r1.2 read.2
--- libcr/sys/read.2 17 Jun 2003 04:26:47 -0000 1.2
+++ libcr/sys/read.2 25 Apr 2006 22:44:12 -0000
@@ -39,7 +39,8 @@
.Sh NAME
.Nm read ,
.Nm readv ,
-.Nm pread
+.Nm pread ,
+.Nm preadv
.Nd read input
.Sh LIBRARY
.Lb libc
@@ -53,6 +54,8 @@
.Fn readv "int d" "const struct iovec *iov" "int iovcnt"
.Ft ssize_t
.Fn pread "int d" "void *buf" "size_t nbytes" "off_t offset"
+.Ft ssize_t
+.Fn preadv "int d" "const struct iovec *iov" "int iovcnt" "off_t offset"
.Sh DESCRIPTION
.Fn Read
attempts to read
@@ -68,12 +71,17 @@
buffers specified by the members of the
.Fa iov
array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1].
-.Fn Pread
-performs the same function, but reads from the specified position in
+The
+.Fn pread
+and
+.Fn preadv
+calls perform the same function, but read from the specified position in
the file without modifying the file pointer.
.Pp
For
-.Fn readv ,
+.Fn readv
+and
+.Fn preadv ,
the
.Fa iovec
structure is defined as:
@@ -90,6 +98,8 @@
entry specifies the base address and length of an area
in memory where data should be placed.
.Fn Readv
+and
+.Fn preadv
will always fill an area completely before proceeding
to the next.
.Pp
@@ -111,8 +121,9 @@
Upon successful completion,
.Fn read ,
.Fn readv ,
+.Fn pread ,
and
-.Fn pread
+.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
@@ -128,8 +139,9 @@
.Sh ERRORS
.Fn Read ,
.Fn readv ,
+.Fn pread ,
and
-.Fn pread
+.Fn preadv
will succeed unless:
.Bl -tag -width Er
.It Bq Er EBADF
@@ -154,6 +166,8 @@
.Pp
In addition,
.Fn readv
+and
+.Fn preadv
may return one of the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
@@ -179,7 +193,9 @@
.Pp
The
.Fn pread
-call may also return the following errors:
+and
+.Fn preadv
+calls may also return the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The specified file offset is invalid.
Index: libcr/sys/write.2
===================================================================
RCS file: /local/dcvs/src/lib/libcr/sys/write.2,v
retrieving revision 1.2
diff -u -r1.2 write.2
--- libcr/sys/write.2 17 Jun 2003 04:26:47 -0000 1.2
+++ libcr/sys/write.2 25 Apr 2006 22:46:08 -0000
@@ -39,7 +39,8 @@
.Sh NAME
.Nm write ,
.Nm writev ,
-.Nm pwrite
+.Nm pwrite ,
+.Nm pwritev
.Nd write output
.Sh LIBRARY
.Lb libc
@@ -53,6 +54,8 @@
.Fn writev "int d" "const struct iovec *iov" "int iovcnt"
.Ft ssize_t
.Fn pwrite "int d" "const void *buf" "size_t nbytes" "off_t offset"
+.Ft ssize_t
+.Fn pwritev "int d" "const struct iovec *iov" "int iovcnt" "off_t offset"
.Sh DESCRIPTION
.Fn Write
attempts to write
@@ -62,18 +65,24 @@
from the buffer pointed to by
.Fa buf .
.Fn Writev
-performs the same action, but gathers the output data
+and
+.Fn pwritev
+perform the same action, but gather the output data
from the
.Fa iovcnt
buffers specified by the members of the
.Fa iov
array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
.Fn Pwrite
-performs the same function, but writes to the specified position in
+and
+.Fn pwritev
+perform the same function, but write to the specified position in
the file without modifying the file pointer.
.Pp
For
-.Fn writev ,
+.Fn writev
+and
+.Fn pwritev ,
the
.Fa iovec
structure is defined as:
@@ -90,6 +99,8 @@
entry specifies the base address and length of an area
in memory from which data should be written.
.Fn Writev
+and
+.Fn pwritev
will always write a complete area before proceeding
to the next.
.Pp
@@ -133,8 +144,9 @@
.Sh ERRORS
.Fn Write ,
.Fn writev ,
+.Fn pwrite ,
and
-.Fn pwrite
+.Fn pwritev
will fail and the file pointer will remain unchanged if:
.Bl -tag -width Er
.It Bq Er EBADF
@@ -183,6 +195,8 @@
.Pp
In addition,
.Fn writev
+and
+.Fn pwritev
may return one of the following errors:
.Bl -tag -width Er
.It Bq Er EDESTADDRREQ
@@ -213,7 +227,9 @@
.Pp
The
.Fn pwrite
-call may also return the following errors:
+and
+.Fn pwritev
+calls may also return the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The specified file offset is invalid.
More information about the Kernel
mailing list