diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-10-26 12:03:29 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-10-26 12:03:29 +0000 |
commit | eb46b9853439c27012a22a86f3d9139930a9e87a (patch) | |
tree | 0668f2d444b8c90d902fc4d94aaf484b512bab93 /sys/compat/linux | |
parent | 322ae2c6b01056eccf34722ee78713e1b3337123 (diff) |
- every new fd created by falloc() is marked as larval and should not be used
any anyone. Every caller of falloc matures the fd when it's usable.
- Since every lookup in the fd table must now check this flag and all of
them do the same thing, move all the necessary checks into a function -
fd_getfile.
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_blkio.c | 14 | ||||
-rw-r--r-- | sys/compat/linux/linux_cdrom.c | 5 | ||||
-rw-r--r-- | sys/compat/linux/linux_fdio.c | 14 | ||||
-rw-r--r-- | sys/compat/linux/linux_file.c | 7 | ||||
-rw-r--r-- | sys/compat/linux/linux_hdio.c | 14 | ||||
-rw-r--r-- | sys/compat/linux/linux_termios.c | 5 |
6 files changed, 13 insertions, 46 deletions
diff --git a/sys/compat/linux/linux_blkio.c b/sys/compat/linux/linux_blkio.c index 41e9e7c8817..b09dc192aa9 100644 --- a/sys/compat/linux/linux_blkio.c +++ b/sys/compat/linux/linux_blkio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_blkio.c,v 1.1 2001/04/09 06:53:44 tholo Exp $ */ +/* $OpenBSD: linux_blkio.c,v 1.2 2001/10/26 12:03:27 art Exp $ */ /* $NetBSD: linux_blkio.c,v 1.3 2001/01/18 17:48:04 tv Exp $ */ /* @@ -69,18 +69,8 @@ linux_ioctl_blkio(struct proc *p, struct linux_sys_ioctl_args *uap, struct disklabel label; fdp = p->p_fd; -#if 1 - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) return (EBADF); -#else - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL || - (fp->f_iflags & FIF_WANTCLOSE) != 0) - return (EBADF); - - FILE_USE(fp); -#endif error = 0; ioctlf = fp->f_ops->fo_ioctl; com = SCARG(uap, com); diff --git a/sys/compat/linux/linux_cdrom.c b/sys/compat/linux/linux_cdrom.c index 365a198e879..cbcb0256082 100644 --- a/sys/compat/linux/linux_cdrom.c +++ b/sys/compat/linux/linux_cdrom.c @@ -1,5 +1,5 @@ -/* $OpenBSD: linux_cdrom.c,v 1.5 2001/05/24 06:00:08 jasoni Exp $ */ +/* $OpenBSD: linux_cdrom.c,v 1.6 2001/10/26 12:03:27 art Exp $ */ /* * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> * All rights reserved. @@ -108,8 +108,7 @@ linux_ioctl_cdrom(p, v, retval) fdp = p->p_fd; - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) return (EBADF); if ((fp->f_flag & (FREAD | FWRITE)) == 0) diff --git a/sys/compat/linux/linux_fdio.c b/sys/compat/linux/linux_fdio.c index 7c8db69da10..d394d17399a 100644 --- a/sys/compat/linux/linux_fdio.c +++ b/sys/compat/linux/linux_fdio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_fdio.c,v 1.1 2001/04/09 06:53:44 tholo Exp $ */ +/* $OpenBSD: linux_fdio.c,v 1.2 2001/10/26 12:03:27 art Exp $ */ /* $NetBSD: linux_fdio.c,v 1.1 2000/12/10 14:12:16 fvdl Exp $ */ /* @@ -75,18 +75,8 @@ linux_ioctl_fdio(struct proc *p, struct linux_sys_ioctl_args *uap, com = (u_long)SCARG(uap, data); fdp = p->p_fd; -#if 1 - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + if ((fp = fd_getfile(fdp, SCARG(uap, fd)) == NULL) return (EBADF); -#else - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL || - (fp->f_iflags & FIF_WANTCLOSE) != 0) - return (EBADF); - - FILE_USE(fp); -#endif com = SCARG(uap, com); ioctlf = fp->f_ops->fo_ioctl; diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 03d4f02e776..c7e1ba769cc 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_file.c,v 1.17 2001/07/03 15:32:34 jasoni Exp $ */ +/* $OpenBSD: linux_file.c,v 1.18 2001/10/26 12:03:27 art Exp $ */ /* $NetBSD: linux_file.c,v 1.15 1996/05/20 01:59:09 fvdl Exp $ */ /* @@ -390,9 +390,8 @@ linux_sys_fcntl(p, v, retval) * does not exist. */ fdp = p->p_fd; - if ((u_int)fd >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[fd]) == NULL) - return EBADF; + if ((fp = fd_getfile(fdp, fd)) == NULL) + return (EBADF); if (fp->f_type == DTYPE_SOCKET) { cmd = cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN; break; diff --git a/sys/compat/linux/linux_hdio.c b/sys/compat/linux/linux_hdio.c index 1e4c6c03d3a..bcc3ac62298 100644 --- a/sys/compat/linux/linux_hdio.c +++ b/sys/compat/linux/linux_hdio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_hdio.c,v 1.1 2001/04/09 06:53:45 tholo Exp $ */ +/* $OpenBSD: linux_hdio.c,v 1.2 2001/10/26 12:03:27 art Exp $ */ /* $NetBSD: linux_hdio.c,v 1.1 2000/12/10 14:12:17 fvdl Exp $ */ /* @@ -77,18 +77,8 @@ linux_ioctl_hdio(struct proc *p, struct linux_sys_ioctl_args *uap, struct linux_hd_big_geometry hdg_big; fdp = p->p_fd; -#if 1 - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) return (EBADF); -#else - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL || - (fp->f_iflags & FIF_WANTCLOSE) != 0) - return (EBADF); - - FILE_USE(fp); -#endif com = SCARG(uap, com); ioctlf = fp->f_ops->fo_ioctl; diff --git a/sys/compat/linux/linux_termios.c b/sys/compat/linux/linux_termios.c index 810f90379f7..e010560fce7 100644 --- a/sys/compat/linux/linux_termios.c +++ b/sys/compat/linux/linux_termios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_termios.c,v 1.9 2001/05/24 06:00:09 jasoni Exp $ */ +/* $OpenBSD: linux_termios.c,v 1.10 2001/10/26 12:03:27 art Exp $ */ /* $NetBSD: linux_termios.c,v 1.3 1996/04/05 00:01:54 christos Exp $ */ /* @@ -460,8 +460,7 @@ linux_ioctl_termios(p, v, retval) int error; fdp = p->p_fd; - if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) return (EBADF); if ((fp->f_flag & (FREAD | FWRITE)) == 0) |