diff options
author | marcel <marcel@FreeBSD.org> | 2000-07-15 22:33:24 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2000-07-15 22:33:24 +0000 |
commit | 8e33a73c687c464e0e9a563443311ea5b1ce0adf (patch) | |
tree | 46fa8136c09326e1005f5b4177a2f824ceeefa51 /sys | |
parent | 022f7e0a5784936f513023dfdccc0aa1d12ad058 (diff) | |
download | FreeBSD-src-8e33a73c687c464e0e9a563443311ea5b1ce0adf.zip FreeBSD-src-8e33a73c687c464e0e9a563443311ea5b1ce0adf.tar.gz |
Simplify the F_GETOWN and F_SETOWN fcntl commands. The workaround
is not needed since the FreeBSD native implementation switched
from TIOC{G|S}PGRP to FIO{G|S}ETOWN (kern_descrip.c rev 1.55).
PR: 16946
Submitted by: Victor Salaman <salaman@teknos.com>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/compat/linux/linux_file.c | 56 | ||||
-rw-r--r-- | sys/i386/linux/linux_file.c | 56 |
2 files changed, 14 insertions, 98 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index cee65db..90d82c2 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -199,14 +199,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) } */ fcntl_args; struct linux_flock linux_flock; struct flock *bsd_flock; - struct filedesc *fdp; - struct file *fp; - struct vnode *vp; - long pgid; - struct pgrp *pgrp; - struct tty *tp; caddr_t sg; - dev_t dev; sg = stackgap_init(); bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock)); @@ -287,49 +280,14 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) fcntl_args.arg = (int)bsd_flock; return fcntl(p, &fcntl_args); - case LINUX_F_SETOWN: case LINUX_F_GETOWN: - /* - * We need to route around the normal fcntl() for these calls, - * since it uses TIOC{G,S}PGRP, which is too restrictive for - * Linux F_{G,S}ETOWN semantics. For sockets, this problem - * does not exist. - */ - fdp = p->p_fd; - if ((u_int)args->fd >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[args->fd]) == NULL) - return EBADF; - if (fp->f_type == DTYPE_SOCKET) { - fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN; - fcntl_args.arg = args->arg; - return fcntl(p, &fcntl_args); - } - vp = (struct vnode *)fp->f_data; - dev = vn_todev(vp); - if (dev == NODEV) - return EINVAL; - if (!(devsw(dev)->d_flags & D_TTY)) - return EINVAL; - tp = dev->si_tty; - if (!tp) - return EINVAL; - if (args->cmd == LINUX_F_GETOWN) { - p->p_retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; - return 0; - } - if ((long)args->arg <= 0) { - pgid = -(long)args->arg; - } else { - struct proc *p1 = pfind((long)args->arg); - if (p1 == 0) - return (ESRCH); - pgid = (long)p1->p_pgrp->pg_id; - } - pgrp = pgfind(pgid); - if (pgrp == NULL || pgrp->pg_session != p->p_session) - return EPERM; - tp->t_pgrp = pgrp; - return 0; + fcntl_args.cmd = F_GETOWN; + return fcntl(p, &fcntl_args); + + case LINUX_F_SETOWN: + fcntl_args.cmd = F_SETOWN; + fcntl_args.arg = args->arg; + return fcntl(p, &fcntl_args); } return EINVAL; } diff --git a/sys/i386/linux/linux_file.c b/sys/i386/linux/linux_file.c index cee65db..90d82c2 100644 --- a/sys/i386/linux/linux_file.c +++ b/sys/i386/linux/linux_file.c @@ -199,14 +199,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) } */ fcntl_args; struct linux_flock linux_flock; struct flock *bsd_flock; - struct filedesc *fdp; - struct file *fp; - struct vnode *vp; - long pgid; - struct pgrp *pgrp; - struct tty *tp; caddr_t sg; - dev_t dev; sg = stackgap_init(); bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock)); @@ -287,49 +280,14 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) fcntl_args.arg = (int)bsd_flock; return fcntl(p, &fcntl_args); - case LINUX_F_SETOWN: case LINUX_F_GETOWN: - /* - * We need to route around the normal fcntl() for these calls, - * since it uses TIOC{G,S}PGRP, which is too restrictive for - * Linux F_{G,S}ETOWN semantics. For sockets, this problem - * does not exist. - */ - fdp = p->p_fd; - if ((u_int)args->fd >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[args->fd]) == NULL) - return EBADF; - if (fp->f_type == DTYPE_SOCKET) { - fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN; - fcntl_args.arg = args->arg; - return fcntl(p, &fcntl_args); - } - vp = (struct vnode *)fp->f_data; - dev = vn_todev(vp); - if (dev == NODEV) - return EINVAL; - if (!(devsw(dev)->d_flags & D_TTY)) - return EINVAL; - tp = dev->si_tty; - if (!tp) - return EINVAL; - if (args->cmd == LINUX_F_GETOWN) { - p->p_retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; - return 0; - } - if ((long)args->arg <= 0) { - pgid = -(long)args->arg; - } else { - struct proc *p1 = pfind((long)args->arg); - if (p1 == 0) - return (ESRCH); - pgid = (long)p1->p_pgrp->pg_id; - } - pgrp = pgfind(pgid); - if (pgrp == NULL || pgrp->pg_session != p->p_session) - return EPERM; - tp->t_pgrp = pgrp; - return 0; + fcntl_args.cmd = F_GETOWN; + return fcntl(p, &fcntl_args); + + case LINUX_F_SETOWN: + fcntl_args.cmd = F_SETOWN; + fcntl_args.arg = args->arg; + return fcntl(p, &fcntl_args); } return EINVAL; } |