]> Git Repo - linux.git/commitdiff
tools: bpftool: support comments in batch files
authorQuentin Monnet <[email protected]>
Fri, 2 Mar 2018 04:20:08 +0000 (20:20 -0800)
committerDaniel Borkmann <[email protected]>
Fri, 2 Mar 2018 08:46:41 +0000 (09:46 +0100)
Replace '#' by '\0' in commands read from batch files in order to avoid
processing the remaining part of the line, thus allowing users to use
comments in the files.

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

index 185acfa229b592f0bf0b62d972e90c3746959283..79587e6decaec32e431da8c3c6c2454bd671e29e 100644 (file)
@@ -176,6 +176,7 @@ static int do_batch(int argc, char **argv)
        char buf[65536];
        int n_argc;
        FILE *fp;
+       char *cp;
        int err;
        int i;
 
@@ -200,6 +201,10 @@ static int do_batch(int argc, char **argv)
        if (json_output)
                jsonw_start_array(json_wtr);
        while (fgets(buf, sizeof(buf), fp)) {
+               cp = strchr(buf, '#');
+               if (cp)
+                       *cp = '\0';
+
                if (strlen(buf) == sizeof(buf) - 1) {
                        errno = E2BIG;
                        break;
This page took 0.053959 seconds and 4 git commands to generate.