From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 15 04:30:09 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD19C106566B for ; Mon, 15 Nov 2010 04:30:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 928B58FC14 for ; Mon, 15 Nov 2010 04:30:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oAF4U9eu032777 for ; Mon, 15 Nov 2010 04:30:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oAF4U9hr032776; Mon, 15 Nov 2010 04:30:09 GMT (envelope-from gnats) Resent-Date: Mon, 15 Nov 2010 04:30:09 GMT Resent-Message-Id: <201011150430.oAF4U9hr032776@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Peter Jeremy Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 58D20106566B for ; Mon, 15 Nov 2010 04:28:22 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 2BFC38FC1B for ; Mon, 15 Nov 2010 04:28:22 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id oAF4SLaZ037363 for ; Mon, 15 Nov 2010 04:28:21 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id oAF4SL06037362; Mon, 15 Nov 2010 04:28:21 GMT (envelope-from nobody) Message-Id: <201011150428.oAF4SL06037362@www.freebsd.org> Date: Mon, 15 Nov 2010 04:28:21 GMT From: Peter Jeremy To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/152254: [patch] Support ioctl() on TTY control devices X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Nov 2010 04:30:09 -0000 >Number: 152254 >Category: kern >Synopsis: [patch] Support ioctl() on TTY control devices >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Nov 15 04:30:09 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Peter Jeremy >Release: FreeBSD-8.1 >Organization: Alcatel-Lucent Australia >Environment: FreeBSD pjdesk.au.alcatel-lucent.com 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #19: Wed Jul 14 07:24:18 EST 2010 root@pjdesk.au.alcatel-lucent.com:/var/obj/usr/src/sys/pjdesk amd64 >Description: The TTY MPSAFE adaption removed support for issuing driver-specific ioctl(2) calls on the TTY control device. This patch re-adds it since this support is required for digi(4). >How-To-Repeat: Code inspection >Fix: Patch attached with submission follows: Index: sys/ttydevsw.h =================================================================== RCS file: /usr/ncvs/src/sys/sys/ttydevsw.h,v retrieving revision 1.4.2.1 diff -u -r1.4.2.1 ttydevsw.h --- sys/ttydevsw.h 3 Aug 2009 08:13:06 -0000 1.4.2.1 +++ sys/ttydevsw.h 15 Nov 2010 03:11:44 -0000 @@ -52,6 +52,8 @@ vm_paddr_t * paddr, int nprot); typedef void tsw_pktnotify_t(struct tty *tp, char event); typedef void tsw_free_t(void *softc); +typedef int tsw_cioctl_t(struct tty *tp, u_long cmd, caddr_t data, + struct thread *td); struct ttydevsw { unsigned int tsw_flags; /* Default TTY flags. */ @@ -70,6 +72,8 @@ tsw_pktnotify_t *tsw_pktnotify; /* TIOCPKT events. */ tsw_free_t *tsw_free; /* Destructor. */ + + tsw_cioctl_t *tsw_cioctl; /* Ioctl on control devices */ }; static __inline int @@ -166,4 +170,13 @@ tp->t_devsw->tsw_free(tty_softc(tp)); } +static __inline int +ttydevsw_cioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) +{ + tty_lock_assert(tp, MA_OWNED); + MPASS(!tty_gone(tp)); + + return tp->t_devsw->tsw_cioctl(tp, cmd, data, td); +} + #endif /* !_SYS_TTYDEVSW_H_ */ Index: kern/tty.c =================================================================== RCS file: /usr/ncvs/src/sys/kern/tty.c,v retrieving revision 1.328.2.4 diff -u -r1.328.2.4 tty.c --- kern/tty.c 18 Jan 2010 09:04:53 -0000 1.328.2.4 +++ kern/tty.c 15 Nov 2010 03:21:46 -0000 @@ -781,7 +781,7 @@ bzero(data, sizeof(struct winsize)); break; default: - error = ENOTTY; + error = ttydevsw_ioctl(tp, cmd, data, td); } done: tty_unlock(tp); @@ -905,6 +905,13 @@ panic("Terminal device freed without a free-handler"); } +static int +ttydevsw_defcioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) +{ + + return (ENOTTY); +} + /* * TTY allocation and deallocation. TTY devices can be deallocated when * the driver doesn't use it anymore, when the TTY isn't a session's @@ -938,6 +945,7 @@ PATCH_FUNC(mmap); PATCH_FUNC(pktnotify); PATCH_FUNC(free); + PATCH_FUNC(cioctl); #undef PATCH_FUNC tp = malloc(sizeof(struct tty), M_TTY, M_WAITOK|M_ZERO); >Release-Note: >Audit-Trail: >Unformatted: