1 /* $NetBSD: osf1_generic.c,v 1.15 2009/04/01 03:06:06 dogcow Exp $ */
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
35 * All rights reserved.
37 * Author: Chris G. Demetriou
39 * Permission to use, copy, modify and distribute this software and
40 * its documentation is hereby granted, provided that both the copyright
41 * notice and this permission notice appear in all copies of the
42 * software, derivative works or modified versions, and any portions
43 * thereof, and that both notices appear in supporting documentation.
45 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
46 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
47 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49 * Carnegie Mellon requests users of this software to return to
51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52 * School of Computer Science
53 * Carnegie Mellon University
54 * Pittsburgh PA 15213-3890
56 * any improvements or extensions that they make and grant Carnegie the
57 * rights to redistribute these changes.
60 #include <sys/cdefs.h>
61 __KERNEL_RCSID(0, "$NetBSD: osf1_generic.c,v 1.15 2009/04/01 03:06:06 dogcow Exp $");
63 #include <sys/param.h>
64 #include <sys/systm.h>
65 #include <sys/namei.h>
69 #include <sys/malloc.h>
71 #include <sys/mount.h>
72 #include <sys/select.h>
73 #include <sys/syscallargs.h>
76 #include <compat/osf1/osf1.h>
77 #include <compat/osf1/osf1_syscallargs.h>
78 #include <compat/osf1/osf1_cvt.h>
81 * The structures end up being the same... but we can't be sure that
82 * the other word of our iov_len is zero!
85 #if __GNUC_PREREQ__(3, 0)
86 __attribute ((noinline
))
89 osf1_get_iov(struct osf1_iovec
*uiov
, unsigned int iovcnt
, struct iovec
**iovp
)
91 struct iovec
*iov
= *iovp
;
92 struct osf1_iovec osf1_iov
[UIO_SMALLIOV
];
98 if (iovcnt
> UIO_SMALLIOV
) {
99 iov
= malloc(iovcnt
* sizeof *iov
, M_IOV
, M_WAITOK
);
101 /* Caller must free - even if we return an error */
104 for (i
= 0; i
< iovcnt
; uiov
+= UIO_SMALLIOV
, i
+= UIO_SMALLIOV
) {
106 if (n
> UIO_SMALLIOV
)
108 error
= copyin(uiov
, osf1_iov
, n
* sizeof osf1_iov
[0]);
112 for (j
= 0; j
< n
; iov
++, j
++) {
113 iov
->iov_base
= osf1_iov
[j
].iov_base
;
114 iov
->iov_len
= osf1_iov
[j
].iov_len
;
122 osf1_sys_readv(struct lwp
*l
, const struct osf1_sys_readv_args
*uap
, register_t
*retval
)
124 struct iovec aiov
[UIO_SMALLIOV
], *niov
= aiov
;
127 error
= osf1_get_iov(SCARG(uap
, iovp
), SCARG(uap
, iovcnt
), &niov
);
130 error
= do_filereadv(SCARG(uap
, fd
), niov
,
131 SCARG(uap
, iovcnt
), NULL
,
132 FOF_UPDATE_OFFSET
| FOF_IOV_SYSSPACE
, retval
);
142 osf1_sys_writev(struct lwp
*l
, const struct osf1_sys_writev_args
*uap
, register_t
*retval
)
144 struct iovec aiov
[UIO_SMALLIOV
], *niov
= aiov
;
147 error
= osf1_get_iov(SCARG(uap
, iovp
), SCARG(uap
, iovcnt
), &niov
);
150 error
= do_filewritev(SCARG(uap
, fd
), niov
,
151 SCARG(uap
, iovcnt
), NULL
,
152 FOF_UPDATE_OFFSET
| FOF_IOV_SYSSPACE
, retval
);
162 osf1_sys_select(struct lwp
*l
, const struct osf1_sys_select_args
*uap
,
165 struct osf1_timeval otv
;
166 struct timespec ats
, *ts
= NULL
;
169 if (SCARG(uap
, tv
)) {
170 /* get the OSF/1 timeval argument */
171 error
= copyin(SCARG(uap
, tv
), &otv
, sizeof otv
);
175 ats
.tv_sec
= otv
.tv_sec
;
176 ats
.tv_nsec
= otv
.tv_usec
* 1000;
180 return selcommon(retval
, SCARG(uap
, nd
), SCARG(uap
, in
),
181 SCARG(uap
, ou
), SCARG(uap
, ex
), ts
, NULL
);