From owner-svn-src-head@freebsd.org Wed Aug 16 15:14:47 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57C4ADE1807; Wed, 16 Aug 2017 15:14:47 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 213F527C3; Wed, 16 Aug 2017 15:14:47 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7GFEkZv091038; Wed, 16 Aug 2017 15:14:46 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GFEkMw091037; Wed, 16 Aug 2017 15:14:46 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201708161514.v7GFEkMw091037@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Wed, 16 Aug 2017 15:14:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322579 - head/usr.sbin/vidcontrol X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/usr.sbin/vidcontrol X-SVN-Commit-Revision: 322579 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Wed, 16 Aug 2017 15:14:47 -0000 Author: bde Date: Wed Aug 16 15:14:46 2017 New Revision: 322579 URL: https://svnweb.freebsd.org/changeset/base/322579 Log: Fix setting of the border color. Teken doesn't support syscons' escape sequence "ESC [ %d A" for this although that was used here. I will fix teken later, but use the more portable ioctl KDSBORDER here. The ioctl is also much easier to use if you check that it works. For -b, check it and complain and exit if it failed, so that it is more obvious that that vt doesn't support border colors. Don't check it when restoring the border color in revert(), since revert() is used on vt for handling other errors. Fix nearby error handling and style. For the error of an invalid color, revert() and print a specific error message using err() instead of not revert()ing and printing spam using usage(). Modified: head/usr.sbin/vidcontrol/vidcontrol.c Modified: head/usr.sbin/vidcontrol/vidcontrol.c ============================================================================== --- head/usr.sbin/vidcontrol/vidcontrol.c Wed Aug 16 13:44:46 2017 (r322578) +++ head/usr.sbin/vidcontrol/vidcontrol.c Wed Aug 16 15:14:46 2017 (r322579) @@ -154,7 +154,7 @@ revert(void) ioctl(0, VT_ACTIVATE, cur_info.active_vty); - fprintf(stderr, "\033[=%dA", cur_info.console_info.mv_ovscan); + ioctl(0, KDSBORDER, cur_info.console_info.mv_ovscan); fprintf(stderr, "\033[=%dH", cur_info.console_info.mv_rev.fore); fprintf(stderr, "\033[=%dI", cur_info.console_info.mv_rev.back); @@ -910,11 +910,15 @@ set_border_color(char *arg) { int color; - if ((color = get_color_number(arg)) != -1) { - fprintf(stderr, "\033[=%dA", color); + color = get_color_number(arg); + if (color == -1) { + revert(); + errx(1, "invalid color '%s'", arg); } - else - usage(); + if (ioctl(0, KDSBORDER, color) != 0) { + revert(); + err(1, "ioctl(KD_SBORDER)"); + } } static void