linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] candump: add option to ignore ENOBUFS
@ 2012-10-26  9:42 yegorslists
  2012-10-26  9:46 ` Marc Kleine-Budde
  0 siblings, 1 reply; 7+ messages in thread
From: yegorslists @ 2012-10-26  9:42 UTC (permalink / raw)
  To: linux-can; +Cc: mkl, Yegor Yefremov

From: Yegor Yefremov <yegorslists@googlemail.com>

-f option replicated -i option from cangen and allows to
ignore ENOBUFS error in bridge mode

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 candump.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/candump.c b/candump.c
index ac51192..3a6be62 100644
--- a/candump.c
+++ b/candump.c
@@ -53,6 +53,7 @@
 #include <ctype.h>
 #include <libgen.h>
 #include <time.h>
+#include <errno.h>
 
 #include <sys/time.h>
 #include <sys/types.h>
@@ -122,6 +123,7 @@ void print_usage(char *prg)
 	fprintf(stderr, "         -r <size>   (set socket receive buffer to <size>)\n");
 	fprintf(stderr, "         -d          (monitor dropped CAN frames)\n");
 	fprintf(stderr, "         -e          (dump CAN error frames in human-readable format)\n");
+	fprintf(stderr, "         -f          (ignore -ENOBUFS return values on write() syscalls)\n");
 	fprintf(stderr, "\n");
 	fprintf(stderr, "Up to %d CAN interfaces with optional filter sets can be specified\n", MAXSOCK);
 	fprintf(stderr, "on the commandline in the form: <ifname>[,filter]*\n");
@@ -211,6 +213,7 @@ int main(int argc, char **argv)
 	unsigned char view = 0;
 	unsigned char log = 0;
 	unsigned char logfrmt = 0;
+	unsigned char ignore_enobufs = 0;
 	int count = 0;
 	int rcvbuf_size = 0;
 	int opt, ret;
@@ -236,7 +239,7 @@ int main(int argc, char **argv)
 	last_tv.tv_sec  = 0;
 	last_tv.tv_usec = 0;
 
-	while ((opt = getopt(argc, argv, "t:ciaSs:b:B:u:ldLn:r:he?")) != -1) {
+	while ((opt = getopt(argc, argv, "ft:ciaSs:b:B:u:ldLn:r:he?")) != -1) {
 		switch (opt) {
 		case 't':
 			timestamp = optarg[0];
@@ -347,6 +350,10 @@ int main(int argc, char **argv)
 			}
 			break;
 
+		case 'f':
+			ignore_enobufs = 1;
+			break;
+
 		default:
 			print_usage(basename(argv[0]));
 			exit(1);
@@ -625,8 +632,14 @@ int main(int argc, char **argv)
 
 					nbytes = write(bridge, &frame, sizeof(struct can_frame));
 					if (nbytes < 0) {
-						perror("bridge write");
-						return 1;
+						if (errno != ENOBUFS) {
+							perror("bridge write");
+							return 1;
+						}
+						if (!ignore_enobufs) {
+							perror("bridge write");
+							return 1;
+						}
 					} else if ((size_t)nbytes < sizeof(struct can_frame)) {
 						fprintf(stderr,"bridge write: incomplete CAN frame\n");
 						return 1;
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-01-13 18:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-26  9:42 [PATCH] candump: add option to ignore ENOBUFS yegorslists
2012-10-26  9:46 ` Marc Kleine-Budde
2012-10-28 20:02   ` Oliver Hartkopp
2012-10-29  8:00     ` Yegor Yefremov
2014-01-10 22:02     ` Oliver Hartkopp
2014-01-13 10:00       ` Yegor Yefremov
2014-01-13 18:15         ` Oliver Hartkopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).