From 3e96616fd4d65cc20b319ecfc987377952395e83 Mon Sep 17 00:00:00 2001 From: dd Date: Wed, 10 Jul 2002 03:31:25 +0000 Subject: Add an -S option that allows the user to disable vty switching. It is implemented using a new VT_LOCKSWITCH ioctl. Although it is possible to implement something like this by VT_SETMODEing to VT_PROCESS and never releasing the vty, that method has a number of downsides, the biggest of which is that some program has to stay resident for the lock to be in effect. Reviewed by: roam, sheldonh --- usr.sbin/vidcontrol/vidcontrol.1 | 8 +++++++- usr.sbin/vidcontrol/vidcontrol.c | 24 ++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/vidcontrol/vidcontrol.1 b/usr.sbin/vidcontrol/vidcontrol.1 index 332643c..0fca733 100644 --- a/usr.sbin/vidcontrol/vidcontrol.1 +++ b/usr.sbin/vidcontrol/vidcontrol.1 @@ -13,7 +13,7 @@ .\" @(#)vidcontrol.1 .\" $FreeBSD$ .\" -.Dd May 27, 2001 +.Dd May 27, 2002 .Dt VIDCONTROL 1 .Os .Sh NAME @@ -36,6 +36,7 @@ .Op Fl M Ar char .Op Fl m Cm on | off .Op Fl r Ar foreground Ar background +.Op Fl S Cm on | off .Op Fl s Ar number .Op Fl t Ar N | Cm off .Op Ar mode @@ -213,6 +214,11 @@ Change reverse mode colors to .Ar foreground and .Ar background . +.It Fl S Cm on | off +Turn vty switching on or off. +When vty switching is off, +attempts to switch to a different virtual terminal will fail. +(The default is to permit vty switching.) .It Fl s Ar number Set the current vty to .Ar number . diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c index 3bc73d1..5f0d018 100644 --- a/usr.sbin/vidcontrol/vidcontrol.c +++ b/usr.sbin/vidcontrol/vidcontrol.c @@ -76,7 +76,7 @@ usage() "usage: vidcontrol [-CdLPpx] [-b color] [-c appearance] [-f [size] file]", " [-g geometry] [-h size] [-i adapter | mode] [-l screen_map]", " [-m on | off] [-M char] [-r foreground background] [-s num]", -" [-t N | off] [mode] [foreground [background]] [show]"); +" [-S on | off] [-t N | off] [mode] [foreground [background]] [show]"); exit(1); } @@ -518,6 +518,23 @@ set_mouse(char *arg) ioctl(0, CONS_MOUSECTL, &mouse); } +void +set_lockswitch(char *arg) +{ + int data; + + if (!strcmp(arg, "off")) + data = 0x01; + else if (!strcmp(arg, "on")) + data = 0x02; + else { + warnx("argument to -S must either on or off"); + return; + } + if (ioctl(0, VT_LOCKSWITCH, &data) == -1) + warn("ioctl(VT_LOCKSWITCH)"); +} + static char *adapter_name(int type) { @@ -749,7 +766,7 @@ main(int argc, char **argv) /* Not reached */ if (ioctl(0, CONS_GETINFO, &info) < 0) err(1, "must be on a virtual console"); - while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:s:t:x")) != -1) + while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:S:s:t:x")) != -1) switch(opt) { case 'b': set_border_color(optarg); @@ -806,6 +823,9 @@ main(int argc, char **argv) case 'r': set_reverse_colors(argc, argv, &optind); break; + case 'S': + set_lockswitch(optarg); + break; case 's': set_console(optarg); break; -- cgit v1.1