From owner-freebsd-questions@FreeBSD.ORG Sat Jul 10 16:03:32 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE1CA106566B for ; Sat, 10 Jul 2010 16:03:32 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 6EC758FC08 for ; Sat, 10 Jul 2010 16:03:31 +0000 (UTC) Received: by wwe15 with SMTP id 15so636284wwe.31 for ; Sat, 10 Jul 2010 09:03:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.155.20 with SMTP id q20mr10242758wbw.74.1278777802859; Sat, 10 Jul 2010 09:03:22 -0700 (PDT) Received: by 10.216.65.3 with HTTP; Sat, 10 Jul 2010 09:03:22 -0700 (PDT) X-Originating-IP: [93.203.29.70] In-Reply-To: References: <87iq4nsr3a.fsf@kobe.laptop> Date: Sat, 10 Jul 2010 18:03:22 +0200 Message-ID: From: "C. P. Ghost" To: Patrick Donnelly Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: questions@freebsd.org Subject: Re: Writes to Hard Disk Going Beyond Capacity X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jul 2010 16:03:33 -0000 On Sat, Jul 10, 2010 at 12:53 PM, Patrick Donnelly w= rote: > On Sat, Jul 10, 2010 at 4:01 AM, Giorgos Keramidas > wrote: >> On Sat, 10 Jul 2010 03:10:31 -0400, Patrick Donnelly wrote: >>> Hi List, >>> >>> I have a strange problem in a C program I wrote. I open a hard >>> disk character file (/dev/ad1) and attempt to write over the >>> entire disk. I expect the last write that would go beyond the >>> hard disk length (capacity) to return with an error but instead >>> the write succeeds. =A0This happens for hundreds of gigabytes >>> beyond the file (hard drive) length. What could be wrong? (This >>> program works fine on Linux. The last write that would go >>> beyond the end of the hard drive returns with -1.) >>> >>> Thanks for any help, >> >> Can we see the exact source code of the program? =A0What you >> describe might work if the file has holes inside it. > > http://www.batbytes.com/destroy > > Specifically, after filling the hard drive it will begin to rapidly > "write" where the throughput of the writes is about 10 GB/s (obviously > not going to the hard drive). Are you aware of short writes? static int write_buf (int fd, const char *buf, size_t s) { ssize_t r =3D write(fd, buf, s); if (r =3D=3D -1) fprintf(stderr, "write error: %s\n", strerror(errno)); return r >=3D 0; } What if write(2) returns less than s, but not -1? > -- > - Patrick Donnelly -cpghost. --=20 Cordula's Web. http://www.cordula.ws/