Merge branch 'devttynullsplash' into 'main'

main: Assume graphical splash when the active kernel console is /dev/ttynull.

See merge request plymouth/plymouth!327
This commit is contained in:
Ray Strode 2024-08-06 09:37:55 +00:00
commit 32bf3a81f2
4 changed files with 48 additions and 3 deletions

View file

@ -974,7 +974,9 @@ add_consoles_from_file (ply_device_manager_t *manager,
contents_length = read (fd, contents, sizeof(contents) - 1);
if (contents_length <= 0) {
ply_trace ("couldn't read it: %m");
if (contents_length < 0)
ply_trace ("couldn't read it: %m");
close (fd);
return false;
}

View file

@ -1259,6 +1259,34 @@ ply_kernel_command_line_override (const char *command_line)
kernel_command_line_is_set = true;
}
char *
ply_get_primary_kernel_console_type (void)
{
int fd;
int len;
char proc_consoles[4096] = "";
size_t return_length;
if (ply_file_exists ("/proc/consoles")) {
ply_trace ("opening /proc/consoles");
fd = open ("/proc/consoles", O_RDONLY);
len = read (fd, proc_consoles, sizeof(proc_consoles));
close (fd);
/* The device type for /dev/ttyS0 is "ttyS".
* for /dev/ttynull it is "ttynull", which appears as "ttynull0" in /proc/consoles. Exclude any numbers at the end.
*/
for (return_length = 0; return_length < len; return_length++) {
/* Read until the next digit or space, the digit should be first */
if (isdigit (proc_consoles[return_length]) || isspace (proc_consoles[return_length]))
return strndup (proc_consoles, return_length);
}
}
return NULL;
}
double ply_strtod (const char *str)
{
char *old_locale;

View file

@ -176,6 +176,8 @@ bool ply_kernel_command_line_has_argument (const char *argument);
void ply_kernel_command_line_override (const char *command_line);
char *ply_kernel_command_line_get_key_value (const char *key);
char *ply_get_primary_kernel_console_type (void);
double ply_strtod (const char *str);
bool ply_is_secure_boot_enabled (void);

View file

@ -884,6 +884,19 @@ sh_is_init (state_t *state)
return result;
}
static bool
kernel_console_is_ttynull (void)
{
char *kernel_console = ply_get_primary_kernel_console_type ();
/* If the primary console is ttynull, the kernel console is virtual.
*/
if (strcmp (kernel_console, "ttynull") == 0)
return true;
return false;
}
static bool
plymouth_should_show_default_splash (state_t *state)
{
@ -925,7 +938,7 @@ plymouth_should_show_default_splash (state_t *state)
}
if (state->should_force_default_splash) {
ply_trace ("using default splash because kernel command line has option \"plymouth.graphical\"");
ply_trace ("using default splash because forced by \"plymouth.graphical\" or no active kernel console");
return true;
}
@ -2457,7 +2470,7 @@ main (int argc,
signal (SIGSEGV, on_crash);
signal (SIGFPE, on_crash);
if (graphical_boot || ply_kernel_command_line_has_argument ("plymouth.graphical")) {
if (graphical_boot || ply_kernel_command_line_has_argument ("plymouth.graphical") || kernel_console_is_ttynull ()) {
state.should_force_default_splash = true;
ignore_serial_consoles = true;
}