]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
device-manager: ignore udev if only console is serial console
authorRay Strode <rstrode@redhat.com>
Mon, 3 Mar 2014 22:55:59 +0000 (17:55 -0500)
committerRay Strode <rstrode@redhat.com>
Mon, 3 Mar 2014 23:02:25 +0000 (18:02 -0500)
Right now we use the heuristic, "more than one entry in
/sys/class/tty/console/active" to mean "has serial consoles".

We used to use the heuristic "file has more than tty0 in it".
The older heuristic is more accurate because a user may have
console=ttyS0 without console=tty0 on the kernel command line.

src/libply-splash-core/ply-device-manager.c

index d06e1b5da96991132bd6eee67e472eb1cdeab2d4..098fd85220e1d4ce25e95d597794438209de4b8b 100644 (file)
@@ -541,14 +541,14 @@ ply_device_manager_free (ply_device_manager_t *manager)
   free (manager);
 }
 
-static int
+static bool
 add_consoles_from_file (ply_device_manager_t *manager,
                         const char           *path)
 {
   int fd;
   char contents[512] = "";
   ssize_t contents_length;
-  int num_consoles;
+  bool has_serial_consoles;
   const char *remaining_file_contents;
 
   ply_trace ("opening %s", path);
@@ -557,7 +557,7 @@ add_consoles_from_file (ply_device_manager_t *manager,
   if (fd < 0)
     {
       ply_trace ("couldn't open it: %m");
-      return 0;
+      return false;
     }
 
   ply_trace ("reading file");
@@ -567,12 +567,12 @@ add_consoles_from_file (ply_device_manager_t *manager,
     {
       ply_trace ("couldn't read it: %m");
       close (fd);
-      return 0;
+      return false;
     }
   close (fd);
 
   remaining_file_contents = contents;
-  num_consoles = 0;
+  has_serial_consoles = false;
 
   while (remaining_file_contents < contents + contents_length)
     {
@@ -603,7 +603,9 @@ add_consoles_from_file (ply_device_manager_t *manager,
       free (console);
 
       ply_trace ("console %s found!", console_device);
-      num_consoles++;
+
+      if (terminal != manager->local_console_terminal)
+        has_serial_consoles = true;
 
       /* Move past the parsed console string, and the whitespace we
        * may have found above.  If we found a NUL above and not whitespace,
@@ -613,7 +615,7 @@ add_consoles_from_file (ply_device_manager_t *manager,
       remaining_file_contents += console_length + 1;
     }
 
-  return num_consoles;
+  return has_serial_consoles;
 }
 
 static void
@@ -667,24 +669,21 @@ create_seat_for_terminal (const char           *device_path,
 static bool
 create_seats_from_terminals (ply_device_manager_t *manager)
 {
-  int num_consoles;
+  bool has_serial_consoles;
 
   ply_trace ("checking for consoles");
 
   if (manager->flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_SERIAL_CONSOLES)
     {
-      num_consoles = 0;
+      has_serial_consoles = false;
       ply_trace ("ignoring all consoles but default console because explicitly told to.");
     }
   else
     {
-      num_consoles = add_consoles_from_file (manager, "/sys/class/tty/console/active");
-
-      if (num_consoles == 0)
-        ply_trace ("ignoring all consoles but default console because /sys/class/tty/console/active could not be read");
+      has_serial_consoles = add_consoles_from_file (manager, "/sys/class/tty/console/active");
     }
 
-  if (num_consoles > 1)
+  if (has_serial_consoles)
     {
       ply_trace ("serial consoles detected, managing them with details forced");
       ply_hashtable_foreach (manager->terminals,