sys_generic.c (89306) | sys_generic.c (89319) |
---|---|
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 89306 2002-01-13 11:58:06Z alfred $ | 39 * $FreeBSD: head/sys/kern/sys_generic.c 89319 2002-01-14 00:13:45Z 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> --- 550 unchanged lines hidden (view full) --- 598 * MPSAFE 599 */ 600/* ARGSUSED */ 601int 602ioctl(td, uap) 603 struct thread *td; 604 register struct ioctl_args *uap; 605{ | 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> --- 550 unchanged lines hidden (view full) --- 598 * MPSAFE 599 */ 600/* ARGSUSED */ 601int 602ioctl(td, uap) 603 struct thread *td; 604 register struct ioctl_args *uap; 605{ |
606 register struct file *fp; | 606 struct file *fp; |
607 register struct filedesc *fdp; 608 register u_long com; 609 int error = 0; 610 register u_int size; 611 caddr_t data, memp; 612 int tmp; 613#define STK_PARAMS 128 614 union { 615 char stkbuf[STK_PARAMS]; 616 long align; 617 } ubuf; 618 | 607 register struct filedesc *fdp; 608 register u_long com; 609 int error = 0; 610 register u_int size; 611 caddr_t data, memp; 612 int tmp; 613#define STK_PARAMS 128 614 union { 615 char stkbuf[STK_PARAMS]; 616 long align; 617 } ubuf; 618 |
619 fp = ffind_hold(td, uap->fd); 620 if (fp == NULL) 621 return (EBADF); | 619 if ((error = fget(td, uap->fd, &fp)) != 0) 620 return (error); |
622 if ((fp->f_flag & (FREAD | FWRITE)) == 0) { 623 fdrop(fp, td); 624 return (EBADF); 625 } 626 fdp = td->td_proc->p_fd; 627 switch (com = uap->com) { 628 case FIONCLEX: 629 FILEDESC_LOCK(fdp); --- 357 unchanged lines hidden (view full) --- 987 if (ibits[msk] == NULL) 988 continue; 989 for (i = 0; i < nfd; i += NFDBITS) { 990 bits = ibits[msk][i/NFDBITS]; 991 /* ffs(int mask) not portable, fd_mask is long */ 992 for (fd = i; bits && fd < nfd; fd++, bits >>= 1) { 993 if (!(bits & 1)) 994 continue; | 621 if ((fp->f_flag & (FREAD | FWRITE)) == 0) { 622 fdrop(fp, td); 623 return (EBADF); 624 } 625 fdp = td->td_proc->p_fd; 626 switch (com = uap->com) { 627 case FIONCLEX: 628 FILEDESC_LOCK(fdp); --- 357 unchanged lines hidden (view full) --- 986 if (ibits[msk] == NULL) 987 continue; 988 for (i = 0; i < nfd; i += NFDBITS) { 989 bits = ibits[msk][i/NFDBITS]; 990 /* ffs(int mask) not portable, fd_mask is long */ 991 for (fd = i; bits && fd < nfd; fd++, bits >>= 1) { 992 if (!(bits & 1)) 993 continue; |
995 fp = ffind_hold(td, fd); 996 if (fp == NULL) | 994 if (fget(td, fd, &fp)) |
997 return (EBADF); 998 if (fo_poll(fp, flag[msk], fp->f_cred, td)) { 999 obits[msk][(fd)/NFDBITS] |= 1000 ((fd_mask)1 << ((fd) % NFDBITS)); 1001 n++; 1002 } 1003 fdrop(fp, td); 1004 } --- 353 unchanged lines hidden --- | 995 return (EBADF); 996 if (fo_poll(fp, flag[msk], fp->f_cred, td)) { 997 obits[msk][(fd)/NFDBITS] |= 998 ((fd_mask)1 << ((fd) % NFDBITS)); 999 n++; 1000 } 1001 fdrop(fp, td); 1002 } --- 353 unchanged lines hidden --- |