diff options
author | alfred <alfred@FreeBSD.org> | 2002-01-14 00:13:45 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-01-14 00:13:45 +0000 |
commit | 1f82bc18d1d1e906cd9ed68039acb051fa6e11cf (patch) | |
tree | fe7842143c9585ef2ebb793d812ec71cc4488a51 /sys/compat | |
parent | c4988e25d265bba2c63409a8c8b8708c13d8525e (diff) | |
download | FreeBSD-src-1f82bc18d1d1e906cd9ed68039acb051fa6e11cf.zip FreeBSD-src-1f82bc18d1d1e906cd9ed68039acb051fa6e11cf.tar.gz |
Replace ffind_* with fget calls.
Make fget MPsafe.
Make fgetvp and fgetsock use the fget subsystem to reduce code bloat.
Push giant down in fpathconf().
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_file.c | 16 | ||||
-rw-r--r-- | sys/compat/linux/linux_ioctl.c | 26 | ||||
-rw-r--r-- | sys/compat/linux/linux_stats.c | 5 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_fcntl.c | 35 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_filio.c | 3 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_ioctl.c | 5 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_stream.c | 6 |
7 files changed, 38 insertions, 58 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 54f4584..1dfa4a1 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -137,11 +137,13 @@ linux_open(struct thread *td, struct linux_open_args *args) SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct file *fp; - fp = ffind_hold(td, td->td_retval[0]); + error = fget(td, td->td_retval[0], &fp); PROC_UNLOCK(p); - if (fp->f_type == DTYPE_VNODE) - fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td); - fdrop(fp, td); + if (!error) { + if (fp->f_type == DTYPE_VNODE) + fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td); + fdrop(fp, td); + } } else PROC_UNLOCK(p); #ifdef DEBUG @@ -996,9 +998,9 @@ fcntl_common(struct thread *td, struct linux_fcntl64_args *args) * significant effect for pipes (SIGIO is not delivered for * pipes under Linux-2.2.35 at least). */ - fp = ffind_hold(td, args->fd); - if (fp == NULL) - return EBADF; + error = fget(td, args->fd, &fp); + if (error) + return (error); if (fp->f_type == DTYPE_PIPE) { fdrop(fp, td); return (EINVAL); diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index baafb5b..acf71d9 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -109,9 +109,8 @@ linux_ioctl_disk(struct thread *td, struct linux_ioctl_args *args) int error; struct disklabel dl; - fp = ffind_hold(td, args->fd); - if (fp == NULL) - return (EBADF); + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); switch (args->cmd & 0xffff) { case LINUX_BLKGETSIZE: error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, td); @@ -555,9 +554,9 @@ linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args) struct file *fp; int error; - fp = ffind_hold(td, args->fd); - if (fp == NULL) - return (EBADF); + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); + switch (args->cmd & 0xffff) { case LINUX_TCGETS: @@ -1249,9 +1248,8 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args) struct file *fp; int error; - fp = ffind_hold(td, args->fd); - if (fp == NULL) - return (EBADF); + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); switch (args->cmd & 0xffff) { case LINUX_CDROMPAUSE: @@ -1706,9 +1704,8 @@ linux_ioctl_console(struct thread *td, struct linux_ioctl_args *args) struct file *fp; int error; - fp = ffind_hold(td, args->fd); - if (fp == NULL) - return (EBADF); + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); switch (args->cmd & 0xffff) { case LINUX_KIOCSOUND: @@ -2259,9 +2256,8 @@ linux_ioctl(struct thread *td, struct linux_ioctl_args *args) (unsigned long)args->cmd); #endif - fp = ffind_hold(td, args->fd); - if (fp == NULL) - return (EBADF); + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); if ((fp->f_flag & (FREAD|FWRITE)) == 0) { fdrop(fp, td); return (EBADF); diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 8f1799c..80b1c02 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -160,9 +160,8 @@ linux_newfstat(struct thread *td, struct linux_newfstat_args *args) printf(ARGS(newfstat, "%d, *"), args->fd); #endif - fp = ffind_hold(td, args->fd); - if (fp == NULL) - return (EBADF); + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); error = fo_stat(fp, &buf, td); fdrop(fp, td); diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index a13cd23..43a571f 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -246,23 +246,14 @@ fd_revoke(td, fd) struct thread *td; int fd; { - struct file *fp; struct vnode *vp; struct mount *mp; struct vattr vattr; int error, *retval; retval = td->td_retval; - fp = ffind_hold(td, fd); - if (fp == NULL) - return EBADF; - - if (fp->f_type != DTYPE_VNODE) { - fdrop(fp, td); - return EINVAL; - } - - vp = (struct vnode *) fp->f_data; + if ((error = fgetvp(td, fd, &vp)) != 0) + return (error); if (vp->v_type != VCHR && vp->v_type != VBLK) { error = EINVAL; @@ -283,7 +274,6 @@ fd_revoke(td, fd) vn_finished_write(mp); out: vrele(vp); - fdrop(fp, td); return error; } @@ -294,7 +284,6 @@ fd_truncate(td, fd, flp) int fd; struct flock *flp; { - struct file *fp; off_t start, length; struct vnode *vp; struct vattr vattr; @@ -306,18 +295,16 @@ fd_truncate(td, fd, flp) /* * We only support truncating the file. */ - fp = ffind_hold(td, fd); - if (fp == NULL) - return EBADF; + if ((error = fgetvp(td, uap->fd, &vp)) != 0) + return (error); - vp = (struct vnode *)fp->f_data; - if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) { - fdrop(fp, td); + if (vp->v_type == VFIFO) { + vrele(vp); return ESPIPE; } if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0) - fdrop(fp, td); + vrele(vp); return error; } @@ -337,7 +324,7 @@ fd_truncate(td, fd, flp) break; default: - fdrop(fp, td); + vrele(vp); return EINVAL; } @@ -351,7 +338,7 @@ fd_truncate(td, fd, flp) error = ftruncate(td, &ft); - fdrop(fp, td); + vrele(vp); return (error); } @@ -386,13 +373,13 @@ svr4_sys_open(td, uap) #if defined(NOTYET) struct file *fp; - fp = ffind_hold(td, retval); + error = fget(td, retval, &fp); PROC_UNLOCK(p); /* * we may have lost a race the above open() and * another thread issuing a close() */ - if (fp == NULL) + if (error) return (EBADF); /* XXX: correct errno? */ /* ignore any error, just give it a try */ if (fp->f_type == DTYPE_VNODE) diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c index b24a039..0dd6bed 100644 --- a/sys/compat/svr4/svr4_filio.c +++ b/sys/compat/svr4/svr4_filio.c @@ -107,8 +107,7 @@ svr4_sys_read(td, uap) SCARG(&ra, buf) = SCARG(uap, buf); SCARG(&ra, nbyte) = SCARG(uap, nbyte); - fp = ffind_hold(td, uap->fd); - if (fp == NULL) { + if (fget(td, uap->fd, &fp) != 0) { DPRINTF(("Something fishy with the user-supplied file descriptor...\n")); return EBADF; } diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c index 024c2e5..cbac631 100644 --- a/sys/compat/svr4/svr4_ioctl.c +++ b/sys/compat/svr4/svr4_ioctl.c @@ -102,9 +102,8 @@ svr4_sys_ioctl(td, uap) retval = td->td_retval; cmd = SCARG(uap, com); - fp = ffind_hold(td, uap->fd); - if (fp == NULL) - return EBADF; + if ((error = fget(td, uap->fd, &fp)) != 0) + return (error); if ((fp->f_flag & (FREAD | FWRITE)) == 0) { fdrop(fp, td); diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c index 2d8ea84..c0f7134 100644 --- a/sys/compat/svr4/svr4_stream.c +++ b/sys/compat/svr4/svr4_stream.c @@ -1717,8 +1717,7 @@ svr4_sys_putmsg(td, uap) struct file *fp; int error; - fp = ffind_hold(td, uap->fd); - if (fp == NULL) { + if ((error = fget(td, uap->fd, &fp)) != 0) { #ifdef DEBUG_SVR4 uprintf("putmsg: bad fp\n"); #endif @@ -1905,8 +1904,7 @@ svr4_sys_getmsg(td, uap) struct file *fp; int error; - fp = ffind_hold(td, uap->fd); - if (fp == NULL) { + if ((error = fget(td, uap->fd, &fp)) != 0) { #ifdef DEBUG_SVR4 uprintf("getmsg: bad fp\n"); #endif |