aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrigory Batalov <bga@altlinux.org>2010-05-23 23:22:10 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-23 23:22:10 +0200
commitad7a5d436c8dec563f834a0a9bdad9e69b333cc9 (patch)
treec28e639d7c526dca6ef6d29892b05a416f6b8286
parenta85b66e0f906fedbba7fbaf5ea9ac0dbfc0e4916 (diff)
downloadbusybox-w32-ad7a5d436c8dec563f834a0a9bdad9e69b333cc9.tar.gz
busybox-w32-ad7a5d436c8dec563f834a0a9bdad9e69b333cc9.tar.bz2
busybox-w32-ad7a5d436c8dec563f834a0a9bdad9e69b333cc9.zip
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>
-rw-r--r--console-tools/Config.in6
-rw-r--r--console-tools/Kbuild1
-rw-r--r--console-tools/fgconsole.c30
-rw-r--r--include/applets.h1
-rw-r--r--include/usage.h13
-rw-r--r--scripts/defconfig1
6 files changed, 48 insertions, 4 deletions
diff --git a/console-tools/Config.in b/console-tools/Config.in
index 195685b97..a7e995936 100644
--- a/console-tools/Config.in
+++ b/console-tools/Config.in
@@ -12,6 +12,12 @@ config CHVT
12 This program is used to change to another terminal. 12 This program is used to change to another terminal.
13 Example: chvt 4 (change to terminal /dev/tty4) 13 Example: chvt 4 (change to terminal /dev/tty4)
14 14
15config FGCONSOLE
16 bool "fgconsole"
17 default n
18 help
19 This program prints active (foreground) console number.
20
15config CLEAR 21config CLEAR
16 bool "clear" 22 bool "clear"
17 default n 23 default n
diff --git a/console-tools/Kbuild b/console-tools/Kbuild
index df5ffdb96..ad8b8ce77 100644
--- a/console-tools/Kbuild
+++ b/console-tools/Kbuild
@@ -6,6 +6,7 @@
6 6
7lib-y:= 7lib-y:=
8lib-$(CONFIG_CHVT) += chvt.o 8lib-$(CONFIG_CHVT) += chvt.o
9lib-$(CONFIG_FGCONSOLE) += fgconsole.o
9lib-$(CONFIG_CLEAR) += clear.o 10lib-$(CONFIG_CLEAR) += clear.o
10lib-$(CONFIG_DEALLOCVT) += deallocvt.o 11lib-$(CONFIG_DEALLOCVT) += deallocvt.o
11lib-$(CONFIG_DUMPKMAP) += dumpkmap.o 12lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
diff --git a/console-tools/fgconsole.c b/console-tools/fgconsole.c
new file mode 100644
index 000000000..75fd98fd5
--- /dev/null
+++ b/console-tools/fgconsole.c
@@ -0,0 +1,30 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini fgconsole implementation for busybox
4 *
5 * Copyright (C) 2010 by Grigory Batalov <bga@altlinux.org>
6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */
9
10#include "libbb.h"
11
12/* From <linux/vt.h> */
13struct vt_stat {
14 unsigned short v_active; /* active vt */
15 unsigned short v_signal; /* signal to send */
16 unsigned short v_state; /* vt bitmask */
17};
18enum { VT_GETSTATE = 0x5603 }; /* get global vt state info */
19
20int fgconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
21int fgconsole_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
22{
23 struct vt_stat vtstat;
24
25 vtstat.v_active = 0;
26 xioctl(get_console_fd_or_die(), VT_GETSTATE, &vtstat);
27 printf("%d\n", vtstat.v_active);
28
29 return EXIT_SUCCESS;
30}
diff --git a/include/applets.h b/include/applets.h
index ff8799c63..33c3c2555 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -157,6 +157,7 @@ IF_FBSPLASH(APPLET(fbsplash, _BB_DIR_SBIN, _BB_SUID_DROP))
157IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_DROP, fdflush)) 157IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_DROP, fdflush))
158IF_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 158IF_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_DROP))
159IF_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_DROP)) 159IF_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_DROP))
160IF_FGCONSOLE(APPLET(fgconsole, _BB_DIR_USR_BIN, _BB_SUID_DROP))
160IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep)) 161IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep))
161IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find)) 162IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find))
162IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE)) 163IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE))
diff --git a/include/usage.h b/include/usage.h
index d53b86731..8b8bd2c78 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -156,6 +156,11 @@
156 "\n -r Repetitions" \ 156 "\n -r Repetitions" \
157 "\n -n Start new tone" \ 157 "\n -n Start new tone" \
158 158
159#define blkid_trivial_usage \
160 ""
161#define blkid_full_usage "\n\n" \
162 "Print UUIDs of all filesystems"
163
159#define bootchartd_trivial_usage \ 164#define bootchartd_trivial_usage \
160 "start [PROG ARGS]|stop|init" 165 "start [PROG ARGS]|stop|init"
161#define bootchartd_full_usage "\n\n" \ 166#define bootchartd_full_usage "\n\n" \
@@ -1243,10 +1248,10 @@
1243 "\n -H HEADS" \ 1248 "\n -H HEADS" \
1244 "\n -S SECTORS" \ 1249 "\n -S SECTORS" \
1245 1250
1246#define blkid_trivial_usage \ 1251#define fgconsole_trivial_usage \
1247 "" 1252 ""
1248#define blkid_full_usage "\n\n" \ 1253#define fgconsole_full_usage "\n\n" \
1249 "Print UUIDs of all filesystems" 1254 "Get active console"
1250 1255
1251#define findfs_trivial_usage \ 1256#define findfs_trivial_usage \
1252 "LABEL=label or UUID=uuid" 1257 "LABEL=label or UUID=uuid"
diff --git a/scripts/defconfig b/scripts/defconfig
index 0a748febc..8b88f79b3 100644
--- a/scripts/defconfig
+++ b/scripts/defconfig
@@ -287,6 +287,7 @@ CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
287# Console Utilities 287# Console Utilities
288# 288#
289CONFIG_CHVT=y 289CONFIG_CHVT=y
290CONFIG_FGCONSOLE=n
290CONFIG_CLEAR=y 291CONFIG_CLEAR=y
291CONFIG_DEALLOCVT=y 292CONFIG_DEALLOCVT=y
292CONFIG_DUMPKMAP=y 293CONFIG_DUMPKMAP=y