[PATCH 2/5] lib: term: ask the terminal when a console can't tell its size
Ahmad Fatoum
a.fatoum at barebox.org
Sun Nov 8 01:32:04 PST 2026
term_cdev_get_size() returns whatever the get_size callback of a
console returns. A console may not always know its size, though: a
virtio console only does once the host has filled it in. Fall back to
querying the terminal when the callback fails, as for consoles without
one.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
lib/term.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/term.c b/lib/term.c
index 382250c70ddf..1322546ce8ac 100644
--- a/lib/term.c
+++ b/lib/term.c
@@ -82,8 +82,9 @@ int term_cdev_get_size(struct console_device *cdev,
if (!(cdev->f_active & CONSOLE_STDOUT))
return -ENOENT;
- if (cdev->get_size)
- return cdev->get_size(cdev, screenwidth, screenheight);
+ /* ask the terminal only if the console can't tell size */
+ if (cdev->get_size && !cdev->get_size(cdev, screenwidth, screenheight))
+ return 0;
if (!(cdev->f_active & CONSOLE_STDIN))
return -ENOENT;
--
2.47.3
More information about the barebox
mailing list