]>
Commit | Line | Data |
---|---|---|
094be68a MT |
1 | From 3c4b5a852d5bb9070c7fb4428aa50f2e3e1f6e1b Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> | |
3 | Date: Thu, 19 Sep 2013 11:25:49 +0200 | |
4 | Subject: [PATCH] Confirm success for each tc -batch command | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | If `tc -force -batch' is fed by a controlling program from a pipe, | |
10 | it's not possible to recognize when a command has been processes | |
11 | successfully. | |
12 | ||
13 | This patch adds an optional `-OK' option to the tc(8) tool, so `tc | |
14 | -force -OK -batch' will print "OK\n" to standard output on each | |
15 | successfully completed tc command. | |
16 | ||
17 | Signed-off-by: Petr Písař <ppisar@redhat.com> | |
18 | --- | |
19 | man/man8/tc.8 | 8 +++++++- | |
20 | tc/tc.c | 8 +++++++- | |
21 | 2 files changed, 14 insertions(+), 2 deletions(-) | |
22 | ||
23 | diff --git a/man/man8/tc.8 b/man/man8/tc.8 | |
24 | index e0acfeb..583eae2 100644 | |
25 | --- a/man/man8/tc.8 | |
26 | +++ b/man/man8/tc.8 | |
27 | @@ -49,7 +49,7 @@ DEV | |
28 | DEV | |
29 | ||
30 | .P | |
31 | -.B tc [ -force ] -b\fR[\fIatch\fR] \fB[ filename ] | |
32 | +.B tc [ -force ] [ -OK ] -b\fR[\fIatch\fR] \fB[ filename ] | |
33 | ||
34 | .ti 8 | |
35 | .IR FORMAT " := {" | |
36 | @@ -440,6 +440,12 @@ First failure will cause termination of tc. | |
37 | don't terminate tc on errors in batch mode. | |
38 | If there were any errors during execution of the commands, the application return code will be non zero. | |
39 | ||
40 | +.TP | |
41 | +.BR "\-OK" | |
42 | +in batch mode, print | |
43 | +.B OK | |
44 | +and a new line on standard output after each successfully interpreted command. | |
45 | + | |
46 | .SH HISTORY | |
47 | .B tc | |
48 | was written by Alexey N. Kuznetsov and added in Linux 2.2. | |
49 | diff --git a/tc/tc.c b/tc/tc.c | |
50 | index 9b50e74..b43bb47 100644 | |
51 | --- a/tc/tc.c | |
52 | +++ b/tc/tc.c | |
53 | @@ -39,6 +39,7 @@ int batch_mode = 0; | |
54 | int resolve_hosts = 0; | |
55 | int use_iec = 0; | |
56 | int force = 0; | |
57 | +int ok = 0; | |
58 | struct rtnl_handle rth; | |
59 | ||
60 | static void *BODY = NULL; /* cached handle dlopen(NULL) */ | |
61 | @@ -183,7 +184,7 @@ noexist: | |
62 | static void usage(void) | |
63 | { | |
64 | fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n" | |
65 | - " tc [-force] -batch filename\n" | |
66 | + " tc [-force] [-OK] -batch filename\n" | |
67 | "where OBJECT := { qdisc | class | filter | action | monitor }\n" | |
68 | " OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] }\n"); | |
69 | } | |
70 | @@ -251,6 +252,9 @@ static int batch(const char *name) | |
71 | ret = 1; | |
72 | if (!force) | |
73 | break; | |
74 | + } else if (ok) { | |
75 | + printf("OK\n"); | |
76 | + fflush(stdout); | |
77 | } | |
78 | } | |
79 | if (line) | |
80 | @@ -288,6 +292,8 @@ int main(int argc, char **argv) | |
81 | return 0; | |
82 | } else if (matches(argv[1], "-force") == 0) { | |
83 | ++force; | |
84 | + } else if (matches(argv[1], "-OK") == 0) { | |
85 | + ++ok; | |
86 | } else if (matches(argv[1], "-batch") == 0) { | |
87 | argc--; argv++; | |
88 | if (argc <= 1) | |
89 | -- | |
90 | 1.8.3.1 | |
91 |