Blame SOURCES/iproute2-3.11.0-tc-ok.patch

5ebd6f
From 3c4b5a852d5bb9070c7fb4428aa50f2e3e1f6e1b Mon Sep 17 00:00:00 2001
5ebd6f
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
5ebd6f
Date: Thu, 19 Sep 2013 11:25:49 +0200
5ebd6f
Subject: [PATCH] Confirm success for each tc -batch command
5ebd6f
MIME-Version: 1.0
5ebd6f
Content-Type: text/plain; charset=UTF-8
5ebd6f
Content-Transfer-Encoding: 8bit
5ebd6f
5ebd6f
If `tc -force -batch' is fed by a controlling program from a pipe,
5ebd6f
it's not possible to recognize when a command has been processes
5ebd6f
successfully.
5ebd6f
5ebd6f
This patch adds an optional `-OK' option to the tc(8) tool, so `tc
5ebd6f
-force -OK -batch' will print "OK\n" to standard output on each
5ebd6f
successfully completed tc command.
5ebd6f
5ebd6f
Signed-off-by: Petr Písař <ppisar@redhat.com>
5ebd6f
---
5ebd6f
 man/man8/tc.8 | 8 +++++++-
5ebd6f
 tc/tc.c       | 8 +++++++-
5ebd6f
 2 files changed, 14 insertions(+), 2 deletions(-)
5ebd6f
5ebd6f
diff --git a/man/man8/tc.8 b/man/man8/tc.8
5ebd6f
index e0acfeb..583eae2 100644
5ebd6f
--- a/man/man8/tc.8
5ebd6f
+++ b/man/man8/tc.8
5ebd6f
@@ -49,7 +49,7 @@ DEV
5ebd6f
 DEV
5ebd6f
 
5ebd6f
 .P
5ebd6f
-.B tc [ -force ] -b\fR[\fIatch\fR] \fB[ filename ]
5ebd6f
+.B tc [ -force ] [ -OK ] -b\fR[\fIatch\fR] \fB[ filename ]
5ebd6f
 
5ebd6f
 .ti 8
5ebd6f
 .IR FORMAT " := {"
5ebd6f
@@ -440,6 +440,12 @@ First failure will cause termination of tc.
5ebd6f
 don't terminate tc on errors in batch mode.
5ebd6f
 If there were any errors during execution of the commands, the application return code will be non zero.
5ebd6f
 
5ebd6f
+.TP
5ebd6f
+.BR "\-OK"
5ebd6f
+in batch mode, print
5ebd6f
+.B OK
5ebd6f
+and a new line on standard output after each successfully interpreted command.
5ebd6f
+
5ebd6f
 .SH HISTORY
5ebd6f
 .B tc
5ebd6f
 was written by Alexey N. Kuznetsov and added in Linux 2.2.
5ebd6f
diff --git a/tc/tc.c b/tc/tc.c
5ebd6f
index 9b50e74..b43bb47 100644
5ebd6f
--- a/tc/tc.c
5ebd6f
+++ b/tc/tc.c
5ebd6f
@@ -39,6 +39,7 @@ int batch_mode = 0;
5ebd6f
 int resolve_hosts = 0;
5ebd6f
 int use_iec = 0;
5ebd6f
 int force = 0;
5ebd6f
+int ok = 0;
5ebd6f
 struct rtnl_handle rth;
5ebd6f
 
5ebd6f
 static void *BODY = NULL;	/* cached handle dlopen(NULL) */
5ebd6f
@@ -183,7 +184,7 @@ noexist:
5ebd6f
 static void usage(void)
5ebd6f
 {
5ebd6f
 	fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
5ebd6f
-			"       tc [-force] -batch filename\n"
5ebd6f
+			"       tc [-force] [-OK] -batch filename\n"
5ebd6f
 	                "where  OBJECT := { qdisc | class | filter | action | monitor }\n"
5ebd6f
 	                "       OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] }\n");
5ebd6f
 }
5ebd6f
@@ -251,6 +252,9 @@ static int batch(const char *name)
5ebd6f
 			ret = 1;
5ebd6f
 			if (!force)
5ebd6f
 				break;
5ebd6f
+		} else if (ok) {
5ebd6f
+			printf("OK\n");
5ebd6f
+			fflush(stdout);
5ebd6f
 		}
5ebd6f
 	}
5ebd6f
 	if (line)
5ebd6f
@@ -288,6 +292,8 @@ int main(int argc, char **argv)
5ebd6f
 			return 0;
5ebd6f
 		} else if (matches(argv[1], "-force") == 0) {
5ebd6f
 			++force;
5ebd6f
+		} else if (matches(argv[1], "-OK") == 0) {
5ebd6f
+			++ok;
5ebd6f
 		} else 	if (matches(argv[1], "-batch") == 0) {
5ebd6f
 			argc--;	argv++;
5ebd6f
 			if (argc <= 1)
5ebd6f
-- 
5ebd6f
1.8.3.1
5ebd6f