Deleted Added
full compact
sys_generic.c (3485) sys_generic.c (3568)
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 * $Id: sys_generic.c,v 1.7 1994/10/02 17:35:24 phk Exp $
39 * $Id: sys_generic.c,v 1.1 1994/10/13 12:13:00 sos Exp sos $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/filedesc.h>
45#include <sys/ioctl.h>
46#include <sys/file.h>
47#include <sys/proc.h>

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

52#include <sys/uio.h>
53#include <sys/kernel.h>
54#include <sys/stat.h>
55#include <sys/malloc.h>
56#ifdef KTRACE
57#include <sys/ktrace.h>
58#endif
59#include <vm/vm.h>
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/filedesc.h>
45#include <sys/ioctl.h>
46#include <sys/file.h>
47#include <sys/proc.h>

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

52#include <sys/uio.h>
53#include <sys/kernel.h>
54#include <sys/stat.h>
55#include <sys/malloc.h>
56#ifdef KTRACE
57#include <sys/ktrace.h>
58#endif
59#include <vm/vm.h>
60#include <i386/ibcs2/ibcs2.h>
60
61int selscan __P((struct proc *, fd_set *, fd_set *, int, int *));
62
63/*
64 * Read system call.
65 */
66struct read_args {
67 int fd;

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

402 /*
403 * Interpret high order word to find amount of data to be
404 * copied to/from the user's address space.
405 */
406 size = IOCPARM_LEN(com);
407 if (size > IOCPARM_MAX)
408 return (ENOTTY);
409 memp = NULL;
61
62int selscan __P((struct proc *, fd_set *, fd_set *, int, int *));
63
64/*
65 * Read system call.
66 */
67struct read_args {
68 int fd;

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

403 /*
404 * Interpret high order word to find amount of data to be
405 * copied to/from the user's address space.
406 */
407 size = IOCPARM_LEN(com);
408 if (size > IOCPARM_MAX)
409 return (ENOTTY);
410 memp = NULL;
411#ifdef COMPAT_IBCS2
412 if (size + IBCS2_RETVAL_SIZE > sizeof (stkbuf)) {
413 memp = (caddr_t)malloc((u_long)size + IBCS2_RETVAL_SIZE,
414 M_IOCTLOPS, M_WAITOK);
415 data = memp;
416 } else
417 data = stkbuf;
418 *(int *)(data - IBCS2_RETVAL_SIZE) = IBCS2_MAGIC_IN;
419 *(int *)(data - (IBCS2_RETVAL_SIZE - sizeof(int))) = 0;
420 *(int *)(data - (IBCS2_RETVAL_SIZE - 2*sizeof(int))) = 0;
421#else
410 if (size > sizeof (stkbuf)) {
411 memp = (caddr_t)malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
412 data = memp;
413 } else
414 data = stkbuf;
422 if (size > sizeof (stkbuf)) {
423 memp = (caddr_t)malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
424 data = memp;
425 } else
426 data = stkbuf;
427#endif
415 if (com&IOC_IN) {
416 if (size) {
417 error = copyin(uap->data, data, (u_int)size);
418 if (error) {
419 if (memp)
420 free(memp, M_IOCTLOPS);
421 return (error);
422 }
423 } else
424 *(caddr_t *)data = uap->data;
425 } else if ((com&IOC_OUT) && size)
426 /*
427 * Zero the buffer so the user always
428 * gets back something deterministic.
429 */
430 bzero(data, size);
431 else if (com&IOC_VOID)
432 *(caddr_t *)data = uap->data;
428 if (com&IOC_IN) {
429 if (size) {
430 error = copyin(uap->data, data, (u_int)size);
431 if (error) {
432 if (memp)
433 free(memp, M_IOCTLOPS);
434 return (error);
435 }
436 } else
437 *(caddr_t *)data = uap->data;
438 } else if ((com&IOC_OUT) && size)
439 /*
440 * Zero the buffer so the user always
441 * gets back something deterministic.
442 */
443 bzero(data, size);
444 else if (com&IOC_VOID)
445 *(caddr_t *)data = uap->data;
446#ifdef COMPAT_IBCS2
447 else if (com)
448 /*
449 * Pick up such things as NIOCxx.
450 * Any copyouts will have to be done prior
451 * to return by their servicing code.
452 */
453 *(caddr_t *)data = uap->data;
454#endif
433
434 switch (com) {
435
436 case FIONBIO:
437 if ((tmp = *(int *)data))
438 fp->f_flag |= FNONBLOCK;
439 else
440 fp->f_flag &= ~FNONBLOCK;

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

485 /*
486 * Copy any data to user, size was
487 * already set and checked above.
488 */
489 if (error == 0 && (com&IOC_OUT) && size)
490 error = copyout(data, uap->data, (u_int)size);
491 break;
492 }
455
456 switch (com) {
457
458 case FIONBIO:
459 if ((tmp = *(int *)data))
460 fp->f_flag |= FNONBLOCK;
461 else
462 fp->f_flag &= ~FNONBLOCK;

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

507 /*
508 * Copy any data to user, size was
509 * already set and checked above.
510 */
511 if (error == 0 && (com&IOC_OUT) && size)
512 error = copyout(data, uap->data, (u_int)size);
513 break;
514 }
515#ifdef COMPAT_IBCS2
516 if ((*(int *)(data - IBCS2_RETVAL_SIZE)) == IBCS2_MAGIC_OUT) {
517 retval[0] = *(int *)(data-(IBCS2_RETVAL_SIZE - sizeof(int)));
518 retval[1] = *(int *)(data-(IBCS2_RETVAL_SIZE - 2*sizeof(int)));
519 }
520#endif
493 if (memp)
494 free(memp, M_IOCTLOPS);
495 return (error);
496}
497
498int selwait, nselcoll;
499
500/*

--- 194 unchanged lines hidden ---
521 if (memp)
522 free(memp, M_IOCTLOPS);
523 return (error);
524}
525
526int selwait, nselcoll;
527
528/*

--- 194 unchanged lines hidden ---