tty.c (191782) | tty.c (192080) |
---|---|
1/*- 2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Portions of this software were developed under sponsorship from Snow 6 * B.V., the Netherlands. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Portions of this software were developed under sponsorship from Snow 6 * B.V., the Netherlands. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/kern/tty.c 191782 2009-05-04 11:11:10Z ed $"); | 31__FBSDID("$FreeBSD: head/sys/kern/tty.c 192080 2009-05-14 03:24:22Z jeff $"); |
32 33#include "opt_compat.h" 34 35#include <sys/param.h> 36#include <sys/conf.h> 37#include <sys/cons.h> 38#include <sys/fcntl.h> 39#include <sys/file.h> --- 1675 unchanged lines hidden (view full) --- 1715 struct cdev *dev; 1716 struct cdevsw *cdp; 1717 struct filedesc *fdp; 1718 int error; 1719 1720 /* Validate the file descriptor. */ 1721 if ((fdp = p->p_fd) == NULL) 1722 return (EBADF); | 32 33#include "opt_compat.h" 34 35#include <sys/param.h> 36#include <sys/conf.h> 37#include <sys/cons.h> 38#include <sys/fcntl.h> 39#include <sys/file.h> --- 1675 unchanged lines hidden (view full) --- 1715 struct cdev *dev; 1716 struct cdevsw *cdp; 1717 struct filedesc *fdp; 1718 int error; 1719 1720 /* Validate the file descriptor. */ 1721 if ((fdp = p->p_fd) == NULL) 1722 return (EBADF); |
1723 FILEDESC_SLOCK(fdp); 1724 if ((fp = fget_locked(fdp, fd)) == NULL || fp->f_ops == &badfileops) { 1725 FILEDESC_SUNLOCK(fdp); | 1723 1724 fp = fget_unlocked(fdp, fd); 1725 if (fp == NULL) |
1726 return (EBADF); | 1726 return (EBADF); |
1727 if (fp->f_ops == &badfileops) { 1728 error = EBADF; 1729 goto done1; |
|
1727 } 1728 1729 /* Make sure the vnode is bound to a character device. */ 1730 error = EINVAL; 1731 if (fp->f_type != DTYPE_VNODE || fp->f_vnode->v_type != VCHR || 1732 fp->f_vnode->v_rdev == NULL) 1733 goto done1; 1734 dev = fp->f_vnode->v_rdev; --- 23 unchanged lines hidden (view full) --- 1758 ttydisc_optimize(tp); 1759 1760 /* Silently convert rint() calls to rint_bypass() when possible. */ 1761 if (!ttyhook_hashook(tp, rint) && ttyhook_hashook(tp, rint_bypass)) 1762 th->th_rint = ttyhook_defrint; 1763 1764done3: tty_unlock(tp); 1765done2: dev_relthread(dev); | 1730 } 1731 1732 /* Make sure the vnode is bound to a character device. */ 1733 error = EINVAL; 1734 if (fp->f_type != DTYPE_VNODE || fp->f_vnode->v_type != VCHR || 1735 fp->f_vnode->v_rdev == NULL) 1736 goto done1; 1737 dev = fp->f_vnode->v_rdev; --- 23 unchanged lines hidden (view full) --- 1761 ttydisc_optimize(tp); 1762 1763 /* Silently convert rint() calls to rint_bypass() when possible. */ 1764 if (!ttyhook_hashook(tp, rint) && ttyhook_hashook(tp, rint_bypass)) 1765 th->th_rint = ttyhook_defrint; 1766 1767done3: tty_unlock(tp); 1768done2: dev_relthread(dev); |
1766done1: FILEDESC_SUNLOCK(fdp); | 1769done1: fdrop(fp, curthread); |
1767 return (error); 1768} 1769 1770void 1771ttyhook_unregister(struct tty *tp) 1772{ 1773 1774 tty_lock_assert(tp, MA_OWNED); --- 298 unchanged lines hidden --- | 1770 return (error); 1771} 1772 1773void 1774ttyhook_unregister(struct tty *tp) 1775{ 1776 1777 tty_lock_assert(tp, MA_OWNED); --- 298 unchanged lines hidden --- |