Date: Sat, 10 Jul 2010 18:03:22 +0200 From: "C. P. Ghost" <cpghost@cordula.ws> To: Patrick Donnelly <batrick@batbytes.com> Cc: questions@freebsd.org Subject: Re: Writes to Hard Disk Going Beyond Capacity Message-ID: <AANLkTilc1NdTqA91CTxINnAdtyE2ToViPdytTTnwkIm0@mail.gmail.com> In-Reply-To: <AANLkTilAuZ3MkzDP5_f7ETk0wcvWR7OLYB8G4c_JVpj9@mail.gmail.com> References: <AANLkTin9-MymICgQoSjFlKbLXN2Efm5_3r6X1lufqiCo@mail.gmail.com> <87iq4nsr3a.fsf@kobe.laptop> <AANLkTilAuZ3MkzDP5_f7ETk0wcvWR7OLYB8G4c_JVpj9@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jul 10, 2010 at 12:53 PM, Patrick Donnelly <batrick@batbytes.com> w= rote: > On Sat, Jul 10, 2010 at 4:01 AM, Giorgos Keramidas > <keramida@ceid.upatras.gr> wrote: >> On Sat, 10 Jul 2010 03:10:31 -0400, Patrick Donnelly <batrick@batbytes.c= om> 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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTilc1NdTqA91CTxINnAdtyE2ToViPdytTTnwkIm0>