summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-06-14 09:29:53 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-14 09:29:53 +0200
commitaec669a81228828abeb634fb43ff00cca1ced7aa (patch)
treef2b2d83310e37907aae563d9f1b20c0e15f413dc
parent253412624e0fa60a309c6691b0cd99b6c341df87 (diff)
parent4f156cbca4ea9dbff65721f1c26b4b07fdacbe5e (diff)
downloadbarebox-aec669a81228828abeb634fb43ff00cca1ced7aa.tar.gz
barebox-aec669a81228828abeb634fb43ff00cca1ced7aa.tar.xz
Merge branch 'for-next/misd'
-rw-r--r--arch/sandbox/os/common.c53
1 files changed, 42 insertions, 11 deletions
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 8cf0873130..665e8194ef 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