Subject: diff patch for more accurate throughput estimate
To: None <tech-userlevel@netbsd.org>
From: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
List: tech-userlevel
Date: 10/17/2000 16:46:03
--QTprm0S8XgL7H0Dt
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello,

some might have noticed that dd reports too optimistic throughput numbers
when exiting...

I looked close, and found that this is because the statistics are done before
the (implicit) close of the output file descriptor. Of course, any buffered
(inside the kernel) data would be counted, without having been written.

A patch to change this is below. Do we want something like this?

Regards,
	-is

--QTprm0S8XgL7H0Dt
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.close"

? diff.close
Index: dd.c
===================================================================
RCS file: /cvsroot/basesrc/bin/dd/dd.c,v
retrieving revision 1.17
diff -u -r1.17 dd.c
--- dd.c	2000/08/25 03:40:32	1.17
+++ dd.c	2000/10/17 14:38:05
@@ -101,7 +101,7 @@
 	(void)sigemptyset(&infoset);
 	(void)sigaddset(&infoset, SIGINFO);
 
-	(void)atexit(summary);
+	(void)atexit(summaryy);
 
 	while (files_cnt--)
 		dd_in();
Index: extern.h
===================================================================
RCS file: /cvsroot/basesrc/bin/dd/extern.h,v
retrieving revision 1.10
diff -u -r1.10 extern.h
--- extern.h	2000/08/02 16:46:16	1.10
+++ extern.h	2000/10/17 14:38:05
@@ -51,6 +51,7 @@
 void pos_out __P((void));
 void summary __P((void));
 void summaryx __P((int));
+void summaryy __P((void));
 void terminate __P((int));
 void unblock __P((void));
 void unblock_close __P((void));
Index: misc.c
===================================================================
RCS file: /cvsroot/basesrc/bin/dd/misc.c,v
retrieving revision 1.9
diff -u -r1.9 misc.c
--- misc.c	1999/07/29 19:03:31	1.9
+++ misc.c	2000/10/17 14:38:05
@@ -100,6 +100,13 @@
 	summary();
 }
 
+void
+summaryy(void)
+{
+	(void)close(out.fd);
+	summary();
+}
+
 /* ARGSUSED */
 void
 terminate(notused)

--QTprm0S8XgL7H0Dt--