projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
65d538d
)
tools: bpftool: read from stdin when batch file name is "-"
author
Quentin Monnet
<
[email protected]
>
Fri, 2 Mar 2018 04:20:10 +0000
(20:20 -0800)
committer
Daniel Borkmann
<
[email protected]
>
Fri, 2 Mar 2018 08:46:41 +0000
(09:46 +0100)
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 <
[email protected]
>
Acked-by: Jakub Kicinski <
[email protected]
>
Signed-off-by: Daniel Borkmann <
[email protected]
>
tools/bpf/bpftool/main.c
patch
|
blob
|
history
diff --git
a/tools/bpf/bpftool/main.c
b/tools/bpf/bpftool/main.c
index cdee4c3d30c35c428752821870d3b9330c621991..1da54a9b5ea37d71f8ee6c8785be6859b8a40832 100644
(file)
--- 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);