2000-02-08 19:58:47 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
1999-10-25 23:32:44 +00:00
|
|
|
/*
|
|
|
|
* chvt.c - aeb - 940227 - Change virtual terminal
|
|
|
|
*
|
|
|
|
* busyboxed by Erik Andersen
|
|
|
|
*/
|
2001-03-09 23:59:51 +00:00
|
|
|
|
|
|
|
/* getopt not needed */
|
|
|
|
|
1999-10-25 23:32:44 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fcntl.h>
|
2000-07-08 18:55:24 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
2001-02-20 06:14:08 +00:00
|
|
|
#include "busybox.h"
|
2000-07-08 18:55:24 +00:00
|
|
|
|
|
|
|
/* From <linux/vt.h> */
|
2001-01-23 22:30:04 +00:00
|
|
|
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
|
|
|
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
2000-07-08 18:55:24 +00:00
|
|
|
|
2000-02-08 19:58:47 +00:00
|
|
|
int chvt_main(int argc, char **argv)
|
1999-10-25 23:32:44 +00:00
|
|
|
{
|
2000-02-08 19:58:47 +00:00
|
|
|
int fd, num;
|
1999-10-25 23:32:44 +00:00
|
|
|
|
2000-07-14 23:28:47 +00:00
|
|
|
if ((argc != 2) || (**(argv + 1) == '-'))
|
2001-02-14 21:23:06 +00:00
|
|
|
show_usage();
|
2000-02-08 19:58:47 +00:00
|
|
|
fd = get_console_fd("/dev/console");
|
|
|
|
num = atoi(argv[1]);
|
2000-12-14 05:44:36 +00:00
|
|
|
if (ioctl(fd, VT_ACTIVATE, num))
|
|
|
|
perror_msg_and_die("VT_ACTIVATE");
|
|
|
|
if (ioctl(fd, VT_WAITACTIVE, num))
|
|
|
|
perror_msg_and_die("VT_WAITACTIVE");
|
2000-12-01 02:55:13 +00:00
|
|
|
return EXIT_SUCCESS;
|
1999-10-25 23:32:44 +00:00
|
|
|
}
|
2000-03-04 21:19:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Local Variables:
|
|
|
|
c-file-style: "linux"
|
|
|
|
c-basic-offset: 4
|
|
|
|
tab-width: 4
|
|
|
|
End:
|
|
|
|
*/
|