mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 22:26:55 +00:00
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>
This commit is contained in:
parent
65d538dde6
commit
416656bbaa
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue