Commit 416656bb authored by Quentin Monnet's avatar Quentin Monnet Committed by Daniel Borkmann

tools: bpftool: read from stdin when batch file name is "-"

Make bpftool read its command list from standard input when the name if
the input file is a single dash.
Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 65d538dd
...@@ -195,6 +195,9 @@ static int do_batch(int argc, char **argv) ...@@ -195,6 +195,9 @@ static int do_batch(int argc, char **argv)
} }
NEXT_ARG(); NEXT_ARG();
if (!strcmp(*argv, "-"))
fp = stdin;
else
fp = fopen(*argv, "r"); fp = fopen(*argv, "r");
if (!fp) { if (!fp) {
p_err("Can't open file (%s): %s", *argv, strerror(errno)); p_err("Can't open file (%s): %s", *argv, strerror(errno));
...@@ -284,6 +287,7 @@ static int do_batch(int argc, char **argv) ...@@ -284,6 +287,7 @@ static int do_batch(int argc, char **argv)
err = 0; err = 0;
} }
err_close: err_close:
if (fp != stdin)
fclose(fp); fclose(fp);
if (json_output) if (json_output)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment