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 90946 2002-02-20 00:11:57Z rwatson $
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 vattr vattr;
623 int error;
624
625 switch (vp->v_type) {
626
627 case VREG:
628 case VDIR:
629 if (com == FIONREAD) {
--- 21 unchanged lines hidden (view full) ---
651 return (ENOTTY);
652 *(int *)data = devsw(vp->v_rdev)->d_flags & D_TYPEMASK;
653 return (0);
654 }
655 error = VOP_IOCTL(vp, com, data, fp->f_flag, td->td_proc->p_ucred, td);
656 if (error == 0 && com == TIOCSCTTY) {
657
658 /* Do nothing if reassigning same control tty */
659 if (td->td_proc->p_session->s_ttyvp == vp)
660 return (0);
661
662 /* Get rid of reference to old control tty */
663 if (td->td_proc->p_session->s_ttyvp)
664 vrele(td->td_proc->p_session->s_ttyvp);
665
666 td->td_proc->p_session->s_ttyvp = vp;
667 VREF(vp);
668 }
669 return (error);
670 }
671}
672
673/*
674 * File table vnode poll routine.
675 */
--- 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 90946 2002-02-20 00:11:57Z rwatson $
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 vattr vattr;
623 int error;
624
625 switch (vp->v_type) {
626
627 case VREG:
628 case VDIR:
629 if (com == FIONREAD) {
--- 21 unchanged lines hidden (view full) ---
651 return (ENOTTY);
652 *(int *)data = devsw(vp->v_rdev)->d_flags & D_TYPEMASK;
653 return (0);
654 }
655 error = VOP_IOCTL(vp, com, data, fp->f_flag, td->td_proc->p_ucred, td);
656 if (error == 0 && com == TIOCSCTTY) {
657
658 /* Do nothing if reassigning same control tty */
659 if (td->td_proc->p_session->s_ttyvp == vp)
660 return (0);
661
662 /* Get rid of reference to old control tty */
663 if (td->td_proc->p_session->s_ttyvp)
664 vrele(td->td_proc->p_session->s_ttyvp);
665
666 td->td_proc->p_session->s_ttyvp = vp;
667 VREF(vp);
668 }
669 return (error);
670 }
671}
672
673/*
674 * File table vnode poll routine.
675 */
--- 320 unchanged lines hidden ---