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
|
|
|
|
*/
|
2000-09-25 21:45:58 +00:00
|
|
|
#include "busybox.h"
|
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>
|
|
|
|
|
|
|
|
/* From <linux/vt.h> */
|
|
|
|
#define VT_ACTIVATE 0x5606 /* make vt active */
|
|
|
|
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
|
|
|
|
|
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) == '-'))
|
|
|
|
usage (chvt_usage);
|
2000-02-08 19:58:47 +00:00
|
|
|
fd = get_console_fd("/dev/console");
|
|
|
|
num = atoi(argv[1]);
|
|
|
|
if (ioctl(fd, VT_ACTIVATE, num)) {
|
|
|
|
perror("VT_ACTIVATE");
|
2000-12-01 02:55:13 +00:00
|
|
|
return EXIT_FAILURE;
|
2000-02-08 19:58:47 +00:00
|
|
|
}
|
|
|
|
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
|
|
|
perror("VT_WAITACTIVE");
|
2000-12-01 02:55:13 +00:00
|
|
|
return EXIT_FAILURE;
|
2000-02-08 19:58:47 +00:00
|
|
|
}
|
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:
|
|
|
|
*/
|