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 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
39 * $FreeBSD: head/sys/kern/vfs_vnops.c 91140 2002-02-23 11:12:57Z tanimura $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/fcntl.h>
45#include <sys/file.h>
46#include <sys/stat.h>
47#include <sys/proc.h>
--- 566 unchanged lines hidden (view full) ---
614static int
615vn_ioctl(fp, com, data, td)
616 struct file *fp;
617 u_long com;
618 caddr_t data;
619 struct thread *td;
620{
621 register struct vnode *vp = ((struct vnode *)fp->f_data);
622 struct vnode *vpold;
623 struct vattr vattr;
624 int error;
625
626 switch (vp->v_type) {
627
628 case VREG:
629 case VDIR:
630 if (com == FIONREAD) {
--- 21 unchanged lines hidden (view full) ---
652 return (ENOTTY);
653 *(int *)data = devsw(vp->v_rdev)->d_flags & D_TYPEMASK;
654 return (0);
655 }
656 error = VOP_IOCTL(vp, com, data, fp->f_flag, td->td_proc->p_ucred, td);
657 if (error == 0 && com == TIOCSCTTY) {
658
659 /* Do nothing if reassigning same control tty */
660 PGRPSESS_XLOCK();
661 if (td->td_proc->p_session->s_ttyvp == vp) {
662 PGRPSESS_XUNLOCK();
663 return (0);
664 }
665
666 vpold = td->td_proc->p_session->s_ttyvp;
667 VREF(vp);
668 SESS_LOCK(td->td_proc->p_session);
669 td->td_proc->p_session->s_ttyvp = vp;
670 SESS_UNLOCK(td->td_proc->p_session);
671
672 PGRPSESS_XUNLOCK();
673
674 /* Get rid of reference to old control tty */
675 if (vpold)
676 vrele(vpold);
677 }
678 return (error);
679 }
680}
681
682/*
683 * File table vnode poll routine.
684 */
--- 320 unchanged lines hidden ---
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 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
39 * $FreeBSD: head/sys/kern/vfs_vnops.c 91140 2002-02-23 11:12:57Z tanimura $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/fcntl.h>
45#include <sys/file.h>
46#include <sys/stat.h>
47#include <sys/proc.h>
--- 566 unchanged lines hidden (view full) ---
614static int
615vn_ioctl(fp, com, data, td)
616 struct file *fp;
617 u_long com;
618 caddr_t data;
619 struct thread *td;
620{
621 register struct vnode *vp = ((struct vnode *)fp->f_data);
622 struct vnode *vpold;
623 struct vattr vattr;
624 int error;
625
626 switch (vp->v_type) {
627
628 case VREG:
629 case VDIR:
630 if (com == FIONREAD) {
--- 21 unchanged lines hidden (view full) ---
652 return (ENOTTY);
653 *(int *)data = devsw(vp->v_rdev)->d_flags & D_TYPEMASK;
654 return (0);
655 }
656 error = VOP_IOCTL(vp, com, data, fp->f_flag, td->td_proc->p_ucred, td);
657 if (error == 0 && com == TIOCSCTTY) {
658
659 /* Do nothing if reassigning same control tty */
660 PGRPSESS_XLOCK();
661 if (td->td_proc->p_session->s_ttyvp == vp) {
662 PGRPSESS_XUNLOCK();
663 return (0);
664 }
665
666 vpold = td->td_proc->p_session->s_ttyvp;
667 VREF(vp);
668 SESS_LOCK(td->td_proc->p_session);
669 td->td_proc->p_session->s_ttyvp = vp;
670 SESS_UNLOCK(td->td_proc->p_session);
671
672 PGRPSESS_XUNLOCK();
673
674 /* Get rid of reference to old control tty */
675 if (vpold)
676 vrele(vpold);
677 }
678 return (error);
679 }
680}
681
682/*
683 * File table vnode poll routine.
684 */
--- 320 unchanged lines hidden ---