Date: Tue, 03 Jun 2003 10:25:30 -0600 From: "Justin T. Gibbs" <gibbs@scsiguy.com> To: Kern Sibbald <kern@sibbald.com>, mjacob@feral.com Cc: freebsd-scsi@freebsd.org Subject: Re: SCSI tape data loss Message-ID: <882210000.1054657530@aslan.btc.adaptec.com> In-Reply-To: <1054652678.13630.209.camel@rufus> References: <3EDB31AB.16420.C8964B7D@localhost> <3EDB59A4.27599.C93270FB@localhost> <20030602110836.H71034@beppo> <577540000.1054579840@aslan.btc.adaptec.com> <20030602131225.F71034@beppo> <1054645616.13630.161.camel@rufus> <20030603072944.U44880@beppo> <1054652678.13630.209.camel@rufus>
next in thread | previous in thread | raw e-mail | index | archive | help
> What is clear from the output is that the write() > is returning a -1 status. errno could possibly be 0, > in which case I set it to ENOSPC, if it is not 0 > then it is ENOSPC judging by the error message that > is printed "Write error on device ...". > > You may want to see more, but here is the basic code > that does the write: > if ((uint32_t)(stat=write(dev->fd, block->buf, (size_t)wlen)) != > wlen) { > /* We should check for errno == ENOSPC, BUT many > * devices simply report EIO when it is full. > * with a little more thought we may be able to check > * capacity and distinguish real errors and EOT > * conditions. In any case, we probably want to > * simulate an End of Medium. > */ > clrerror_dev(dev, -1); Apart from the funny casting, the only obvious bug is that you are expecting errno to be set on every syscall. Errno is only valid if stat == -1 or you explicitly clear it prior to the syscall (or after the last time it was set). You don't seem to be doing that here. See the errno man page for details -- Justin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?882210000.1054657530>