Deleted Added
full compact
sys_generic.c (315462) sys_generic.c (315553)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: stable/11/sys/kern/sys_generic.c 315462 2017-03-17 21:03:54Z mmokhi $");
38__FBSDID("$FreeBSD: stable/11/sys/kern/sys_generic.c 315553 2017-03-19 14:46:40Z trasz $");
39
40#include "opt_capsicum.h"
41#include "opt_compat.h"
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>

--- 168 unchanged lines hidden (view full) ---

215 int fd;
216 void *buf;
217 size_t nbyte;
218 int pad;
219 off_t offset;
220};
221#endif
222int
39
40#include "opt_capsicum.h"
41#include "opt_compat.h"
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>

--- 168 unchanged lines hidden (view full) ---

215 int fd;
216 void *buf;
217 size_t nbyte;
218 int pad;
219 off_t offset;
220};
221#endif
222int
223sys_pread(td, uap)
224 struct thread *td;
225 struct pread_args *uap;
223sys_pread(struct thread *td, struct pread_args *uap)
226{
224{
225
226 return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
227}
228
229int
230kern_pread(struct thread *td, int fd, void *buf, size_t nbyte, off_t offset)
231{
227 struct uio auio;
228 struct iovec aiov;
229 int error;
230
232 struct uio auio;
233 struct iovec aiov;
234 int error;
235
231 if (uap->nbyte > IOSIZE_MAX)
236 if (nbyte > IOSIZE_MAX)
232 return (EINVAL);
237 return (EINVAL);
233 aiov.iov_base = uap->buf;
234 aiov.iov_len = uap->nbyte;
238 aiov.iov_base = buf;
239 aiov.iov_len = nbyte;
235 auio.uio_iov = &aiov;
236 auio.uio_iovcnt = 1;
240 auio.uio_iov = &aiov;
241 auio.uio_iovcnt = 1;
237 auio.uio_resid = uap->nbyte;
242 auio.uio_resid = nbyte;
238 auio.uio_segflg = UIO_USERSPACE;
243 auio.uio_segflg = UIO_USERSPACE;
239 error = kern_preadv(td, uap->fd, &auio, uap->offset);
240 return(error);
244 error = kern_preadv(td, fd, &auio, offset);
245 return (error);
241}
242
243#if defined(COMPAT_FREEBSD6)
244int
246}
247
248#if defined(COMPAT_FREEBSD6)
249int
245freebsd6_pread(td, uap)
246 struct thread *td;
247 struct freebsd6_pread_args *uap;
250freebsd6_pread(struct thread *td, struct freebsd6_pread_args *uap)
248{
251{
249 struct pread_args oargs;
250
252
251 oargs.fd = uap->fd;
252 oargs.buf = uap->buf;
253 oargs.nbyte = uap->nbyte;
254 oargs.offset = uap->offset;
255 return (sys_pread(td, &oargs));
253 return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
256}
257#endif
258
259/*
260 * Scatter read system call.
261 */
262#ifndef _SYS_SYSPROTO_H_
263struct readv_args {

--- 167 unchanged lines hidden (view full) ---

431 int fd;
432 const void *buf;
433 size_t nbyte;
434 int pad;
435 off_t offset;
436};
437#endif
438int
254}
255#endif
256
257/*
258 * Scatter read system call.
259 */
260#ifndef _SYS_SYSPROTO_H_
261struct readv_args {

--- 167 unchanged lines hidden (view full) ---

429 int fd;
430 const void *buf;
431 size_t nbyte;
432 int pad;
433 off_t offset;
434};
435#endif
436int
439sys_pwrite(td, uap)
440 struct thread *td;
441 struct pwrite_args *uap;
437sys_pwrite(struct thread *td, struct pwrite_args *uap)
442{
438{
439
440 return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
441}
442
443int
444kern_pwrite(struct thread *td, int fd, const void *buf, size_t nbyte,
445 off_t offset)
446{
443 struct uio auio;
444 struct iovec aiov;
445 int error;
446
447 struct uio auio;
448 struct iovec aiov;
449 int error;
450
447 if (uap->nbyte > IOSIZE_MAX)
451 if (nbyte > IOSIZE_MAX)
448 return (EINVAL);
452 return (EINVAL);
449 aiov.iov_base = (void *)(uintptr_t)uap->buf;
450 aiov.iov_len = uap->nbyte;
453 aiov.iov_base = (void *)(uintptr_t)buf;
454 aiov.iov_len = nbyte;
451 auio.uio_iov = &aiov;
452 auio.uio_iovcnt = 1;
455 auio.uio_iov = &aiov;
456 auio.uio_iovcnt = 1;
453 auio.uio_resid = uap->nbyte;
457 auio.uio_resid = nbyte;
454 auio.uio_segflg = UIO_USERSPACE;
458 auio.uio_segflg = UIO_USERSPACE;
455 error = kern_pwritev(td, uap->fd, &auio, uap->offset);
459 error = kern_pwritev(td, fd, &auio, offset);
456 return(error);
457}
458
459#if defined(COMPAT_FREEBSD6)
460int
460 return(error);
461}
462
463#if defined(COMPAT_FREEBSD6)
464int
461freebsd6_pwrite(td, uap)
462 struct thread *td;
463 struct freebsd6_pwrite_args *uap;
465freebsd6_pwrite(struct thread *td, struct freebsd6_pwrite_args *uap)
464{
466{
465 struct pwrite_args oargs;
466
467
467 oargs.fd = uap->fd;
468 oargs.buf = uap->buf;
469 oargs.nbyte = uap->nbyte;
470 oargs.offset = uap->offset;
471 return (sys_pwrite(td, &oargs));
468 return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
472}
473#endif
474
475/*
476 * Gather write system call.
477 */
478#ifndef _SYS_SYSPROTO_H_
479struct writev_args {

--- 1474 unchanged lines hidden ---
469}
470#endif
471
472/*
473 * Gather write system call.
474 */
475#ifndef _SYS_SYSPROTO_H_
476struct writev_args {

--- 1474 unchanged lines hidden ---