Deleted Added
full compact
sys_pipe.c (230955) sys_pipe.c (233353)
1/*-
2 * Copyright (c) 1996 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

84 * both directions of a pipe.
85 *
86 * As pipelock() may have to sleep before it can acquire the flag, it
87 * is important to reread all data after a call to pipelock(); everything
88 * in the structure may have changed.
89 */
90
91#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1996 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

84 * both directions of a pipe.
85 *
86 * As pipelock() may have to sleep before it can acquire the flag, it
87 * is important to reread all data after a call to pipelock(); everything
88 * in the structure may have changed.
89 */
90
91#include <sys/cdefs.h>
92__FBSDID("$FreeBSD: stable/9/sys/kern/sys_pipe.c 230955 2012-02-03 20:24:18Z jilles $");
92__FBSDID("$FreeBSD: stable/9/sys/kern/sys_pipe.c 233353 2012-03-23 11:26:54Z kib $");
93
94#include <sys/param.h>
95#include <sys/systm.h>
96#include <sys/conf.h>
97#include <sys/fcntl.h>
98#include <sys/file.h>
99#include <sys/filedesc.h>
100#include <sys/filio.h>

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

580 struct uio *uio;
581 struct ucred *active_cred;
582 struct thread *td;
583 int flags;
584{
585 struct pipe *rpipe = fp->f_data;
586 int error;
587 int nread = 0;
93
94#include <sys/param.h>
95#include <sys/systm.h>
96#include <sys/conf.h>
97#include <sys/fcntl.h>
98#include <sys/file.h>
99#include <sys/filedesc.h>
100#include <sys/filio.h>

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

580 struct uio *uio;
581 struct ucred *active_cred;
582 struct thread *td;
583 int flags;
584{
585 struct pipe *rpipe = fp->f_data;
586 int error;
587 int nread = 0;
588 u_int size;
588 int size;
589
590 PIPE_LOCK(rpipe);
591 ++rpipe->pipe_busy;
592 error = pipelock(rpipe, 1);
593 if (error)
594 goto unlocked_error;
595
596#ifdef MAC

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

612 while (uio->uio_resid) {
613 /*
614 * normal pipe buffer receive
615 */
616 if (rpipe->pipe_buffer.cnt > 0) {
617 size = rpipe->pipe_buffer.size - rpipe->pipe_buffer.out;
618 if (size > rpipe->pipe_buffer.cnt)
619 size = rpipe->pipe_buffer.cnt;
589
590 PIPE_LOCK(rpipe);
591 ++rpipe->pipe_busy;
592 error = pipelock(rpipe, 1);
593 if (error)
594 goto unlocked_error;
595
596#ifdef MAC

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

612 while (uio->uio_resid) {
613 /*
614 * normal pipe buffer receive
615 */
616 if (rpipe->pipe_buffer.cnt > 0) {
617 size = rpipe->pipe_buffer.size - rpipe->pipe_buffer.out;
618 if (size > rpipe->pipe_buffer.cnt)
619 size = rpipe->pipe_buffer.cnt;
620 if (size > (u_int) uio->uio_resid)
621 size = (u_int) uio->uio_resid;
620 if (size > uio->uio_resid)
621 size = uio->uio_resid;
622
623 PIPE_UNLOCK(rpipe);
624 error = uiomove(
625 &rpipe->pipe_buffer.buffer[rpipe->pipe_buffer.out],
626 size, uio);
627 PIPE_LOCK(rpipe);
628 if (error)
629 break;

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

645 }
646 nread += size;
647#ifndef PIPE_NODIRECT
648 /*
649 * Direct copy, bypassing a kernel buffer.
650 */
651 } else if ((size = rpipe->pipe_map.cnt) &&
652 (rpipe->pipe_state & PIPE_DIRECTW)) {
622
623 PIPE_UNLOCK(rpipe);
624 error = uiomove(
625 &rpipe->pipe_buffer.buffer[rpipe->pipe_buffer.out],
626 size, uio);
627 PIPE_LOCK(rpipe);
628 if (error)
629 break;

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

645 }
646 nread += size;
647#ifndef PIPE_NODIRECT
648 /*
649 * Direct copy, bypassing a kernel buffer.
650 */
651 } else if ((size = rpipe->pipe_map.cnt) &&
652 (rpipe->pipe_state & PIPE_DIRECTW)) {
653 if (size > (u_int) uio->uio_resid)
653 if (size > uio->uio_resid)
654 size = (u_int) uio->uio_resid;
655
656 PIPE_UNLOCK(rpipe);
657 error = uiomove_fromphys(rpipe->pipe_map.ms,
658 rpipe->pipe_map.pos, size, uio);
659 PIPE_LOCK(rpipe);
660 if (error)
661 break;

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

759{
760 u_int size;
761 int i;
762
763 PIPE_LOCK_ASSERT(wpipe, MA_NOTOWNED);
764 KASSERT(wpipe->pipe_state & PIPE_DIRECTW,
765 ("Clone attempt on non-direct write pipe!"));
766
654 size = (u_int) uio->uio_resid;
655
656 PIPE_UNLOCK(rpipe);
657 error = uiomove_fromphys(rpipe->pipe_map.ms,
658 rpipe->pipe_map.pos, size, uio);
659 PIPE_LOCK(rpipe);
660 if (error)
661 break;

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

759{
760 u_int size;
761 int i;
762
763 PIPE_LOCK_ASSERT(wpipe, MA_NOTOWNED);
764 KASSERT(wpipe->pipe_state & PIPE_DIRECTW,
765 ("Clone attempt on non-direct write pipe!"));
766
767 size = (u_int) uio->uio_iov->iov_len;
768 if (size > wpipe->pipe_buffer.size)
769 size = wpipe->pipe_buffer.size;
767 if (uio->uio_iov->iov_len > wpipe->pipe_buffer.size)
768 size = wpipe->pipe_buffer.size;
769 else
770 size = uio->uio_iov->iov_len;
770
771 if ((i = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map,
772 (vm_offset_t)uio->uio_iov->iov_base, size, VM_PROT_READ,
773 wpipe->pipe_map.ms, PIPENPAGES)) < 0)
774 return (EFAULT);
775
776/*
777 * set up the control block

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

955pipe_write(fp, uio, active_cred, flags, td)
956 struct file *fp;
957 struct uio *uio;
958 struct ucred *active_cred;
959 struct thread *td;
960 int flags;
961{
962 int error = 0;
771
772 if ((i = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map,
773 (vm_offset_t)uio->uio_iov->iov_base, size, VM_PROT_READ,
774 wpipe->pipe_map.ms, PIPENPAGES)) < 0)
775 return (EFAULT);
776
777/*
778 * set up the control block

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

956pipe_write(fp, uio, active_cred, flags, td)
957 struct file *fp;
958 struct uio *uio;
959 struct ucred *active_cred;
960 struct thread *td;
961 int flags;
962{
963 int error = 0;
963 int desiredsize, orig_resid;
964 int desiredsize;
965 ssize_t orig_resid;
964 struct pipe *wpipe, *rpipe;
965
966 rpipe = fp->f_data;
967 wpipe = rpipe->pipe_peer;
968
969 PIPE_LOCK(rpipe);
970 error = pipelock(wpipe, 1);
971 if (error) {

--- 700 unchanged lines hidden ---
966 struct pipe *wpipe, *rpipe;
967
968 rpipe = fp->f_data;
969 wpipe = rpipe->pipe_peer;
970
971 PIPE_LOCK(rpipe);
972 error = pipelock(wpipe, 1);
973 if (error) {

--- 700 unchanged lines hidden ---