summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorDJ Hoffman <dj.hoffman@joyent.com>2014-06-09 20:35:13 +0000
committerRobert Mustacchi <rm@joyent.com>2015-01-14 13:51:40 -0800
commitfca543ca45b12c44a243625bce68b645ba8ed791 (patch)
tree40308157ab44217c4e91c13aa0e0aab95d583b74 /usr/src
parent078266a5aafa880521ea55488ef3d676f35e908e (diff)
downloadillumos-joyent-fca543ca45b12c44a243625bce68b645ba8ed791.tar.gz
4923 want preadv and pwritev
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Robert Mustacchi <robert.mustacchi@joyent.com> Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/truss/systable.c5
-rw-r--r--usr/src/lib/libc/amd64/Makefile4
-rw-r--r--usr/src/lib/libc/common/sys/preadv.s38
-rw-r--r--usr/src/lib/libc/common/sys/pwritev.s38
-rw-r--r--usr/src/lib/libc/i386/Makefile.com6
-rw-r--r--usr/src/lib/libc/port/mapfile-vers13
-rw-r--r--usr/src/lib/libc/port/threads/scalls.c43
-rw-r--r--usr/src/lib/libc/sparc/Makefile.com6
-rw-r--r--usr/src/lib/libc/sparcv9/Makefile.com4
-rw-r--r--usr/src/lib/libproc/common/proc_names.c5
-rw-r--r--usr/src/man/man2/Makefile5
-rw-r--r--usr/src/man/man2/read.227
-rw-r--r--usr/src/man/man2/write.224
-rw-r--r--usr/src/man/man3lib/libc.3lib12
-rw-r--r--usr/src/man/man5/lf64.563
-rw-r--r--usr/src/pkg/manifests/system-kernel.man2.inc2
-rw-r--r--usr/src/uts/common/os/sysent.c11
-rw-r--r--usr/src/uts/common/sys/syscall.h3
-rw-r--r--usr/src/uts/common/sys/uio.h40
-rw-r--r--usr/src/uts/common/syscall/rw.c395
-rw-r--r--usr/src/uts/intel/os/name_to_sysnum2
-rw-r--r--usr/src/uts/sparc/os/name_to_sysnum2
22 files changed, 659 insertions, 89 deletions
diff --git a/usr/src/cmd/truss/systable.c b/usr/src/cmd/truss/systable.c
index 3cd07c698b..7628a8298c 100644
--- a/usr/src/cmd/truss/systable.c
+++ b/usr/src/cmd/truss/systable.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -341,8 +342,8 @@ const struct systable systable[] = {
{"fchdir", 1, DEC, NOV, DEC}, /* 120 */
{"readv", 3, DEC, NOV, DEC, HEX, DEC}, /* 121 */
{"writev", 3, DEC, NOV, DEC, HEX, DEC}, /* 122 */
-{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
-{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
+{"preadv", 4, DEC, NOV, DEC, HEX, DEC, DEC}, /* 123 */
+{"pwritev", 4, DEC, NOV, DEC, HEX, DEC, DEC}, /* 124 */
{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
{"mmapobj", 5, DEC, NOV, DEC, MOB, HEX, HEX, HEX}, /* 127 */
diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile
index 5b378065c5..f4b79eedb6 100644
--- a/usr/src/lib/libc/amd64/Makefile
+++ b/usr/src/lib/libc/amd64/Makefile
@@ -20,7 +20,7 @@
#
#
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+# Copyright (c) 2015, Joyent, Inc. All rights reserved.
#
# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2013 Garrett D'Amore <garrett@damore.org>
@@ -229,6 +229,7 @@ COMSYSOBJS= \
pipe2.o \
pollsys.o \
pread.o \
+ preadv.o \
priocntlset.o \
processor_bind.o \
processor_info.o \
@@ -236,6 +237,7 @@ COMSYSOBJS= \
putmsg.o \
putpmsg.o \
pwrite.o \
+ pwritev.o \
read.o \
readv.o \
resolvepath.o \
diff --git a/usr/src/lib/libc/common/sys/preadv.s b/usr/src/lib/libc/common/sys/preadv.s
new file mode 100644
index 0000000000..da4514e91a
--- /dev/null
+++ b/usr/src/lib/libc/common/sys/preadv.s
@@ -0,0 +1,38 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
+ */
+
+ .file "preadv.s"
+
+/* C library -- preadv */
+/* ssize_t __preadv(int, const struct iovec *, int, off_t, off_t); */
+
+#include "SYS.h"
+
+#if !defined(_LARGEFILE_SOURCE)
+
+ SYSCALL2_RESTART_RVAL1(__preadv,preadv)
+ RET
+ SET_SIZE(__preadv)
+
+#else
+
+/* C library -- preadv64 transitional large file API */
+/* ssize_t __preadv64(int, void *, size_t, off_t, off_t); */
+
+ SYSCALL2_RESTART_RVAL1(__preadv64,preadv)
+ RET
+ SET_SIZE(__preadv64)
+
+#endif
diff --git a/usr/src/lib/libc/common/sys/pwritev.s b/usr/src/lib/libc/common/sys/pwritev.s
new file mode 100644
index 0000000000..05bd90912a
--- /dev/null
+++ b/usr/src/lib/libc/common/sys/pwritev.s
@@ -0,0 +1,38 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
+ */
+
+ .file "pwritev.s"
+
+/* C library -- pwritev */
+/* ssize_t __pwritev(int, const struct iovec *, int, off_t, off_t); */
+
+#include "SYS.h"
+
+#if !defined(_LARGEFILE_SOURCE)
+
+ SYSCALL2_RESTART_RVAL1(__pwritev,pwritev)
+ RET
+ SET_SIZE(__pwritev)
+
+#else
+
+/* C library -- pwrite64 transitional large file API, */
+/* ssize_t __pwritev64(int, const struct iovec *, int, off_t, off_t); */
+
+ SYSCALL2_RESTART_RVAL1(__pwritev64,pwritev)
+ RET
+ SET_SIZE(__pwritev64)
+
+#endif
diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com
index 6f6ebf0ed1..bf9a9f5536 100644
--- a/usr/src/lib/libc/i386/Makefile.com
+++ b/usr/src/lib/libc/i386/Makefile.com
@@ -20,7 +20,7 @@
#
#
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2013, Joyent, Inc. All rights reserved.
+# Copyright (c) 2015, Joyent, Inc. All rights reserved.
# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2013 Garrett D'Amore <garrett@damore.org>
#
@@ -156,7 +156,9 @@ COMSYSOBJS64= \
lseek64.o \
mmap64.o \
pread64.o \
+ preadv64.o \
pwrite64.o \
+ pwritev64.o \
setrlimit64.o \
statvfs64.o
@@ -251,6 +253,7 @@ COMSYSOBJS= \
pipe2.o \
pollsys.o \
pread.o \
+ preadv.o \
priocntlset.o \
processor_bind.o \
processor_info.o \
@@ -258,6 +261,7 @@ COMSYSOBJS= \
putmsg.o \
putpmsg.o \
pwrite.o \
+ pwritev.o \
read.o \
readv.o \
resolvepath.o \
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
index 6509cd1aad..8b1fe1363b 100644
--- a/usr/src/lib/libc/port/mapfile-vers
+++ b/usr/src/lib/libc/port/mapfile-vers
@@ -25,7 +25,7 @@
# Use is subject to license terms.
#
# Copyright (c) 2012 by Delphix. All rights reserved.
-# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+# Copyright (c) 2015, Joyent, Inc. All rights reserved.
# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright (c) 2013 Gary Mills
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
@@ -93,6 +93,17 @@ $if _x86 && _ELF64
$add amd64
$endif
+SYMBOL_VERSION ILLUMOS_0.10 { # Illumos additions
+ protected:
+ preadv;
+ pwritev;
+
+$if lf64
+ preadv64;
+ pwritev64;
+$endif
+} ILLUMOS_0.9;
+
SYMBOL_VERSION ILLUMOS_0.9 {
protected:
wcsnrtombs;
diff --git a/usr/src/lib/libc/port/threads/scalls.c b/usr/src/lib/libc/port/threads/scalls.c
index 18b6b1c05f..4a62ea76b9 100644
--- a/usr/src/lib/libc/port/threads/scalls.c
+++ b/usr/src/lib/libc/port/threads/scalls.c
@@ -22,6 +22,7 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
@@ -910,9 +911,29 @@ pread64(int fildes, void *buf, size_t nbyte, off64_t offset)
PERFORM(__pread64(fildes, buf, nbyte, offset))
}
+
+ssize_t
+preadv64(int fildes, const struct iovec *iov, int iovcnt, off64_t offset)
+{
+
+ extern ssize_t __preadv64(int, const struct iovec *, int, off_t, off_t);
+ ssize_t rv;
+
+ PERFORM(__preadv64(fildes, iov, iovcnt, offset & 0xffffffffULL,
+ offset>>32))
+}
#endif /* !_LP64 */
ssize_t
+preadv(int fildes, const struct iovec *iov, int iovcnt, off_t offset)
+{
+
+ extern ssize_t __preadv(int, const struct iovec *, int, off_t, off_t);
+ ssize_t rv;
+
+ PERFORM(__preadv(fildes, iov, iovcnt, offset, 0))
+}
+ssize_t
pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
{
extern ssize_t __pwrite(int, const void *, size_t, off_t);
@@ -930,9 +951,31 @@ pwrite64(int fildes, const void *buf, size_t nbyte, off64_t offset)
PERFORM(__pwrite64(fildes, buf, nbyte, offset))
}
+
+ssize_t
+pwritev64(int fildes, const struct iovec *iov, int iovcnt, off64_t offset)
+{
+
+ extern ssize_t __pwritev64(int,
+ const struct iovec *, int, off_t, off_t);
+ ssize_t rv;
+
+ PERFORM(__pwritev64(fildes, iov, iovcnt, offset &
+ 0xffffffffULL, offset>>32))
+}
+
#endif /* !_LP64 */
ssize_t
+pwritev(int fildes, const struct iovec *iov, int iovcnt, off_t offset)
+{
+ extern ssize_t __pwritev(int, const struct iovec *, int, off_t, off_t);
+ ssize_t rv;
+
+ PERFORM(__pwritev(fildes, iov, iovcnt, offset, 0))
+}
+
+ssize_t
readv(int fildes, const struct iovec *iov, int iovcnt)
{
extern ssize_t __readv(int, const struct iovec *, int);
diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com
index 15c5c2b092..fdeaaf757f 100644
--- a/usr/src/lib/libc/sparc/Makefile.com
+++ b/usr/src/lib/libc/sparc/Makefile.com
@@ -20,7 +20,7 @@
#
#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+# Copyright (c) 2015, Joyent, Inc. All rights reserved.
# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2013 Garrett D'Amore <garrett@damore.org>
#
@@ -176,7 +176,9 @@ COMSYSOBJS64= \
lseek64.o \
mmap64.o \
pread64.o \
+ preadv64.o \
pwrite64.o \
+ pwritev64.o \
setrlimit64.o \
statvfs64.o
@@ -271,6 +273,7 @@ COMSYSOBJS= \
pipe2.o \
pollsys.o \
pread.o \
+ preadv.o \
priocntlset.o \
processor_bind.o \
processor_info.o \
@@ -278,6 +281,7 @@ COMSYSOBJS= \
putmsg.o \
putpmsg.o \
pwrite.o \
+ pwritev.o \
read.o \
readv.o \
resolvepath.o \
diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com
index 0c3f0a2e32..39fa3d2c9f 100644
--- a/usr/src/lib/libc/sparcv9/Makefile.com
+++ b/usr/src/lib/libc/sparcv9/Makefile.com
@@ -20,7 +20,7 @@
#
#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+# Copyright (c) 2015, Joyent, Inc. All rights reserved.
# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2013 Garrett D'Amore <garrett@damore.org>
#
@@ -256,6 +256,7 @@ COMSYSOBJS= \
pipe2.o \
pollsys.o \
pread.o \
+ preadv.o \
priocntlset.o \
processor_bind.o \
processor_info.o \
@@ -263,6 +264,7 @@ COMSYSOBJS= \
putmsg.o \
putpmsg.o \
pwrite.o \
+ pwritev.o \
read.o \
readv.o \
resolvepath.o \
diff --git a/usr/src/lib/libproc/common/proc_names.c b/usr/src/lib/libproc/common/proc_names.c
index aa92006fbb..b0a4dfa131 100644
--- a/usr/src/lib/libproc/common/proc_names.c
+++ b/usr/src/lib/libproc/common/proc_names.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
#include <stdio.h>
@@ -235,8 +236,8 @@ static const char *const systable[] = {
"fchdir", /* 120 */
"readv", /* 121 */
"writev", /* 122 */
- NULL, /* 123 */
- NULL, /* 124 */
+ "preadv", /* 123 */
+ "pwritev", /* 124 */
NULL, /* 125 */
NULL, /* 126 */
"mmapobj", /* 127 */
diff --git a/usr/src/man/man2/Makefile b/usr/src/man/man2/Makefile
index 2e5c7a51e6..c4a4411877 100644
--- a/usr/src/man/man2/Makefile
+++ b/usr/src/man/man2/Makefile
@@ -13,6 +13,7 @@
# Copyright 2011, Richard Lowe
# Copyright 2013, OmniTI Computer Consulting, Inc
# Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+# Copyright (c) 2015, Joyent, Inc. All rights reserved.
#
include $(SRC)/Makefile.master
@@ -219,12 +220,14 @@ MANLINKS= _Exit.2 \
pipe2.2 \
ppoll.2 \
pread.2 \
+ preadv.2 \
pset_assign.2 \
pset_destroy.2 \
pset_getattr.2 \
putacct.2 \
putpmsg.2 \
pwrite.2 \
+ pwritev.2 \
readlinkat.2 \
readv.2 \
renameat.2 \
@@ -360,6 +363,7 @@ putpmsg.2 := LINKSRC = putmsg.2
pread.2 := LINKSRC = read.2
readv.2 := LINKSRC = read.2
+preadv.2 := LINKSRC = read.2
readlinkat.2 := LINKSRC = readlink.2
@@ -401,6 +405,7 @@ vforkx.2 := LINKSRC = vfork.2
pwrite.2 := LINKSRC = write.2
writev.2 := LINKSRC = write.2
+pwritev.2 := LINKSRC = write.2
.KEEP_STATE:
diff --git a/usr/src/man/man2/read.2 b/usr/src/man/man2/read.2
index 53a8ccc482..4fd785ee37 100644
--- a/usr/src/man/man2/read.2
+++ b/usr/src/man/man2/read.2
@@ -2,6 +2,7 @@
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
+.\" Copyright (c) 2015, Joyent, Inc. All rights reserved.
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
@@ -9,9 +10,9 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH READ 2 "Dec 03, 2014"
+.TH READ 2 "Jan 15, 2015"
.SH NAME
-read, readv, pread \- read from file
+read, readv, pread, preadv \- read from file
.SH SYNOPSIS
.LP
.nf
@@ -31,6 +32,11 @@ read, readv, pread \- read from file
\fBssize_t\fR \fBreadv\fR(\fBint\fR \fIfildes\fR, \fBconst struct iovec *\fR\fIiov\fR, \fBint\fR \fIiovcnt\fR);
.fi
+.LP
+.nf
+\fBssize_t\fR \fBpreadv\fR(\fBint\fR \fIfildes\fR, \fBconst struct iovec *\fR\fIiov\fR, \fBint\fR \fIiovcnt\fR, \fBoff_t\fR \fIoffset\fR);
+.fi
+
.SH DESCRIPTION
.LP
@@ -280,6 +286,16 @@ desired position inside the file. \fBpread()\fR will read up to the maximum
offset value that can be represented in an \fBoff_t\fR for regular files. An
attempt to perform a \fBpread()\fR on a file that is incapable of seeking
results in an error.
+.SS "\fBpreadv()\fR"
+.LP
+The \fBpreadv()\fR function performs the same action as \fBreadv()\fR except it
+reads from a given position in the file without changing the file pointer. The
+first three arguments are the same as \fBreadv()\fR with the addition of a
+fourth argument \fIoffset\fR for the desired position inside the file.
+\fBpreadv()\fR will read up to the maximum offset value that can be represented
+in an \fBoff_t\fR for regular files. An attempt to perform a \fBpreadv()\fR on a
+file that is incapable of seeking results in an error.
+
.SH RETURN VALUES
.LP
Upon successful completion, \fBread()\fR and \fBreadv()\fR return a
@@ -287,7 +303,7 @@ non-negative integer indicating the number of bytes actually read. Otherwise,
the functions return \fB\(mi1\fR and set \fBerrno\fR to indicate the error.
.SH ERRORS
.LP
-The \fBread()\fR, \fBreadv()\fR, and \fBpread()\fR functions will fail if:
+The \fBread()\fR, \fBreadv()\fR, \fBpread()\fR, and \fBpreadv()\fR functions will fail if:
.sp
.ne 2
.na
@@ -448,7 +464,7 @@ associated with \fIfildes\fR.
.sp
.LP
-The \fBreadv()\fR function may fail if:
+The \fBreadv()\fR and \fBpreadv()\fR functions may fail if:
.sp
.ne 2
.na
@@ -473,7 +489,8 @@ of the \fBiov_len\fR values in the \fIiov\fR array overflowed an \fBssize_t\fR.
.sp
.LP
-The \fBpread()\fR function will fail and the file pointer remain unchanged if:
+The \fBpread()\fR and \fBpreadv()\fR functions will fail and the file pointer
+remain unchanged if:
.sp
.ne 2
.na
diff --git a/usr/src/man/man2/write.2 b/usr/src/man/man2/write.2
index cf2dd34fac..64787b4b2a 100644
--- a/usr/src/man/man2/write.2
+++ b/usr/src/man/man2/write.2
@@ -2,6 +2,7 @@
.\" Copyright (c) 2087, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
+.\" Copyright (c) 2015, Joyent, Inc. All rights reserved.
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
@@ -9,9 +10,9 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH WRITE 2 "Dec 03, 2014"
+.TH WRITE 2 "Jan 15, 2015"
.SH NAME
-write, pwrite, writev \- write on a file
+write, pwrite, writev, pwritev\- write on a file
.SH SYNOPSIS
.LP
.nf
@@ -32,6 +33,10 @@ write, pwrite, writev \- write on a file
\fBssize_t\fR \fBwritev\fR(\fBint\fR \fIfildes\fR, \fBconst struct iovec *\fR\fIiov\fR, \fBint\fR \fIiovcnt\fR);
.fi
+.LP
+.nf
+\fBssize_t\fR \fBpwritev\fR(\fBint\fR \fIfildes\fR, \fBconst struct iovec *\fR\fIiov\fR, \fBint\fR \fIiovcnt\fR, \fBoff_t\fR \fIoffset\fR);
+.fi
.SH DESCRIPTION
.LP
@@ -272,6 +277,13 @@ of the \fIiov\fR array: \fIiov\fR[0], \fIiov\fR[1], \&.\|.\|.,
than 0 and less than or equal to \fB{IOV_MAX}\fR. See \fBIntro\fR(2) for a
definition of \fB{IOV_MAX}\fR.
.sp
+.SS "\fBpwritev()\fR"
+.LP
+The \fBpwritev()\fR function is equivalent to \fBwritev()\fR, except that it
+writes into a given position and does not change the file offset (regardless of
+whether \fBO_APPEND\fR is set). The first three arguments to \fBpwritev()\fR are
+the same as \fBwritev()\fR, with the addition of a fourth argument \fIoffset\fR
+for the desired position inside the file.
.LP
The \fBiovec\fR structure contains the following members:
.sp
@@ -309,7 +321,8 @@ written. Otherwise, it returns \fB\(mi1\fR, the file-pointer remains
unchanged, and \fBerrno\fR is set to indicate an error.
.SH ERRORS
.LP
-The \fBwrite()\fR, \fBpwrite()\fR, and \fBwritev()\fR functions will fail if:
+The \fBwrite()\fR, \fBpwrite()\fR, \fBwritev()\fR, and \fBpwritev()\fR
+functions will fail if:
.sp
.ne 2
.na
@@ -500,7 +513,8 @@ The \fInbyte\fR argument overflowed an \fBssize_t\fR.
.sp
.LP
-The \fBpwrite()\fR function fails and the file pointer remains unchanged if:
+The \fBpwrite()\fR and \fBpwritev()\fR functions fail and the file pointer
+remains unchanged if:
.sp
.ne 2
.na
@@ -549,7 +563,7 @@ stream head. In this case, \fBerrno\fR is set to the value included in the
error message.
.sp
.LP
-The \fBwritev()\fR function may fail if:
+The \fBwritev()\fR and \fBpwritev()\fR functions may fail if:
.sp
.ne 2
.na
diff --git a/usr/src/man/man3lib/libc.3lib b/usr/src/man/man3lib/libc.3lib
index 827bf53f28..18d3e9416f 100644
--- a/usr/src/man/man3lib/libc.3lib
+++ b/usr/src/man/man3lib/libc.3lib
@@ -1,11 +1,12 @@
'\" te
.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
.\" Copyright (c) 2009, Sun Microsystems, Inc. All rights reserved.
+.\" Copyright (c) 2015, Joyent, Inc. All rights reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.\" Copyright 2011 by Delphix. All rights reserved.
-.TH LIBC 3LIB "Aug 15, 2014"
+.TH LIBC 3LIB "Jan 14, 2014"
.SH NAME
libc \- C library
.SH DESCRIPTION
@@ -482,7 +483,8 @@ l l .
\fBposix_spawnattr_setschedparam\fR \fBposix_spawnattr_setschedpolicy\fR
\fBposix_spawnattr_setsigdefault\fR \fBposix_spawnattr_setsigignore_np\fR
\fBposix_spawnattr_setsigmask\fR \fBposix_spawnp\fR
-\fBpread\fR \fBprintf\fR
+\fBpread\fR \fBpreadv\fR
+\fBprintf\fR
\fBprintstack\fR \fBpriocntl\fR
\fBpriocntlset\fR \fBpriv_addset\fR
\fBpriv_allocset\fR \fBpriv_copyset\fR
@@ -567,6 +569,7 @@ l l .
\fBpututxline\fR \fBputw\fR
\fBputwc\fR \fBputwchar\fR
\fBputws\fR \fBpwrite\fR
+\fBpwritev\fR
\fBqeconvert\fR \fBqecvt\fR
\fBqfconvert\fR \fBqfcvt\fR
\fBqgconvert\fR \fBqgcvt\fR
@@ -862,8 +865,9 @@ l l .
\fBlseek64\fR \fBlstat64\fR
\fBmkstemp64\fR \fBmmap64\fR
\fBnftw64\fR \fBopen64\fR
-\fBpread64\fR \fBptrace\fR
-\fBpwrite64\fR \fBreaddir64\fR
+\fBpread64\fR \fBpreadv64\fR
+\fBptrace\fR \fBpwrite64\fR
+\fBpwritev64\fR \fBreaddir64\fR
\fBreaddir64_r\fR \fBs_fcntl\fR
\fBs_ioctl\fR \fBselect_large_fdset\fR
\fBsetrlimit64\fR \fBstat64\fR
diff --git a/usr/src/man/man5/lf64.5 b/usr/src/man/man5/lf64.5
index f8f3afba41..f1be4e3d83 100644
--- a/usr/src/man/man5/lf64.5
+++ b/usr/src/man/man5/lf64.5
@@ -3,11 +3,11 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH LF64 5 "Jul 14, 2008"
+.\" Copyright (c) 2015, Joyent, Inc. All rights reserved.
+.TH LF64 5 "Jan 14, 2015"
.SH NAME
lf64 \- transitional interfaces for 64-bit file offsets
.SH DESCRIPTION
-.sp
.LP
The data types, interfaces, and macros described on this page provide explicit
access to 64-bit file offsets. They are accessible through the transitional
@@ -16,7 +16,6 @@ function prototype and semantics of a transitional interface are equivalent to
those of the standard version of the call, except that relevant data types are
64-bit entities.
.SS "Data Types"
-.sp
.LP
The following tables list the standard data or struct types in the left-hand
column and their corresponding explicit 64-bit file offset types in the
@@ -26,9 +25,7 @@ corresponds to the 64-bit type listed in the right\(emhand column. Note that
in a 64-bit application, the standard definition is equivalent to the 64-bit
file offset definition.
.SS "<\fBaio.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -37,9 +34,7 @@ struct \fBaiocb\fR struct \fBaiocb64\fR
.TE
.SS "<\fBsys/dirent.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -49,9 +44,7 @@ struct \fBdirent\fR struct \fBdirent64\fR
.TE
.SS "<\fBsys/fcntl.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -67,18 +60,14 @@ struct \fBflock\fR struct \fBflock64\fR
.TE
.SS "<\fBsys/stdio.h\fR>"
-.sp
-.sp
.TS
l l .
\fBfpos_t\fR \fBfpos64_t\fR
.TE
.SS "<\fBsys/resource.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -92,9 +81,7 @@ struct \fBrlimit\fR struct \fBrlimit64\fR
.TE
.SS "<\fBsys/stat.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -105,9 +92,7 @@ struct \fBstat\fR struct \fBstat64\fR
.TE
.SS "<\fBsys/statvfs.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -121,9 +106,7 @@ struct \fBstatvfs\fR struct \fBstatvfs64\fR
.TE
.SS "<\fBsys/types.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -135,9 +118,7 @@ l l .
.TE
.SS "<\fBunistd.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -146,9 +127,7 @@ l l .
.TE
.SS "<\fBsys/unistd.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -159,16 +138,13 @@ l l .
.TE
.SS "System Interfaces"
-.sp
.LP
The following tables display the standard API and the corresponding
transitional interfaces for 64-bit file offsets. The interfaces are grouped by
header. The interface name and the affected data types are displayed in courier
font.
.SS "<\fBaio.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -190,9 +166,7 @@ int \fBlio_listio\fR(..., int \fBlio_listio64\fR(...,
.TE
.SS "<\fBdirent.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -209,9 +183,7 @@ int \fBscandir\fR(..., int \fBscandir64\fR(...,
.TE
.SS "<\fBfcntl.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -224,9 +196,7 @@ int \fBposix_fallocate()\fR int \fBposix_fallocate64()\fR
.TE
.SS "<\fBftw.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -239,18 +209,14 @@ int \fBnftw\fR(.. int \fBnftw64\fR(...,
.TE
.SS "<\fBlibgen.h\fR>"
-.sp
-.sp
.TS
l l .
char *\fBcopylist\fR(..., \fBoff_t\fR); char *\fBcopylist64\fR(..., \fBoff64_t\fR);
.TE
.SS "<\fBstdio.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -265,18 +231,14 @@ FILE *\fBtmpfile()\fR; FILE *\fBtmpfile64()\fR;
.TE
.SS "<\fBstdlib.h\fR>"
-.sp
-.sp
.TS
l l .
int \fBmkstemp()\fR; int \fBmkstemp64()\fR;
.TE
.SS "<\fBsys/async.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -285,9 +247,7 @@ int \fBaiowrite\fR(..., \fBoff_t\fR, ...); int \fBaiowrite64\fR(..., \fBoff64_t\
.TE
.SS "<\fBsys/dirent.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -296,18 +256,14 @@ int \fBgetdents\fR(..., \fBdirent\fR); int \fBgetdents64\fR(..., \fBdirent64\fR)
.TE
.SS "<\fBsys/mman.h\fR>"
-.sp
-.sp
.TS
l l .
void \fBmmap\fR(..., \fBoff_t\fR); void \fBmmap64\fR(..., \fBoff64_t\fR);
.TE
.SS "<\fBsys/resource.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -318,9 +274,7 @@ int \fBsetrlimit\fR(..., int \fBsetrlimit64\fR(...,
.TE
.SS "<\fBsys/sendfile.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -332,9 +286,7 @@ ssize_t \fBsendfilev\fR(..., const ssize_t \fBsendfilev64\fR(..., const
.TE
.SS "<\fBsys/stat.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -346,9 +298,7 @@ int \fBstat\fR(..., struct \fBstat\fR *); int \fBstat64\fR(..., struct \fBstat64
.TE
.SS "<\fBsys/statvfs.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -359,9 +309,7 @@ int \fBfstatvfs\fR(..., int \fBfstatvfs64\fR(...,
.TE
.SS "<\fBucbinclude/stdio.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -370,9 +318,7 @@ FILE *\fBfreopen()\fR FILE *\fBfreopen64()\fR
.TE
.SS "<\fBucbinclude/sys/dir.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -386,9 +332,7 @@ int \fBscandir\fR(..., int \fBscandir64\fR(...,
.TE
.SS "<\fBunistd.h\fR>"
-.sp
-.sp
.TS
l l
l l .
@@ -397,10 +341,11 @@ int \fBlockf\fR(..., \fBoff_t\fR); int \fBlockf64\fR(..., \fBoff64_t\fR);
int \fBftruncate\fR(..., \fBoff_t\fR); int \fBftruncate64\fR..., \fBoff64_t\fR);
ssize_t \fBpread\fR(..., \fBoff_t\fR); ssize_t \fBpread64\fR..., \fBoff64_t\fR);
ssize_t \fBpwrite\fR(..., \fBoff_t\fR); ssize_t \fBpwrite64\fR(..., \fBoff64_t\fR);
+ssize_t \fBpreadv\fR(..., \fBoff_t\fR); ssize_t \fBpreadv64\fR..., \fBoff64_t\fR);
+ssize_t \fBpwritev\fR(..., \fBoff_t\fR); ssize_t \fBpwritev64\fR(..., \fBoff64_t\fR);
int \fBtruncate\fR(..., \fBoff_t\fR); int \fBtruncate64\fR(..., \fBoff64_t\fR);
.TE
.SH SEE ALSO
-.sp
.LP
\fBlfcompile\fR(5), \fBlfcompile64\fR(5)
diff --git a/usr/src/pkg/manifests/system-kernel.man2.inc b/usr/src/pkg/manifests/system-kernel.man2.inc
index c1b9076963..3f85767644 100644
--- a/usr/src/pkg/manifests/system-kernel.man2.inc
+++ b/usr/src/pkg/manifests/system-kernel.man2.inc
@@ -214,12 +214,14 @@ link path=usr/share/man/man2/pathconf.2 target=fpathconf.2
link path=usr/share/man/man2/pipe2.2 target=pipe.2
link path=usr/share/man/man2/ppoll.2 target=poll.2
link path=usr/share/man/man2/pread.2 target=read.2
+link path=usr/share/man/man2/preadv.2 target=read.2
link path=usr/share/man/man2/pset_assign.2 target=pset_create.2
link path=usr/share/man/man2/pset_destroy.2 target=pset_create.2
link path=usr/share/man/man2/pset_getattr.2 target=pset_setattr.2
link path=usr/share/man/man2/putacct.2 target=getacct.2
link path=usr/share/man/man2/putpmsg.2 target=putmsg.2
link path=usr/share/man/man2/pwrite.2 target=write.2
+link path=usr/share/man/man2/pwritev.2 target=write.2
link path=usr/share/man/man2/readlinkat.2 target=readlink.2
link path=usr/share/man/man2/readv.2 target=read.2
link path=usr/share/man/man2/renameat.2 target=rename.2
diff --git a/usr/src/uts/common/os/sysent.c b/usr/src/uts/common/os/sysent.c
index e3965f7d82..ced2f3bb3a 100644
--- a/usr/src/uts/common/os/sysent.c
+++ b/usr/src/uts/common/os/sysent.c
@@ -23,6 +23,7 @@
* Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012 Milan Jurik. All rights reserved.
* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
+ * Copyright (c) 2015, Joyent, Inc.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -152,6 +153,8 @@ ssize_t uucopystr(const char *, char *, size_t);
ssize_t write(int, void *, size_t);
ssize_t readv(int, struct iovec *, int);
ssize_t writev(int, struct iovec *, int);
+ssize_t preadv(int, struct iovec *, int, off_t, off_t);
+ssize_t pwritev(int, struct iovec *, int, off_t, off_t);
int syslwp_park(int, uintptr_t, uintptr_t);
int rmdir(char *);
int mkdir(char *, int);
@@ -576,8 +579,8 @@ struct sysent sysent[NSYSCALL] =
/* 120 */ SYSENT_CI("fchdir", fchdir, 1),
/* 121 */ SYSENT_CL("readv", readv, 3),
/* 122 */ SYSENT_CL("writev", writev, 3),
- /* 123 */ SYSENT_LOADABLE(), /* (was xstat) */
- /* 124 */ SYSENT_LOADABLE(), /* (was lxstat) */
+ /* 123 */ SYSENT_CL("preadv", preadv, 5),
+ /* 124 */ SYSENT_CL("pwritev", pwritev, 5),
/* 125 */ SYSENT_LOADABLE(), /* (was fxstat) */
/* 126 */ SYSENT_LOADABLE(), /* (was xmknod) */
/* 127 */ SYSENT_CI("mmapobj", mmapobjsys, 5),
@@ -941,8 +944,8 @@ struct sysent sysent32[NSYSCALL] =
/* 120 */ SYSENT_CI("fchdir", fchdir, 1),
/* 121 */ SYSENT_CI("readv", readv32, 3),
/* 122 */ SYSENT_CI("writev", writev32, 3),
- /* 123 */ SYSENT_LOADABLE32(), /* was xstat32 */
- /* 124 */ SYSENT_LOADABLE32(), /* was lxstat32 */
+ /* 123 */ SYSENT_CI("preadv", preadv, 5),
+ /* 124 */ SYSENT_CI("pwritev", pwritev, 5),
/* 125 */ SYSENT_LOADABLE32(), /* was fxstat32 */
/* 126 */ SYSENT_LOADABLE32(), /* was xmknod */
/* 127 */ SYSENT_CI("mmapobj", mmapobjsys, 5),
diff --git a/usr/src/uts/common/sys/syscall.h b/usr/src/uts/common/sys/syscall.h
index eee273a25f..bbcd46995d 100644
--- a/usr/src/uts/common/sys/syscall.h
+++ b/usr/src/uts/common/sys/syscall.h
@@ -23,6 +23,7 @@
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -293,6 +294,8 @@ extern "C" {
#define SYS_fchdir 120
#define SYS_readv 121
#define SYS_writev 122
+#define SYS_preadv 123
+#define SYS_pwritev 124
#define SYS_mmapobj 127
#define SYS_setrlimit 128
#define SYS_getrlimit 129
diff --git a/usr/src/uts/common/sys/uio.h b/usr/src/uts/common/sys/uio.h
index dd8cbea4fa..b04ca7b8f3 100644
--- a/usr/src/uts/common/sys/uio.h
+++ b/usr/src/uts/common/sys/uio.h
@@ -23,6 +23,7 @@
*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -254,6 +255,45 @@ extern uioasync_t uioasync;
extern ssize_t readv(int, const struct iovec *, int);
extern ssize_t writev(int, const struct iovec *, int);
+/*
+ * When in the large file compilation environment,
+ * map preadv/pwritev to their 64 bit offset versions
+ */
+#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
+#ifdef __PRAGMA_REDEFINE_EXTNAME
+#pragma redefine_extname preadv preadv64
+#pragma redefine_extname pwritev pwritev64
+#else /* __PRAGMA_REDEFINE_EXTNAME */
+#define preadv preadv64
+#define pwritev pwritev64
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
+#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
+
+/* In the LP64 compilation environment, the APIs are already large file */
+#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
+#ifdef __PRAGMA_REDEFINE_EXTNAME
+#pragma redefine_extname preadv64 preadv
+#pragma redefine_extname pwritev64 pwritev
+#else /* __PRAGMA_REDEFINE_EXTNAME */
+#define preadv64 preadv
+#define pwritev64 pwritev
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
+#endif /* _LP64 && _LARGEFILE64_SOURCE */
+
+extern ssize_t preadv(int, const struct iovec *, int, off_t);
+extern ssize_t pwritev(int, const struct iovec *, int, off_t);
+
+/*
+ * preadv64 and pwritev64 should be defined when:
+ * - Using the transitional compilation environment, and not
+ * the large file compilation environment.
+ */
+#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
+ !defined(__PRAGMA_REDEFINE_EXTNAME))
+extern ssize_t preadv64(int, const struct iovec *, int, off64_t);
+extern ssize_t pwritev64(int, const struct iovec *, int, off64_t);
+#endif /* _LARGEFILE64_SOURCE */
+
#endif /* defined(_KERNEL) */
#ifdef __cplusplus
diff --git a/usr/src/uts/common/syscall/rw.c b/usr/src/uts/common/syscall/rw.c
index 26585bcf68..a28894b2c9 100644
--- a/usr/src/uts/common/syscall/rw.c
+++ b/usr/src/uts/common/syscall/rw.c
@@ -22,6 +22,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
@@ -32,8 +33,6 @@
* under license from the Regents of the University of California.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/param.h>
#include <sys/isa_defs.h>
#include <sys/types.h>
@@ -923,6 +922,397 @@ out:
return (count);
}
+ssize_t
+preadv(int fdes, struct iovec *iovp, int iovcnt, off_t offset,
+ off_t extended_offset)
+{
+ struct uio auio;
+ struct iovec aiov[DEF_IOV_MAX];
+ file_t *fp;
+ register vnode_t *vp;
+ struct cpu *cp;
+ int fflag, ioflag, rwflag;
+ ssize_t count, bcount;
+ int error = 0;
+ int i;
+
+#if defined(_SYSCALL32_IMPL) || defined(_ILP32)
+ u_offset_t fileoff = ((u_offset_t)extended_offset << 32) |
+ (u_offset_t)offset;
+#else /* _SYSCALL32_IMPL || _ILP32 */
+ u_offset_t fileoff = (u_offset_t)(ulong_t)offset;
+#endif /* _SYSCALL32_IMPR || _ILP32 */
+#ifdef _SYSCALL32_IMPL
+ const u_offset_t maxoff = get_udatamodel() == DATAMODEL_ILP32 &&
+ extended_offset == 0?
+ MAXOFF32_T : MAXOFFSET_T;
+#else /* _SYSCALL32_IMPL */
+ const u_offset_t maxoff = MAXOFF32_T;
+#endif /* _SYSCALL32_IMPL */
+
+ int in_crit = 0;
+
+ if (iovcnt <= 0 || iovcnt > DEF_IOV_MAX)
+ return (set_errno(EINVAL));
+
+#ifdef _SYSCALL32_IMPL
+ /*
+ * 32-bit callers need to have their iovec expanded,
+ * while ensuring that they can't move more than 2Gbytes
+ * of data in a single call.
+ */
+ if (get_udatamodel() == DATAMODEL_ILP32) {
+ struct iovec32 aiov32[DEF_IOV_MAX];
+ ssize32_t count32;
+
+ if (copyin(iovp, aiov32, iovcnt * sizeof (struct iovec32)))
+ return (set_errno(EFAULT));
+
+ count32 = 0;
+ for (i = 0; i < iovcnt; i++) {
+ ssize32_t iovlen32 = aiov32[i].iov_len;
+ count32 += iovlen32;
+ if (iovlen32 < 0 || count32 < 0)
+ return (set_errno(EINVAL));
+ aiov[i].iov_len = iovlen32;
+ aiov[i].iov_base =
+ (caddr_t)(uintptr_t)aiov32[i].iov_base;
+ }
+ } else
+#endif /* _SYSCALL32_IMPL */
+ if (copyin(iovp, aiov, iovcnt * sizeof (struct iovec)))
+ return (set_errno(EFAULT));
+
+ count = 0;
+ for (i = 0; i < iovcnt; i++) {
+ ssize_t iovlen = aiov[i].iov_len;
+ count += iovlen;
+ if (iovlen < 0 || count < 0)
+ return (set_errno(EINVAL));
+ }
+
+ if ((bcount = (ssize_t)count) < 0)
+ return (set_errno(EINVAL));
+ if ((fp = getf(fdes)) == NULL)
+ return (set_errno(EBADF));
+ if (((fflag = fp->f_flag) & FREAD) == 0) {
+ error = EBADF;
+ goto out;
+ }
+ vp = fp->f_vnode;
+ rwflag = 0;
+ if (vp->v_type == VREG) {
+
+ if (bcount == 0)
+ goto out;
+
+ /*
+ * return EINVAL for offsets that cannot be
+ * represented in an off_t.
+ */
+ if (fileoff > maxoff) {
+ error = EINVAL;
+ goto out;
+ }
+
+ if (fileoff + bcount > maxoff)
+ bcount = (ssize_t)((u_offset_t)maxoff - fileoff);
+ } else if (vp->v_type == VFIFO) {
+ error = ESPIPE;
+ goto out;
+ }
+ /*
+ * We have to enter the critical region before calling VOP_RWLOCK
+ * to avoid a deadlock with ufs.
+ */
+ if (nbl_need_check(vp)) {
+ int svmand;
+
+ nbl_start_crit(vp, RW_READER);
+ in_crit = 1;
+ error = nbl_svmand(vp, fp->f_cred, &svmand);
+ if (error != 0)
+ goto out;
+ if (nbl_conflict(vp, NBL_WRITE, fileoff, count, svmand,
+ NULL)) {
+ error = EACCES;
+ goto out;
+ }
+ }
+
+ (void) VOP_RWLOCK(vp, rwflag, NULL);
+
+ /*
+ * Behaviour is same as read(2). Please see comments in
+ * read(2).
+ */
+
+ if ((vp->v_type == VREG) && (fileoff >= OFFSET_MAX(fp))) {
+ struct vattr va;
+ va.va_mask = AT_SIZE;
+ if ((error =
+ VOP_GETATTR(vp, &va, 0, fp->f_cred, NULL))) {
+ VOP_RWUNLOCK(vp, rwflag, NULL);
+ goto out;
+ }
+ if (fileoff >= va.va_size) {
+ VOP_RWUNLOCK(vp, rwflag, NULL);
+ count = 0;
+ goto out;
+ } else {
+ VOP_RWUNLOCK(vp, rwflag, NULL);
+ error = EOVERFLOW;
+ goto out;
+ }
+ }
+ if ((vp->v_type == VREG) &&
+ (fileoff + count > OFFSET_MAX(fp))) {
+ count = (ssize_t)(OFFSET_MAX(fp) - fileoff);
+ }
+ auio.uio_loffset = fileoff;
+ auio.uio_iov = aiov;
+ auio.uio_iovcnt = iovcnt;
+ auio.uio_resid = bcount = count;
+ auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_llimit = MAXOFFSET_T;
+ auio.uio_fmode = fflag;
+ if (bcount <= copyout_max_cached)
+ auio.uio_extflg = UIO_COPY_CACHED;
+ else
+ auio.uio_extflg = UIO_COPY_DEFAULT;
+
+ ioflag = auio.uio_fmode & (FAPPEND|FSYNC|FDSYNC|FRSYNC);
+ error = VOP_READ(vp, &auio, ioflag, fp->f_cred, NULL);
+ count -= auio.uio_resid;
+ CPU_STATS_ENTER_K();
+ cp = CPU;
+ CPU_STATS_ADDQ(cp, sys, sysread, 1);
+ CPU_STATS_ADDQ(cp, sys, readch, (ulong_t)count);
+ CPU_STATS_EXIT_K();
+ ttolwp(curthread)->lwp_ru.ioch += (ulong_t)count;
+
+ VOP_RWUNLOCK(vp, rwflag, NULL);
+
+ if (error == EINTR && count != 0)
+ error = 0;
+out:
+ if (in_crit)
+ nbl_end_crit(vp);
+ releasef(fdes);
+ if (error)
+ return (set_errno(error));
+ return (count);
+}
+
+ssize_t
+pwritev(int fdes, struct iovec *iovp, int iovcnt, off_t offset,
+ off_t extended_offset)
+{
+ struct uio auio;
+ struct iovec aiov[DEF_IOV_MAX];
+ file_t *fp;
+ register vnode_t *vp;
+ struct cpu *cp;
+ int fflag, ioflag, rwflag;
+ ssize_t count, bcount;
+ int error = 0;
+ int i;
+
+#if defined(_SYSCALL32_IMPL) || defined(_ILP32)
+ u_offset_t fileoff = ((u_offset_t)extended_offset << 32) |
+ (u_offset_t)offset;
+#else /* _SYSCALL32_IMPL || _ILP32 */
+ u_offset_t fileoff = (u_offset_t)(ulong_t)offset;
+#endif /* _SYSCALL32_IMPR || _ILP32 */
+#ifdef _SYSCALL32_IMPL
+ const u_offset_t maxoff = get_udatamodel() == DATAMODEL_ILP32 &&
+ extended_offset == 0?
+ MAXOFF32_T : MAXOFFSET_T;
+#else /* _SYSCALL32_IMPL */
+ const u_offset_t maxoff = MAXOFF32_T;
+#endif /* _SYSCALL32_IMPL */
+
+ int in_crit = 0;
+
+ if (iovcnt <= 0 || iovcnt > DEF_IOV_MAX)
+ return (set_errno(EINVAL));
+
+#ifdef _SYSCALL32_IMPL
+ /*
+ * 32-bit callers need to have their iovec expanded,
+ * while ensuring that they can't move more than 2Gbytes
+ * of data in a single call.
+ */
+ if (get_udatamodel() == DATAMODEL_ILP32) {
+ struct iovec32 aiov32[DEF_IOV_MAX];
+ ssize32_t count32;
+
+ if (copyin(iovp, aiov32, iovcnt * sizeof (struct iovec32)))
+ return (set_errno(EFAULT));
+
+ count32 = 0;
+ for (i = 0; i < iovcnt; i++) {
+ ssize32_t iovlen32 = aiov32[i].iov_len;
+ count32 += iovlen32;
+ if (iovlen32 < 0 || count32 < 0)
+ return (set_errno(EINVAL));
+ aiov[i].iov_len = iovlen32;
+ aiov[i].iov_base =
+ (caddr_t)(uintptr_t)aiov32[i].iov_base;
+ }
+ } else
+#endif /* _SYSCALL32_IMPL */
+ if (copyin(iovp, aiov, iovcnt * sizeof (struct iovec)))
+ return (set_errno(EFAULT));
+
+ count = 0;
+ for (i = 0; i < iovcnt; i++) {
+ ssize_t iovlen = aiov[i].iov_len;
+ count += iovlen;
+ if (iovlen < 0 || count < 0)
+ return (set_errno(EINVAL));
+ }
+
+ if ((bcount = (ssize_t)count) < 0)
+ return (set_errno(EINVAL));
+ if ((fp = getf(fdes)) == NULL)
+ return (set_errno(EBADF));
+ if (((fflag = fp->f_flag) & FWRITE) == 0) {
+ error = EBADF;
+ goto out;
+ }
+ vp = fp->f_vnode;
+ rwflag = 1;
+ if (vp->v_type == VREG) {
+
+ if (bcount == 0)
+ goto out;
+
+ /*
+ * return EINVAL for offsets that cannot be
+ * represented in an off_t.
+ */
+ if (fileoff > maxoff) {
+ error = EINVAL;
+ goto out;
+ }
+ /*
+ * Take appropriate action if we are trying
+ * to write above the resource limit.
+ */
+ if (fileoff >= curproc->p_fsz_ctl) {
+ mutex_enter(&curproc->p_lock);
+ /*
+ * Return value ignored because it lists
+ * actions taken, but we are in an error case.
+ * We don't have any actions that depend on
+ * what could happen in this call, so we ignore
+ * the return value.
+ */
+ (void) rctl_action(
+ rctlproc_legacy[RLIMIT_FSIZE],
+ curproc->p_rctls, curproc,
+ RCA_UNSAFE_SIGINFO);
+ mutex_exit(&curproc->p_lock);
+
+ error = EFBIG;
+ goto out;
+ }
+ /*
+ * Don't allow pwritev to cause file sizes to exceed
+ * maxoff.
+ */
+ if (fileoff == maxoff) {
+ error = EFBIG;
+ goto out;
+ }
+
+ if (fileoff + bcount > maxoff)
+ bcount = (ssize_t)((u_offset_t)maxoff - fileoff);
+ } else if (vp->v_type == VFIFO) {
+ error = ESPIPE;
+ goto out;
+ }
+ /*
+ * We have to enter the critical region before calling VOP_RWLOCK
+ * to avoid a deadlock with ufs.
+ */
+ if (nbl_need_check(vp)) {
+ int svmand;
+
+ nbl_start_crit(vp, RW_READER);
+ in_crit = 1;
+ error = nbl_svmand(vp, fp->f_cred, &svmand);
+ if (error != 0)
+ goto out;
+ if (nbl_conflict(vp, NBL_WRITE, fileoff, count, svmand,
+ NULL)) {
+ error = EACCES;
+ goto out;
+ }
+ }
+
+ (void) VOP_RWLOCK(vp, rwflag, NULL);
+
+
+ /*
+ * Behaviour is same as write(2). Please see comments for
+ * write(2).
+ */
+
+ if (vp->v_type == VREG) {
+ if (fileoff >= curproc->p_fsz_ctl) {
+ VOP_RWUNLOCK(vp, rwflag, NULL);
+ mutex_enter(&curproc->p_lock);
+ /* see above rctl_action comment */
+ (void) rctl_action(
+ rctlproc_legacy[RLIMIT_FSIZE],
+ curproc->p_rctls,
+ curproc, RCA_UNSAFE_SIGINFO);
+ mutex_exit(&curproc->p_lock);
+ error = EFBIG;
+ goto out;
+ }
+ if (fileoff >= OFFSET_MAX(fp)) {
+ VOP_RWUNLOCK(vp, rwflag, NULL);
+ error = EFBIG;
+ goto out;
+ }
+ if (fileoff + count > OFFSET_MAX(fp))
+ count = (ssize_t)(OFFSET_MAX(fp) - fileoff);
+ }
+
+ auio.uio_loffset = fileoff;
+ auio.uio_iov = aiov;
+ auio.uio_iovcnt = iovcnt;
+ auio.uio_resid = bcount = count;
+ auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_llimit = curproc->p_fsz_ctl;
+ auio.uio_fmode = fflag;
+ auio.uio_extflg = UIO_COPY_CACHED;
+ ioflag = auio.uio_fmode & (FSYNC|FDSYNC|FRSYNC);
+ error = VOP_WRITE(vp, &auio, ioflag, fp->f_cred, NULL);
+ count -= auio.uio_resid;
+ CPU_STATS_ENTER_K();
+ cp = CPU;
+ CPU_STATS_ADDQ(cp, sys, syswrite, 1);
+ CPU_STATS_ADDQ(cp, sys, writech, (ulong_t)count);
+ CPU_STATS_EXIT_K();
+ ttolwp(curthread)->lwp_ru.ioch += (ulong_t)count;
+
+ VOP_RWUNLOCK(vp, rwflag, NULL);
+
+ if (error == EINTR && count != 0)
+ error = 0;
+out:
+ if (in_crit)
+ nbl_end_crit(vp);
+ releasef(fdes);
+ if (error)
+ return (set_errno(error));
+ return (count);
+}
+
#if defined(_SYSCALL32_IMPL) || defined(_ILP32)
/*
@@ -1240,5 +1630,4 @@ writev32(int32_t fdes, caddr32_t iovp, int32_t iovcnt)
{
return (writev(fdes, (void *)(uintptr_t)iovp, iovcnt));
}
-
#endif /* _SYSCALL32_IMPL */
diff --git a/usr/src/uts/intel/os/name_to_sysnum b/usr/src/uts/intel/os/name_to_sysnum
index 5e02b78d43..eed990a8da 100644
--- a/usr/src/uts/intel/os/name_to_sysnum
+++ b/usr/src/uts/intel/os/name_to_sysnum
@@ -115,6 +115,8 @@ vfork 119
fchdir 120
readv 121
writev 122
+preadv 123
+pwritev 124
mmapobj 127
setrlimit 128
getrlimit 129
diff --git a/usr/src/uts/sparc/os/name_to_sysnum b/usr/src/uts/sparc/os/name_to_sysnum
index 8671ca5942..a762ee1c65 100644
--- a/usr/src/uts/sparc/os/name_to_sysnum
+++ b/usr/src/uts/sparc/os/name_to_sysnum
@@ -113,6 +113,8 @@ vfork 119
fchdir 120
readv 121
writev 122
+preadv 123
+pwritev 124
mmapobj 127
setrlimit 128
getrlimit 129