diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2018-03-02 07:20:10 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-03-02 11:46:41 +0300 |
commit | 416656bbaa57a5be75514498491b7e24c58537c1 (patch) | |
tree | b32f81211aeba94746f45459a783455a2934701a /tools/bpf | |
parent | 65d538dde625d93359ca4e33d2311f8598f423a6 (diff) | |
download | linux-416656bbaa57a5be75514498491b7e24c58537c1.tar.xz |
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: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/bpf')
-rw-r--r-- | tools/bpf/bpftool/main.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index cdee4c3d30c3..1da54a9b5ea3 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -195,7 +195,10 @@ static int do_batch(int argc, char **argv) } NEXT_ARG(); - fp = fopen(*argv, "r"); + if (!strcmp(*argv, "-")) + fp = stdin; + else + fp = fopen(*argv, "r"); if (!fp) { p_err("Can't open file (%s): %s", *argv, strerror(errno)); return -1; @@ -284,7 +287,8 @@ static int do_batch(int argc, char **argv) err = 0; } err_close: - fclose(fp); + if (fp != stdin) + fclose(fp); if (json_output) jsonw_end_array(json_wtr); |