mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] sandbox: new --stdinout option to enable a bidirectional console
@ 2017-06-02 12:01 Aleksander Morgado
  2017-06-06  6:53 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Aleksander Morgado @ 2017-06-02 12:01 UTC (permalink / raw)
  To: barebox; +Cc: Aleksander Morgado

In addition to allowing read-only and write-only consoles with --stdin
and --stdout, we now allow bidirectional read/write consoles with FIFO
files. This is e.g. to allow doing RATP over the FIFO based consoles.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
---
 arch/sandbox/os/common.c | 53 ++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 11 deletions(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 8cf087313..665e8194e 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -312,26 +312,28 @@ static int add_dtb(const char *file)
 static void print_usage(const char*);
 
 static struct option long_options[] = {
-	{"help",   0, 0, 'h'},
-	{"malloc", 1, 0, 'm'},
-	{"image",  1, 0, 'i'},
-	{"env",    1, 0, 'e'},
-	{"dtb",    1, 0, 'd'},
-	{"stdout", 1, 0, 'O'},
-	{"stdin",  1, 0, 'I'},
-	{"xres",  1, 0, 'x'},
-	{"yres",  1, 0, 'y'},
+	{"help",     0, 0, 'h'},
+	{"malloc",   1, 0, 'm'},
+	{"image",    1, 0, 'i'},
+	{"env",      1, 0, 'e'},
+	{"dtb",      1, 0, 'd'},
+	{"stdout",   1, 0, 'O'},
+	{"stdin",    1, 0, 'I'},
+	{"stdinout", 1, 0, 'B'},
+	{"xres",     1, 0, 'x'},
+	{"yres",     1, 0, 'y'},
 	{0, 0, 0, 0},
 };
 
-static const char optstring[] = "hm:i:e:d:O:I:x:y:";
+static const char optstring[] = "hm:i:e:d:O:I:B:x:y:";
 
 int main(int argc, char *argv[])
 {
 	void *ram;
-	int opt, ret, fd;
+	int opt, ret, fd, fd2;
 	int malloc_size = CONFIG_MALLOC_SIZE;
 	int fdno = 0, envno = 0, option_index = 0;
+	char *aux;
 
 	while (1) {
 		option_index = 0;
@@ -421,6 +423,31 @@ int main(int argc, char *argv[])
 
 			barebox_register_console(fd, -1);
 			break;
+		case 'B':
+			aux = strchr(optarg, ',');
+			if (!aux) {
+				printf("-B, --stdinout requires two file paths given\n");
+				exit(1);
+			}
+
+			/* open stdout file */
+			fd = open(aux + 1, O_WRONLY);
+			if (fd < 0) {
+				perror("open stdout");
+				exit(1);
+			}
+
+			/* open stdin file */
+			aux = strndup(optarg, aux - optarg);
+			fd2 = open(aux, O_RDWR);
+			if (fd2 < 0) {
+				perror("open stdin");
+				exit(1);
+			}
+			free(aux);
+
+			barebox_register_console(fd2, fd);
+			break;
 		default:
 			break;
 		}
@@ -463,6 +490,10 @@ static void print_usage(const char *prgname)
 "                       <file> can be a regular file or a FIFO.\n"
 "  -I, --stdin=<file>   Register a file as a console capable of doing stdin.\n"
 "                       <file> can be a regular file or a FIFO.\n"
+"  -B, --stdinout=<filein>,<fileout>\n"
+"                       Register a bidirectional console capable of doing both\n"
+"                       stdin and stdout. <filein> and <fileout> can be regular\n"
+"                       files or FIFOs.\n"
 "  -x, --xres=<res>     SDL width.\n"
 "  -y, --yres=<res>     SDL height.\n",
 	prgname
-- 
2.13.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sandbox: new --stdinout option to enable a bidirectional console
  2017-06-02 12:01 [PATCH] sandbox: new --stdinout option to enable a bidirectional console Aleksander Morgado
@ 2017-06-06  6:53 ` Sascha Hauer
  2017-06-06  7:00   ` Aleksander Morgado
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2017-06-06  6:53 UTC (permalink / raw)
  To: Aleksander Morgado; +Cc: barebox

On Fri, Jun 02, 2017 at 02:01:05PM +0200, Aleksander Morgado wrote:
> In addition to allowing read-only and write-only consoles with --stdin
> and --stdout, we now allow bidirectional read/write consoles with FIFO
> files. This is e.g. to allow doing RATP over the FIFO based consoles.
> 
> Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
> ---
>  arch/sandbox/os/common.c | 53 ++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 42 insertions(+), 11 deletions(-)

Applied, thanks.

Have you tried RATP over the FIFO consoles? Does it work as expected?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sandbox: new --stdinout option to enable a bidirectional console
  2017-06-06  6:53 ` Sascha Hauer
@ 2017-06-06  7:00   ` Aleksander Morgado
  0 siblings, 0 replies; 3+ messages in thread
From: Aleksander Morgado @ 2017-06-06  7:00 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Tue, Jun 6, 2017 at 8:53 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> In addition to allowing read-only and write-only consoles with --stdin
>> and --stdout, we now allow bidirectional read/write consoles with FIFO
>> files. This is e.g. to allow doing RATP over the FIFO based consoles.
>>
>> Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
>> ---
>>  arch/sandbox/os/common.c | 53 ++++++++++++++++++++++++++++++++++++++----------
>>  1 file changed, 42 insertions(+), 11 deletions(-)
>
> Applied, thanks.
>
> Have you tried RATP over the FIFO consoles? Does it work as expected?

Not completely, because the pyserial backend in bbremote didn't want
FIFOs, but I did try with my own minimal RATP implementation and it
did work ok up to where I tested.

-- 
Aleksander
https://aleksander.es

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-06  7:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 12:01 [PATCH] sandbox: new --stdinout option to enable a bidirectional console Aleksander Morgado
2017-06-06  6:53 ` Sascha Hauer
2017-06-06  7:00   ` Aleksander Morgado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox