tools: kwboot: unbreak terminal-only mode
From: Willy Tarreau <[email protected]>
Commit 84899e2 ("tools/kwboot: Sync with latest barebox version to support Armada XP") accidently broke the terminal-only mode (-t) by removing the test on the bootmsg. Thus even when trying to use kwboot as a plain terminal, it asks to reboot the target.
This commit simply reintroduces the lost test so that it is possible again to use kwboot to attach to the target system's console.
--- tools/kwboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/kwboot.c +1 -1
@@ -821,7 +821,7 @@ main(int argc, char **argv)perror ("debugmsg" ); goto out; } - }else { + }else if (bootmsg) { rc =kwboot_bootmsg (tty, bootmsg);if (rc) {perror ("bootmsg" );
Signature · 1 line
1.7.12.1
[U-Boot] tools: kwboot: properly quit when read() returns 0
From: Willy Tarreau <[email protected]>
When kwboot is attached to a terminal which disappears such as one connected via an unplugged USB cable, read() returns 0, making kwboot loop until a key is pressed in the terminal. The only case where read() may return 0 here is when the terminal is closed anyway, so let's properly handle this one and report is similar to other errors.
--- tools/kwboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/kwboot.c +2 -2
@@ -182,7 +182,7 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo) } n =read (fd, buf, len); -if (n <0 ) +if (n <=0 ) goto out; buf = (char *)buf + n;
@@ -466,7 +466,7 @@ kwboot_term_pipe(int in, int out, char *quit, int *s)char _buf[128 ], *buf = _buf; nin =read (in, buf,sizeof (buf)); -if (nin <0 ) +if (nin <=0 )return -1 ;if (quit) {
Signature · 1 line
1.7.12.1