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);
if (fd < 0)
{
ply_trace ("couldn't open it: %m");
- return 0;
+ return false;
}
ply_trace ("reading file");
{
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)
{
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,
remaining_file_contents += console_length + 1;
}
- return num_consoles;
+ return has_serial_consoles;
}
static void
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,