Date: Mon, 15 Nov 2010 04:28:21 GMT From: Peter Jeremy <peter.jeremy@alcatel-lucent.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/152254: [patch] Support ioctl() on TTY control devices Message-ID: <201011150428.oAF4SL06037362@www.freebsd.org> Resent-Message-ID: <201011150430.oAF4U9hr032776@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011150428.oAF4SL06037362>