diff options
Diffstat (limited to 'sys/compat/linux')
-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 |
3 files changed, 22 insertions, 25 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); |