Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Apr 2009 09:46:25 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Lars Eggert <lars.eggert@nokia.com>
Cc:        stable@freebsd.org
Subject:   Re: bdes: fwrite error at 8
Message-ID:  <20090408144625.GA90152@dan.emsphone.com>
In-Reply-To: <AE62DFD8-11DA-474B-AB13-1ADC5F33A824@nokia.com>
References:  <AE62DFD8-11DA-474B-AB13-1ADC5F33A824@nokia.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090408144625.GA90152>