From owner-freebsd-scsi@FreeBSD.ORG Tue Jun 3 09:24:51 2003 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E10C837B404 for ; Tue, 3 Jun 2003 09:24:51 -0700 (PDT) Received: from magic.adaptec.com (magic-mail.adaptec.com [208.236.45.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4927943F85 for ; Tue, 3 Jun 2003 09:24:51 -0700 (PDT) (envelope-from gibbs@scsiguy.com) Received: from redfish.adaptec.com (redfish.adaptec.com [162.62.50.11]) by magic.adaptec.com (8.11.6/8.11.6) with ESMTP id h53GJmZ24864; Tue, 3 Jun 2003 09:19:48 -0700 Received: from [10.100.253.70] (aslan.btc.adaptec.com [10.100.253.70]) by redfish.adaptec.com (8.8.8p2+Sun/8.8.8) with ESMTP id JAA07505; Tue, 3 Jun 2003 09:24:50 -0700 (PDT) Date: Tue, 03 Jun 2003 10:25:30 -0600 From: "Justin T. Gibbs" To: Kern Sibbald , mjacob@feral.com 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> X-Mailer: Mulberry/3.0.3 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline cc: freebsd-scsi@freebsd.org Subject: Re: SCSI tape data loss X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Justin T. Gibbs" List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jun 2003 16:24:52 -0000 > 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