Drop confusing splash cmdline and --enable-progress configure option

This patch reverts back to the progress/status behavior of Finit < v3.0
because this is what most users expect, including the maintainer.  The
resulting code and configure script is a lot simpler to understand and
maintain:

- No more --enable-progress or --enable-progress-classic configure
  flags.  Instead a progress_style variable in helpers.c that can
  be changed at compile time for those that really need it.
- No more 'splash' kernel commnand line option.  This turned out to
  be *very* confusing to many users who believed it was some sort of
  graphical splash screen à la Plymouth.

Also, when Finit debug is enabled we now have a global 'debug' flag
which now alo controls if klogctl() should be called to prevent the
kernel logs to the console or not.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-02-14 20:11:08 +01:00
parent 13a33d345b
commit 35e4e0d073
13 changed files with 55 additions and 130 deletions
+5 -8
View File
@@ -75,20 +75,17 @@ static void hide_args(int argc, char *argv[])
}
}
static void parse_arg(char *arg, int *dbg)
static void parse_arg(char *arg)
{
/* Catches finit_debug (deprecated), --debug, and debug */
/* Catches finit_debug, --debug, and debug */
if (strstr(arg, "debug"))
*dbg = 1;
debug = 1;
if (string_compare(arg, "rescue") || string_compare(arg, "recover"))
rescue = 1;
if (string_compare(arg, "single") || string_compare(arg, "S"))
single = 1;
if (string_compare(arg, "splash"))
splash = 1;
}
void conf_parse_cmdline(int argc, char *argv[])
@@ -98,7 +95,7 @@ void conf_parse_cmdline(int argc, char *argv[])
char line[LINE_SIZE], *cmdline, *tok;
for (int i = 1; i < argc; i++)
parse_arg(argv[i], &dbg);
parse_arg(argv[i]);
hide_args(argc, argv);
@@ -116,7 +113,7 @@ void conf_parse_cmdline(int argc, char *argv[])
while ((tok = strtok(cmdline, " \t"))) {
cmdline = NULL;
parse_arg(tok, &dbg);
parse_arg(tok);
}
fclose(fp);
+3 -3
View File
@@ -172,7 +172,7 @@ int run_interactive(char *cmd, char *fmt, ...)
/* Redirect output from cmd to a tempfile */
fp = tempfile();
if (fp && !log_is_debug()) {
if (fp && !debug) {
oldout = dup(STDOUT_FILENO);
olderr = dup(STDERR_FILENO);
dup2(fileno(fp), STDOUT_FILENO);
@@ -183,7 +183,7 @@ int run_interactive(char *cmd, char *fmt, ...)
status = run(cmd);
/* Restore stderr/stdout */
if (fp && !log_is_debug()) {
if (fp && !debug) {
if (oldout >= 0) {
dup2(oldout, STDOUT_FILENO);
close(oldout);
@@ -198,7 +198,7 @@ int run_interactive(char *cmd, char *fmt, ...)
print_result(status);
/* Dump any results of cmd on stderr after we've printed [ OK ] or [FAIL] */
if (fp && !log_is_debug()) {
if (fp && !debug) {
size_t len, written;
rewind(fp);
+9 -9
View File
@@ -55,9 +55,9 @@
int runlevel = 0; /* Bootstrap 'S' */
int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */
int prevlevel = -1;
int debug = 0; /* debug mode from kernel cmdline */
int rescue = 0; /* rescue mode from kernel cmdline */
int single = 0; /* single user mode from kernel cmdline */
int splash = 0; /* splash + progress enabled on kernel cmdline */
char *sdown = NULL;
char *network = NULL;
char *hostname = NULL;
@@ -78,7 +78,8 @@ static void banner(void)
* similar enabled to start emptying /dev/kmsg, but for
* our progress we want to own the console.
*/
klogctl(6, NULL, 0);
if (!debug)
klogctl(6, NULL, 0);
/*
* First level hooks, if you want to run here, you're
@@ -86,9 +87,6 @@ static void banner(void)
*/
plugin_run_hooks(HOOK_BANNER);
if (log_is_silent())
return;
print_banner(INIT_HEADING);
}
@@ -310,8 +308,10 @@ static void finalize(void)
service_step_all(SVC_TYPE_ANY);
/* Enable silent mode before starting TTYs */
_d("Going silent ...");
log_silent();
if (!debug) {
_d("Going silent ...");
show_progress(0);
}
/* Delayed start of TTYs at bootstrap */
_d("Launching all getty services ...");
@@ -381,7 +381,7 @@ int main(int argc, char *argv[])
fs_init();
/*
* Parse /proc/cmdline (debug, rescue, splash, console=, etc.)
* Parse /proc/cmdline (debug, rescue, console=, etc.)
* Also calls log_init() to set correct log level
*/
conf_parse_cmdline(argc, argv);
@@ -407,7 +407,7 @@ int main(int argc, char *argv[])
umask(0);
/* Set up canvas */
if (!rescue && !log_is_debug())
if (!rescue && !debug)
screen_init();
/*
+1 -1
View File
@@ -92,9 +92,9 @@ struct init_request {
extern int runlevel;
extern int cfglevel;
extern int prevlevel;
extern int debug;
extern int rescue;
extern int single;
extern int splash;
extern char *rcsd;
extern char *sdown;
extern char *network;
+26 -7
View File
@@ -39,7 +39,14 @@
#include "util.h"
#include "utmp-api.h"
static int progress_style = PROGRESS_STYLE;
typedef enum {
PROGRESS_SILENT,
PROGRESS_CLASSIC,
PROGRESS_MODERN,
} pstyle_t;
#define PROGRESS_DEFAULT PROGRESS_MODERN
static pstyle_t progress_style = PROGRESS_DEFAULT;
#ifndef HOSTNAME_PATH
#define HOSTNAME_PATH "/etc/hostname"
@@ -182,6 +189,14 @@ char *strip_line(char *line)
return line;
}
void show_progress(int onoff)
{
if (onoff)
progress_style = PROGRESS_DEFAULT;
else
progress_style = PROGRESS_SILENT;
}
/*
* Return screen length of string, not counting escape chars, and
* accounting for unicode characters as only one screen byte wide
@@ -234,9 +249,13 @@ void print_banner(const char *heading)
{
char buf[4 * SCREEN_WIDTH];
if (progress_style == PROGRESS_SILENT)
return;
memset(buf, 0, sizeof(buf));
strlcat(buf, "\r\e[2K", sizeof(buf));
if (progress_style == 1) {
if (progress_style == PROGRESS_CLASSIC) {
strlcat(buf, "\e[1m", sizeof(buf));
strlcat(buf, heading, sizeof(buf));
pad(buf, sizeof(buf), "=", SCREEN_WIDTH - 2);
@@ -289,7 +308,7 @@ static char *status(int rc)
if (rc < 0 || rc >= (int)NELEMS(status1))
rc = NELEMS(status1) - 1; /* Default to "⋯" (pending) */
if (progress_style == 1) {
if (progress_style == PROGRESS_CLASSIC) {
int hl = 1;
if (rc == 1 || rc == 2)
@@ -307,7 +326,7 @@ void printv(const char *fmt, va_list ap)
char buf[SCREEN_WIDTH];
size_t len;
if (!fmt || log_is_silent())
if (!fmt || progress_style == PROGRESS_SILENT)
return;
delline();
@@ -316,7 +335,7 @@ void printv(const char *fmt, va_list ap)
len = print_timestamp(buf, sizeof(buf));
vsnprintf(&buf[len], sizeof(buf) - len, fmt, ap);
if (progress_style == 1)
if (progress_style == PROGRESS_CLASSIC)
cprintf("\r%s ", pad(buf, sizeof(buf), ".", sizeof(buf)));
else
cprintf("\r\e[2K%s%s", status(3), buf);
@@ -324,7 +343,7 @@ void printv(const char *fmt, va_list ap)
void print(int rc, const char *fmt, ...)
{
if (log_is_silent())
if (progress_style == PROGRESS_SILENT)
return;
if (fmt) {
@@ -338,7 +357,7 @@ void print(int rc, const char *fmt, ...)
if (rc < 0)
return;
if (progress_style == 1)
if (progress_style == PROGRESS_CLASSIC)
cprintf("%s\n", status(rc));
else
cprintf("\r%s\n", status(rc));
+1
View File
@@ -55,6 +55,7 @@ void console_init (void);
ssize_t cprintf (const char *fmt, ...);
char *strip_line (char *line);
void show_progress (int onoff);
int getty (char *tty, speed_t speed, char *term, char *user);
int sh (char *tty);
+3 -45
View File
@@ -28,43 +28,24 @@
#include <lite/lite.h>
#include "finit.h"
#include "helpers.h"
#include "log.h"
#include "util.h"
static int up = 0;
static int debug = 0;
static int silent = SILENT_MODE; /* Completely silent, including boot */
static int loglevel = LOG_NOTICE;
static void muffler(void)
{
silent = SILENT_MODE;
/* User override from kernel cmdline */
if (splash)
silent = 0;
}
void log_init(int dbg)
{
if (dbg)
debug = 1;
if (debug)
loglevel = LOG_DEBUG;
else
loglevel = LOG_NOTICE;
muffler();
}
/* If we enabled terse mode at boot, restore to previous setting at shutdown */
void log_exit(void)
{
muffler();
if (!silent)
sched_yield();
/*
* Unless in debug mode at shutdown, Reinitialize screen,
* terminal may have been resized at runtime
@@ -73,6 +54,8 @@ void log_exit(void)
screen_exit();
else
screen_init();
show_progress(1);
}
void log_open(void)
@@ -89,48 +72,23 @@ void log_open(void)
up = 1;
}
void log_silent(void)
{
if (debug)
silent = 0;
else
silent = 1;
}
int log_is_silent(void)
{
return silent;
}
/* Toggle debug mode */
void log_debug(void)
{
debug = !debug;
if (debug) {
silent = 0;
loglevel = LOG_DEBUG;
screen_exit();
} else {
silent = SILENT_MODE;
loglevel = LOG_NOTICE;
screen_init();
}
log_open();
/* Also toggle silent mode (progress) */
log_silent();
logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled");
}
int log_is_debug(void)
{
return debug;
}
/*
* Log to /dev/kmsg until syslogd has started, then openlog()
* and continue logging as a regular daemon.
-4
View File
@@ -48,11 +48,7 @@
void log_init (int dbg);
void log_exit (void);
void log_silent (void);
int log_is_silent (void);
void log_debug (void);
int log_is_debug (void);
void logit (int prio, const char *fmt, ...);
+2 -2
View File
@@ -256,7 +256,7 @@ static int redirect(svc_t *svc)
return fredirect(console());
return lredirect(svc);
} else if (log_is_debug())
} else if (debug)
return fredirect(console());
#ifdef REDIRECT_OUTPUT
else
@@ -393,7 +393,7 @@ static int service_start(svc_t *svc)
status = execvp(svc->cmd, args);
_exit(status);
} else if (log_is_debug()) {
} else if (debug) {
char buf[CMD_SIZE] = "";
for (i = 0; i < (MAX_NUM_SVC_ARGS - 1) && svc->args[i][0] != 0; i++) {