mirror of
https://github.com/troglobit/finit.git
synced 2026-11-07 16:01:08 +00:00
Adjust logic in finding system consoles for progress/debug output
By default, Linux gives us /dev/console for output. This is a pseudo device that uses the same actual device as the last console=foo listed in /proc/cmdline. The last one listed is the main console, which is also the *first* one listed in /sys/class/tty/console/active, so we skip that when we check for system consoles to avoid duplicating output. The getty code in tty.c currently has its own handling of @console, which we keep for now. Ideally, however, the code should be merged. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
5404aa6037
commit
3027a6755f
1 file changed
+20
-6
+20
-6
@@ -75,9 +75,16 @@ static const char *color[] = STATUS_CLASS;
|
|||||||
*/
|
*/
|
||||||
#define MAX_CONS 3
|
#define MAX_CONS 3
|
||||||
|
|
||||||
static char *consoles[MAX_CONS];
|
/*
|
||||||
static int fds[MAX_CONS];
|
* Linux gives us stdio using /dev/console by default. This is the
|
||||||
static int num_cons = 0;
|
* first one listed in /sys/class/tty/console/active so we don't need
|
||||||
|
* to register that again.
|
||||||
|
*
|
||||||
|
* NOTE: the getty @console is handled separately in tty.c, for now.
|
||||||
|
*/
|
||||||
|
static char *consoles[MAX_CONS] = { "/dev/console" };
|
||||||
|
static int fds[MAX_CONS] = { 2 };
|
||||||
|
static int num_cons = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System default console is always the first
|
* System default console is always the first
|
||||||
@@ -124,6 +131,14 @@ static void add_console(char *cons)
|
|||||||
num_cons++;
|
num_cons++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The main console is the first listed in /sys/class/tty/console/active
|
||||||
|
* we already have that open from the kernel as /dev/console, which is
|
||||||
|
* all we need to display progress and debug messages. If there are any
|
||||||
|
* more we add them as secondary consoles for displaying progress etc.
|
||||||
|
*
|
||||||
|
* The getty code in tty.c is separate from this, for now.
|
||||||
|
*/
|
||||||
static void find_active_consoles(void)
|
static void find_active_consoles(void)
|
||||||
{
|
{
|
||||||
char *cons, *ptr, *tok;
|
char *cons, *ptr, *tok;
|
||||||
@@ -145,10 +160,9 @@ static void find_active_consoles(void)
|
|||||||
|
|
||||||
cons = chomp(ptr);
|
cons = chomp(ptr);
|
||||||
_d("Using these system consoles: %s", cons);
|
_d("Using these system consoles: %s", cons);
|
||||||
while ((tok = strtok(cons, " \t"))) {
|
strtok(cons, " \t");
|
||||||
cons = NULL;
|
while ((tok = strtok(NULL, " \t")))
|
||||||
add_console(tok);
|
add_console(tok);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_init(void)
|
void console_init(void)
|
||||||
|
|||||||
Reference in new issue
Block a user