busybox/console-tools/fgconsole.c
Ron Yorston 5c69ad0ecd build system: drop PLATFORM_LINUX
PLATFORM_LINUX is a hidden configuration option which is disabled by
default and enabled at over a hundred locations for features that are
deemed to be Linux specific.

The only effect of PLATFORM_LINUX is to control compilation of
libbb/match_fstype.c.  This file is only needed by mount and umount.

Remove all references to PLATFORM_LINUX and compile match_fstype.c
if mount or umount is enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 17:12:56 +02:00

45 lines
1.2 KiB
C

/* 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 source tree.
*/
//config:config FGCONSOLE
//config: bool "fgconsole (1.5 kb)"
//config: default y
//config: help
//config: This program prints active (foreground) console number.
//applet:IF_FGCONSOLE(APPLET_NOEXEC(fgconsole, fgconsole, BB_DIR_USR_BIN, BB_SUID_DROP, fgconsole))
//kbuild:lib-$(CONFIG_FGCONSOLE) += fgconsole.o
//usage:#define fgconsole_trivial_usage
//usage: ""
//usage:#define fgconsole_full_usage "\n\n"
//usage: "Get active console"
#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;
}