From owner-svn-src-all@FreeBSD.ORG Mon Apr 18 20:28:08 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 613041065677; Mon, 18 Apr 2011 20:28:08 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4453E8FC1C; Mon, 18 Apr 2011 20:28:08 +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 p3IKS89D083280; Mon, 18 Apr 2011 20:28:08 GMT (envelope-from ru@svn.freebsd.org) Received: (from ru@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3IKS80P083277; Mon, 18 Apr 2011 20:28:08 GMT (envelope-from ru@svn.freebsd.org) Message-Id: <201104182028.p3IKS80P083277@svn.freebsd.org> From: Ruslan Ermilov Date: Mon, 18 Apr 2011 20:28:08 +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: r220801 - head/sbin/conscontrol X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Apr 2011 20:28:08 -0000 Author: ru Date: Mon Apr 18 20:28:07 2011 New Revision: 220801 URL: http://svn.freebsd.org/changeset/base/220801 Log: Changed "conscontrol unset" to accept an existing virtual console device as an argument. Unsetting virtual console using /dev/console seems to have never worked. MFC after: 3 days Modified: head/sbin/conscontrol/conscontrol.8 head/sbin/conscontrol/conscontrol.c Modified: head/sbin/conscontrol/conscontrol.8 ============================================================================== --- head/sbin/conscontrol/conscontrol.8 Mon Apr 18 20:07:08 2011 (r220800) +++ head/sbin/conscontrol/conscontrol.8 Mon Apr 18 20:28:07 2011 (r220801) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 23, 2001 +.Dd April 14, 2011 .Dt CONSCONTROL 8 .Os .Sh NAME @@ -40,7 +40,7 @@ .Cm add | delete .Ar console .Nm -.Cm set Ar console | Cm unset +.Cm set | unset Ar console .Sh DESCRIPTION The .Nm @@ -91,7 +91,7 @@ the name of the directory may be omitted Change the state of console muting. All console output is suppressed when console muting is .Cm on . -.It Cm set Ar console | Cm unset +.It Cm set | unset Ar console Set or unset the virtual console. When unset, output from the system, such as the kernel .Xr printf 9 , Modified: head/sbin/conscontrol/conscontrol.c ============================================================================== --- head/sbin/conscontrol/conscontrol.c Mon Apr 18 20:07:08 2011 (r220800) +++ head/sbin/conscontrol/conscontrol.c Mon Apr 18 20:28:07 2011 (r220801) @@ -50,7 +50,7 @@ usage(void) "usage: conscontrol [list]", " conscontrol mute on | off", " conscontrol add | delete console", - " conscontrol set console | unset"); + " conscontrol set | unset console"); exit(1); } @@ -153,28 +153,16 @@ consdel(char *devnam) } static void -consset(char *devnam) +consset(char *devnam, int flag) { - int ttyfd, flag = 1; + int ttyfd; ttyfd = open(devnam, O_RDONLY); if (ttyfd == -1) err(1, "opening %s", devnam); if (ioctl(ttyfd, TIOCCONS, &flag) == -1) - err(1, "could not set %s as virtual console", devnam); - close(ttyfd); -} - -static void -consunset(void) -{ - int ttyfd, flag = 0; - - ttyfd = open(DEVDIR "console", O_RDONLY); - if (ttyfd == -1) - err(1, "opening virtual console"); - if (ioctl(ttyfd, TIOCCONS, &flag) == -1) - err(1, "could not unset virtual console"); + err(1, "could not %s %s as virtual console", + flag ? "set" : "unset", devnam); close(ttyfd); } @@ -188,9 +176,7 @@ main(int argc, char **argv) argv += optind; if (argc > 0 && strcmp(argv[0], "list") != 0) { - if (argc == 1 && strcmp(argv[0], "unset") == 0) - consunset(); - else if (argc != 2) + if (argc != 2) usage(); else if (strcmp(argv[0], "mute") == 0) consmute(argv[1]); @@ -199,7 +185,9 @@ main(int argc, char **argv) else if (strcmp(argv[0], "delete") == 0) consdel(argv[1]); else if (strcmp(argv[0], "set") == 0) - consset(argv[1]); + consset(argv[1], 1); + else if (strcmp(argv[0], "unset") == 0) + consset(argv[1], 0); else usage(); }