blob: 86d3f2ddb4d23d23c4ad34b9f0555a45fbab93e6 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen0460ff21999-10-25 23:32:44 +00002/*
Eric Andersen28672dd2003-10-22 10:30:53 +00003 * Mini chvt implementation for busybox
Eric Andersen0460ff21999-10-25 23:32:44 +00004 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersen28672dd2003-10-22 10:30:53 +00006 *
Bernhard Reutner-Fischerb1629b12006-05-19 19:29:19 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersen0460ff21999-10-25 23:32:44 +00008 */
Mark Whitley827e45c2001-03-09 23:59:51 +00009
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000010#include "libbb.h"
Eric Andersenbd22ed82000-07-08 18:55:24 +000011
12/* From <linux/vt.h> */
Rob Landleybc68cd12006-03-10 19:22:06 +000013enum {
14 VT_ACTIVATE = 0x5606, /* make vt active */
15 VT_WAITACTIVE = 0x5607 /* wait for vt active */
16};
Eric Andersenbd22ed82000-07-08 18:55:24 +000017
Denis Vlasenko06af2162007-02-03 17:28:39 +000018int chvt_main(int argc, char **argv);
Erik Andersene49d5ec2000-02-08 19:58:47 +000019int chvt_main(int argc, char **argv)
Eric Andersen0460ff21999-10-25 23:32:44 +000020{
Erik Andersene49d5ec2000-02-08 19:58:47 +000021 int fd, num;
Eric Andersen0460ff21999-10-25 23:32:44 +000022
Glenn L McGrath6a786312004-01-14 07:34:37 +000023 if (argc != 2) {
Manuel Novoa III cad53642003-03-19 09:13:01 +000024 bb_show_usage();
Eric Andersen28672dd2003-10-22 10:30:53 +000025 }
26
Eric Andersenc38678d2002-09-16 06:22:25 +000027 fd = get_console_fd();
Denis Vlasenko13858992006-10-08 12:49:22 +000028 num = xatoul_range(argv[1], 1, 63);
Denis Vlasenkofb79a2e2007-07-14 22:07:14 +000029 xioctl(fd, VT_ACTIVATE, (void *)num);
30 xioctl(fd, VT_WAITACTIVE, (void *)num);
Matt Kraai3e856ce2000-12-01 02:55:13 +000031 return EXIT_SUCCESS;
Eric Andersen0460ff21999-10-25 23:32:44 +000032}