Deleted Added
full compact
sys_generic.c (107849) sys_generic.c (109623)
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.

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

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
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.

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

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
39 * $FreeBSD: head/sys/kern/sys_generic.c 107849 2002-12-14 01:56:26Z alfred $
39 * $FreeBSD: head/sys/kern/sys_generic.c 109623 2003-01-21 08:56:16Z alfred $
40 */
41
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>
47#include <sys/filedesc.h>

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

243 needfree = NULL;
244 /* note: can't use iovlen until iovcnt is validated */
245 iovlen = uap->iovcnt * sizeof (struct iovec);
246 if (uap->iovcnt > UIO_SMALLIOV) {
247 if (uap->iovcnt > UIO_MAXIOV) {
248 error = EINVAL;
249 goto done;
250 }
40 */
41
42#include "opt_ktrace.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/sysproto.h>
47#include <sys/filedesc.h>

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

243 needfree = NULL;
244 /* note: can't use iovlen until iovcnt is validated */
245 iovlen = uap->iovcnt * sizeof (struct iovec);
246 if (uap->iovcnt > UIO_SMALLIOV) {
247 if (uap->iovcnt > UIO_MAXIOV) {
248 error = EINVAL;
249 goto done;
250 }
251 MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
251 MALLOC(iov, struct iovec *, iovlen, M_IOV, 0);
252 needfree = iov;
253 } else
254 iov = aiov;
255 auio.uio_iov = iov;
256 auio.uio_iovcnt = uap->iovcnt;
257 auio.uio_rw = UIO_READ;
258 auio.uio_segflg = UIO_USERSPACE;
259 auio.uio_td = td;

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

269 auio.uio_resid += iov->iov_len;
270 iov++;
271 }
272#ifdef KTRACE
273 /*
274 * if tracing, save a copy of iovec
275 */
276 if (KTRPOINT(td, KTR_GENIO)) {
252 needfree = iov;
253 } else
254 iov = aiov;
255 auio.uio_iov = iov;
256 auio.uio_iovcnt = uap->iovcnt;
257 auio.uio_rw = UIO_READ;
258 auio.uio_segflg = UIO_USERSPACE;
259 auio.uio_td = td;

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

269 auio.uio_resid += iov->iov_len;
270 iov++;
271 }
272#ifdef KTRACE
273 /*
274 * if tracing, save a copy of iovec
275 */
276 if (KTRPOINT(td, KTR_GENIO)) {
277 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
277 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, 0);
278 bcopy(auio.uio_iov, ktriov, iovlen);
279 ktruio = auio;
280 }
281#endif
282 cnt = auio.uio_resid;
283 if ((error = fo_read(fp, &auio, td->td_ucred, 0, td))) {
284 if (auio.uio_resid != cnt && (error == ERESTART ||
285 error == EINTR || error == EWOULDBLOCK))

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

475 /* note: can't use iovlen until iovcnt is validated */
476 iovlen = uap->iovcnt * sizeof (struct iovec);
477 if (uap->iovcnt > UIO_SMALLIOV) {
478 if (uap->iovcnt > UIO_MAXIOV) {
479 needfree = NULL;
480 error = EINVAL;
481 goto done;
482 }
278 bcopy(auio.uio_iov, ktriov, iovlen);
279 ktruio = auio;
280 }
281#endif
282 cnt = auio.uio_resid;
283 if ((error = fo_read(fp, &auio, td->td_ucred, 0, td))) {
284 if (auio.uio_resid != cnt && (error == ERESTART ||
285 error == EINTR || error == EWOULDBLOCK))

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

475 /* note: can't use iovlen until iovcnt is validated */
476 iovlen = uap->iovcnt * sizeof (struct iovec);
477 if (uap->iovcnt > UIO_SMALLIOV) {
478 if (uap->iovcnt > UIO_MAXIOV) {
479 needfree = NULL;
480 error = EINVAL;
481 goto done;
482 }
483 MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
483 MALLOC(iov, struct iovec *, iovlen, M_IOV, 0);
484 needfree = iov;
485 } else {
486 iov = aiov;
487 needfree = NULL;
488 }
489 auio.uio_iov = iov;
490 auio.uio_iovcnt = uap->iovcnt;
491 auio.uio_rw = UIO_WRITE;

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

503 auio.uio_resid += iov->iov_len;
504 iov++;
505 }
506#ifdef KTRACE
507 /*
508 * if tracing, save a copy of iovec and uio
509 */
510 if (KTRPOINT(td, KTR_GENIO)) {
484 needfree = iov;
485 } else {
486 iov = aiov;
487 needfree = NULL;
488 }
489 auio.uio_iov = iov;
490 auio.uio_iovcnt = uap->iovcnt;
491 auio.uio_rw = UIO_WRITE;

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

503 auio.uio_resid += iov->iov_len;
504 iov++;
505 }
506#ifdef KTRACE
507 /*
508 * if tracing, save a copy of iovec and uio
509 */
510 if (KTRPOINT(td, KTR_GENIO)) {
511 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
511 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, 0);
512 bcopy(auio.uio_iov, ktriov, iovlen);
513 ktruio = auio;
514 }
515#endif
516 cnt = auio.uio_resid;
517 if (fp->f_type == DTYPE_VNODE)
518 bwillwrite();
519 if ((error = fo_write(fp, &auio, td->td_ucred, 0, td))) {

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

613 if (size > IOCPARM_MAX) {
614 fdrop(fp, td);
615 mtx_unlock(&Giant);
616 return (ENOTTY);
617 }
618
619 memp = NULL;
620 if (size > sizeof (ubuf.stkbuf)) {
512 bcopy(auio.uio_iov, ktriov, iovlen);
513 ktruio = auio;
514 }
515#endif
516 cnt = auio.uio_resid;
517 if (fp->f_type == DTYPE_VNODE)
518 bwillwrite();
519 if ((error = fo_write(fp, &auio, td->td_ucred, 0, td))) {

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

613 if (size > IOCPARM_MAX) {
614 fdrop(fp, td);
615 mtx_unlock(&Giant);
616 return (ENOTTY);
617 }
618
619 memp = NULL;
620 if (size > sizeof (ubuf.stkbuf)) {
621 memp = malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
621 memp = malloc((u_long)size, M_IOCTLOPS, 0);
622 data = memp;
623 } else {
624 data = ubuf.stkbuf;
625 }
626 if (com&IOC_IN) {
627 if (size) {
628 error = copyin(uap->data, data, (u_int)size);
629 if (error) {

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

763 nbufbytes += 2 * ncpbytes;
764 if (fd_ou != NULL)
765 nbufbytes += 2 * ncpbytes;
766 if (fd_ex != NULL)
767 nbufbytes += 2 * ncpbytes;
768 if (nbufbytes <= sizeof s_selbits)
769 selbits = &s_selbits[0];
770 else
622 data = memp;
623 } else {
624 data = ubuf.stkbuf;
625 }
626 if (com&IOC_IN) {
627 if (size) {
628 error = copyin(uap->data, data, (u_int)size);
629 if (error) {

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

763 nbufbytes += 2 * ncpbytes;
764 if (fd_ou != NULL)
765 nbufbytes += 2 * ncpbytes;
766 if (fd_ex != NULL)
767 nbufbytes += 2 * ncpbytes;
768 if (nbufbytes <= sizeof s_selbits)
769 selbits = &s_selbits[0];
770 else
771 selbits = malloc(nbufbytes, M_SELECT, M_WAITOK);
771 selbits = malloc(nbufbytes, M_SELECT, 0);
772
773 /*
774 * Assign pointers into the bit buffers and fetch the input bits.
775 * Put the output buffers together so that they can be bzeroed
776 * together.
777 */
778 sbp = selbits;
779#define getbits(name, x) \

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

963 */
964 if ((nfds > td->td_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur) &&
965 (nfds > FD_SETSIZE)) {
966 error = EINVAL;
967 goto done2;
968 }
969 ni = nfds * sizeof(struct pollfd);
970 if (ni > sizeof(smallbits))
772
773 /*
774 * Assign pointers into the bit buffers and fetch the input bits.
775 * Put the output buffers together so that they can be bzeroed
776 * together.
777 */
778 sbp = selbits;
779#define getbits(name, x) \

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

963 */
964 if ((nfds > td->td_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur) &&
965 (nfds > FD_SETSIZE)) {
966 error = EINVAL;
967 goto done2;
968 }
969 ni = nfds * sizeof(struct pollfd);
970 if (ni > sizeof(smallbits))
971 bits = malloc(ni, M_TEMP, M_WAITOK);
971 bits = malloc(ni, M_TEMP, 0);
972 else
973 bits = smallbits;
974 error = copyin(uap->fds, bits, ni);
975 if (error)
976 goto done_nosellock;
977 if (uap->timeout != INFTIM) {
978 atv.tv_sec = uap->timeout / 1000;
979 atv.tv_usec = (uap->timeout % 1000) * 1000;

--- 246 unchanged lines hidden ---
972 else
973 bits = smallbits;
974 error = copyin(uap->fds, bits, ni);
975 if (error)
976 goto done_nosellock;
977 if (uap->timeout != INFTIM) {
978 atv.tv_sec = uap->timeout / 1000;
979 atv.tv_usec = (uap->timeout % 1000) * 1000;

--- 246 unchanged lines hidden ---