terminal-util: make get_kernel_consoles() return > 0 if /dev/console is resolved
This commit is contained in:
@@ -866,13 +866,12 @@ int resolve_dev_console(char **ret) {
|
||||
int get_kernel_consoles(char ***ret) {
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
_cleanup_free_ char *line = NULL;
|
||||
const char *p;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* If /sys is mounted read-only this means we are running in some kind of container environment. In that
|
||||
* case /sys would reflect the host system, not us, hence ignore the data we can read from it. */
|
||||
/* If /sys/ is mounted read-only this means we are running in some kind of container environment.
|
||||
* In that case /sys/ would reflect the host system, not us, hence ignore the data we can read from it. */
|
||||
if (path_is_read_only_fs("/sys") > 0)
|
||||
goto fallback;
|
||||
|
||||
@@ -880,8 +879,7 @@ int get_kernel_consoles(char ***ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
p = line;
|
||||
for (;;) {
|
||||
for (const char *p = line;;) {
|
||||
_cleanup_free_ char *tty = NULL, *path = NULL;
|
||||
|
||||
r = extract_first_word(&p, &tty, NULL, 0);
|
||||
@@ -917,8 +915,7 @@ int get_kernel_consoles(char ***ret) {
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(l);
|
||||
|
||||
return 0;
|
||||
return strv_length(*ret);
|
||||
|
||||
fallback:
|
||||
r = strv_extend(&l, "/dev/console");
|
||||
@@ -926,7 +923,6 @@ fallback:
|
||||
return r;
|
||||
|
||||
*ret = TAKE_PTR(l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user