bdes: fwrite error at 8

Dan Nelson dnelson at allantgroup.com
Wed Apr 8 15:13:48 UTC 2009


In the last episode (Apr 08), Lars Eggert said:
> I'm doing encrypted nightly dumps over the network to an NFS file system,
> i.e., dump | bzip2 | bdes > nfs.
> 
> Since about a week ago, I see occasional errors from bdes ("bdes:  
> fwrite error at 8"). Anyone have a hunch what's going on here? I'm  
> wondering if this is something that started when I upgraded to 7.2- 
> PRERELEASE...
[..]
>   DUMP: 34.16% done, finished in 0:48 at Wed Apr  8 04:46:41 2009
> bdes: fwrite error at 8
>   DUMP: 38.56% done, finished in 0:47 at Wed Apr  8 04:51:17 2009

Two bugs:  if fwrite fails, there's no sense in continuing to encrypt, and
it should print the error it got.  Apply this patch and try again:

Index: bdes.c
===================================================================
RCS file: /home/ncvs/src/secure/usr.bin/bdes/bdes.c,v
retrieving revision 1.9
diff -u -r1.9 bdes.c
--- bdes.c	10 Feb 2005 14:47:06 -0000	1.9
+++ bdes.c	8 Apr 2009 14:32:43 -0000
@@ -112,7 +112,7 @@
 #define	READ(buf, n)	fread(buf, sizeof(char), n, stdin)
 #define WRITE(buf,n)						\
 		if (fwrite(buf, sizeof(char), n, stdout) != n)	\
-			warnx("fwrite error at %d", n);
+			err(1, "fwrite error at %d", n);
 
 /*
  * global variables and related macros


After patching, the following test commands should print a single usefull
error instead of a stream of useless ones.

$ trap '' PIPE 
$ bdes -k asd < /boot/kernel/kernel | dd of=/dev/null count=1

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-stable mailing list