summaryrefslogtreecommitdiff
path: root/console-tools/fgconsole.c
diff options
context:
space:
mode:
authorGrigory Batalov2010-05-23 23:22:10 +0200
committerDenys Vlasenko2010-05-23 23:22:10 +0200
commitad7a5d436c8dec563f834a0a9bdad9e69b333cc9 (patch)
treec28e639d7c526dca6ef6d29892b05a416f6b8286 /console-tools/fgconsole.c
parenta85b66e0f906fedbba7fbaf5ea9ac0dbfc0e4916 (diff)
downloadbusybox-ad7a5d436c8dec563f834a0a9bdad9e69b333cc9.zip
busybox-ad7a5d436c8dec563f834a0a9bdad9e69b333cc9.tar.gz
fgconsole: new applet by Grigory Batalov <bga@altlinux.org>
function old new delta fgconsole_main - 51 +51 applet_names 2227 2237 +10 applet_main 1304 1308 +4 applet_nameofs 652 654 +2 applet_install_loc 163 164 +1 packed_usage 27079 27073 -6 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/1 up/down: 68/-6) Total: 62 bytes Signed-off-by: Grigory Batalov <bga@altlinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'console-tools/fgconsole.c')
-rw-r--r--console-tools/fgconsole.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/console-tools/fgconsole.c b/console-tools/fgconsole.c
new file mode 100644
index 0000000..75fd98f
--- /dev/null
+++ b/console-tools/fgconsole.c
@@ -0,0 +1,30 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini fgconsole implementation for busybox
+ *
+ * Copyright (C) 2010 by Grigory Batalov <bga@altlinux.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+
+#include "libbb.h"
+
+/* From <linux/vt.h> */
+struct vt_stat {
+ unsigned short v_active; /* active vt */
+ unsigned short v_signal; /* signal to send */
+ unsigned short v_state; /* vt bitmask */
+};
+enum { VT_GETSTATE = 0x5603 }; /* get global vt state info */
+
+int fgconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int fgconsole_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
+{
+ struct vt_stat vtstat;
+
+ vtstat.v_active = 0;
+ xioctl(get_console_fd_or_die(), VT_GETSTATE, &vtstat);
+ printf("%d\n", vtstat.v_active);
+
+ return EXIT_SUCCESS;
+}