From owner-freebsd-stable@FreeBSD.ORG Sun Oct 11 10:51:15 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01B94106568B for ; Sun, 11 Oct 2009 10:51:15 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-ew0-f218.google.com (mail-ew0-f218.google.com [209.85.219.218]) by mx1.freebsd.org (Postfix) with ESMTP id 80F588FC12 for ; Sun, 11 Oct 2009 10:51:14 +0000 (UTC) Received: by ewy18 with SMTP id 18so2160308ewy.43 for ; Sun, 11 Oct 2009 03:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:to:subject:organization:from :date:message-id:user-agent:mime-version:content-type; bh=Ti4veoh49dCgiDADOQb5DieQz8buZ+R6z1Q6fhV98XM=; b=gtFgG1nyPdOHJ7PotwWQLuRbKdb5fsBsr10EVRKjaIh1zyGMNP6OFaCzOIIGEedNmG oH2LFi9ivyjM1xWwpE89+MXb4Fld0j9PlLiJo28/xQ8UZqLWRgRQm2RguTPcR3hDTvXX Sk4fAEZVCQG7xe6a9xrdDOgAjgTZPTmmpPv08= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=to:subject:organization:from:date:message-id:user-agent :mime-version:content-type; b=NYoxZbr4wxXPs6Q0a93dsqyOaTO6Jhq6JbXbtb3vFkrcWY0eAbvdBr6z1aGyNQDT/1 rXxwE33kj5F+1QIfv9G2uktku4LeNDqK68WxWrs6H/pUKBWXqhqh3JBZDVW4pNLI/p7B lHxVPqCPk0WjC+wdoaKYzHNIzoRRgLcGuHHqE= Received: by 10.210.3.18 with SMTP id 18mr2636254ebc.80.1255258273511; Sun, 11 Oct 2009 03:51:13 -0700 (PDT) Received: from localhost (vpn-193-138-133-43.customer.onet.com.ua [193.138.133.43]) by mx.google.com with ESMTPS id 10sm1186017eyd.14.2009.10.11.03.51.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 11 Oct 2009 03:51:12 -0700 (PDT) To: freebsd-stable@freebsd.org Organization: TOA Ukraine From: Mikolaj Golub Date: Sun, 11 Oct 2009 13:51:09 +0300 Message-ID: <861vla2ogy.fsf@kopusha.onet> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: can't change tty speed and buffer size on 8.0 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Oct 2009 10:51:15 -0000 Hi, On 8.0-RC1 if you run this command: cat > /dev/null and try to input a long line, the maximum length you can input is 1920 characters. I have investigated a bit how I can increase a tty buffer as this is a problem for me (I have logs with very long lines and I used to copy&past a particular line into input of some script to structure it). According to kern/tty.c:tty_watermarks() the input buffer size is set as ispeed / 5. The default speed is 9600 that is rather low: /usr/include/sys/ttydefaults.h:#define TTYDEF_SPEED (B9600) So to increase the buffer size I need to decrease tty speed. But this does not work: zhuzha:/tmp% stty speed 9600 baud; lflags: echoe echok echoke echoctl iflags: -ixany -imaxbel oflags: tab0 cflags: cs8 parenb eol2 erase status ^@ ^H zhuzha:/tmp% stty ispeed 38400 zhuzha:/tmp% stty speed 9600 baud; lflags: echoe echok echoke echoctl iflags: -ixany -imaxbel oflags: tab0 cflags: cs8 parenb eol2 erase status ^@ ^H I can change tty speed on 7.X but can't on 8.0. I ran this simple dtrace program to see what is going on: tty*:entry /execname == "stty"/ { printf("%s entered; args0-4: %d %d %d %d %d\n", probefunc, arg0, arg1, arg2, arg3, arg4); } tty*:return /execname == "stty"/ { printf("%s returned %d\n", probefunc, arg1); } And here is the relevant part of the output: ttydev_ioctl entered; arguments: 3313875456 2150396948 3363021248 3 3357835264 tty_wait_background entered; arguments: 3354367492 0 3234498062 158 0 tty_wait_background returned 0 tty_ioctl entered; arguments: 3354367488 2150396948 3363021248 3357835264 0 ttydevsw_defioctl entered; arguments: 3354367488 2150396948 3363021248 3357835264 0 ttydevsw_defioctl returned 4294967293 ttydevsw_defparam entered; arguments: 3354367488 3363021248 3363021248 3357835264 0 ttydevsw_defparam returned 0 tty_watermarks entered; arguments: 3354367488 3363021248 3363021248 3357835264 0 ttyinq_setsize entered; arguments: 3354367528 3354367488 1920 0 3875601352 ttyinq_setsize returned 15 ttyoutq_setsize entered; arguments: 3354367572 3354367488 1920 0 3875601352 ttyoutq_setsize returned 3545052638 tty_watermarks returned 858997088 ttydisc_optimize entered; arguments: 3354367488 3363021264 20 3357835264 0 ttydisc_optimize returned 0 tty_ioctl returned 0 ttydev_ioctl returned 0 As you can see, before calling tty_watermarks() and ttyinq_setsize(), ttydevsw_defparam() is called that do only this thing: /* Use a fake baud rate, we're not a real device. */ t->c_ispeed = t->c_ospeed = TTYDEF_SPEED; As a result the speed of terminal is always set to TTYDEF_SPEED and ttyinq_setsize() is always called with size=1920 (TTYDEF_SPEED/5). This all happens in tty_generic_ioctl() in this part: /* * Only call param() when the flags really change. */ if ((t->c_cflag & CIGNORE) == 0 && (tp->t_termios.c_cflag != t->c_cflag || tp->t_termios.c_ispeed != t->c_ispeed || tp->t_termios.c_ospeed != t->c_ospeed)) { error = ttydevsw_param(tp, t); if (error) return (error); /* XXX: CLOCAL? */ tp->t_termios.c_cflag = t->c_cflag & ~CIGNORE; tp->t_termios.c_ispeed = t->c_ispeed; tp->t_termios.c_ospeed = t->c_ospeed; /* Baud rate has changed - update watermarks. */ tty_watermarks(tp); } AFAIR ttydevsw_param() runs tty hooks and ttydevsw_defparam() among them. So you can't change the speed of terminal and the size of input buffer on running system. Only by recompiling the kernel with updated TTYDEF_SPEED. Is this intentional or does it look rather like a bug? -- Mikolaj Golub