mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
cttyhack: serial console detection is Linux-specific
Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
85a359afab
commit
430ba79c39
@ -13,7 +13,6 @@
|
|||||||
//config:config CTTYHACK
|
//config:config CTTYHACK
|
||||||
//config: bool "cttyhack"
|
//config: bool "cttyhack"
|
||||||
//config: default y
|
//config: default y
|
||||||
//config: depends on PLATFORM_LINUX
|
|
||||||
//config: help
|
//config: help
|
||||||
//config: One common problem reported on the mailing list is "can't access tty;
|
//config: One common problem reported on the mailing list is "can't access tty;
|
||||||
//config: job control turned off" error message which typically appears when
|
//config: job control turned off" error message which typically appears when
|
||||||
@ -59,6 +58,10 @@
|
|||||||
//usage: "\nStarting interactive shell from boot shell script:"
|
//usage: "\nStarting interactive shell from boot shell script:"
|
||||||
//usage: "\n setsid cttyhack sh"
|
//usage: "\n setsid cttyhack sh"
|
||||||
|
|
||||||
|
#if !defined(__linux__) && !defined(TIOCGSERIAL)
|
||||||
|
# warning cttyhack will not be able to detect a controlling tty on this system
|
||||||
|
#endif
|
||||||
|
|
||||||
/* From <linux/vt.h> */
|
/* From <linux/vt.h> */
|
||||||
struct vt_stat {
|
struct vt_stat {
|
||||||
unsigned short v_active; /* active vt */
|
unsigned short v_active; /* active vt */
|
||||||
@ -112,13 +115,19 @@ int cttyhack_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
close(fd);
|
close(fd);
|
||||||
} else {
|
} else {
|
||||||
/* We don't have ctty (or don't have "/dev/tty" node...) */
|
/* We don't have ctty (or don't have "/dev/tty" node...) */
|
||||||
if (ioctl(0, TIOCGSERIAL, &u.sr) == 0) {
|
if (0) {}
|
||||||
|
#ifdef TIOCGSERIAL
|
||||||
|
else if (ioctl(0, TIOCGSERIAL, &u.sr) == 0) {
|
||||||
/* this is a serial console */
|
/* this is a serial console */
|
||||||
sprintf(console + 8, "S%d", u.sr.line);
|
sprintf(console + 8, "S%d", u.sr.line);
|
||||||
} else if (ioctl(0, VT_GETSTATE, &u.vt) == 0) {
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __linux__
|
||||||
|
else if (ioctl(0, VT_GETSTATE, &u.vt) == 0) {
|
||||||
/* this is linux virtual tty */
|
/* this is linux virtual tty */
|
||||||
sprintf(console + 8, "S%d" + 1, u.vt.v_active);
|
sprintf(console + 8, "S%d" + 1, u.vt.v_active);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (console[8]) {
|
if (console[8]) {
|
||||||
fd = xopen(console, O_RDWR);
|
fd = xopen(console, O_RDWR);
|
||||||
//bb_error_msg("switching to '%s'", console);
|
//bb_error_msg("switching to '%s'", console);
|
||||||
|
Loading…
Reference in New Issue
Block a user