From owner-svn-src-head@FreeBSD.ORG Tue Dec 1 19:14:57 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E3AC106568B; Tue, 1 Dec 2009 19:14:57 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D3528FC12; Tue, 1 Dec 2009 19:14:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nB1JEvD8073648; Tue, 1 Dec 2009 19:14:57 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nB1JEvV3073646; Tue, 1 Dec 2009 19:14:57 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200912011914.nB1JEvV3073646@svn.freebsd.org> From: Ed Schouten Date: Tue, 1 Dec 2009 19:14:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199998 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Dec 2009 19:14:57 -0000 Author: ed Date: Tue Dec 1 19:14:57 2009 New Revision: 199998 URL: http://svn.freebsd.org/changeset/base/199998 Log: Don't allocate an input buffer for a TTY when the receiver is turned off. When the termios CREAD flag is not set, it makes little sense to allocate an input buffer. Just set the size to 0 in this case to reduce memory footprint. Disallow CREAD to be disabled for pseudo-devices to prevent foot-shooting. Modified: head/sys/kern/tty.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Tue Dec 1 17:29:25 2009 (r199997) +++ head/sys/kern/tty.c Tue Dec 1 19:14:57 2009 (r199998) @@ -102,10 +102,11 @@ static const char *dev_console_filename; static void tty_watermarks(struct tty *tp) { - size_t bs; + size_t bs = 0; /* Provide an input buffer for 0.2 seconds of data. */ - bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX); + if (tp->t_termios.c_cflag & CREAD) + bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX); ttyinq_setsize(&tp->t_inq, tp, bs); /* Set low watermark at 10% (when 90% is available). */ @@ -890,6 +891,7 @@ ttydevsw_defparam(struct tty *tp, struct t->c_ospeed = B50; else if (t->c_ospeed > B115200) t->c_ospeed = B115200; + t->c_cflag |= CREAD; return (0); }