From owner-svn-src-head@FreeBSD.ORG Fri Jan 29 10:04:01 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5236E1065693; Fri, 29 Jan 2010 10:04:01 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 40F318FC13; Fri, 29 Jan 2010 10:04:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0TA41Ox025047; Fri, 29 Jan 2010 10:04:01 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0TA41SJ025045; Fri, 29 Jan 2010 10:04:01 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201001291004.o0TA41SJ025045@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 29 Jan 2010 10:04:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203157 - head/sbin/restore X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2010 10:04:01 -0000 Author: jh Date: Fri Jan 29 10:04:00 2010 New Revision: 203157 URL: http://svn.freebsd.org/changeset/base/203157 Log: - Handle short reads when the -P option is used. Short reads must be handled when reading from pipes. - Remove dead code related to the -P option from getvol(). pipein and pipecmdin are never set at the same time. PR: bin/121502 Approved by: trasz (mentor) MFC after: 2 weeks Modified: head/sbin/restore/tape.c Modified: head/sbin/restore/tape.c ============================================================================== --- head/sbin/restore/tape.c Fri Jan 29 10:02:50 2010 (r203156) +++ head/sbin/restore/tape.c Fri Jan 29 10:04:00 2010 (r203157) @@ -333,10 +333,6 @@ getvol(long nextvol) } if (volno == 1) return; - if (pipecmdin) { - closemt(); - goto getpipecmdhdr; - } goto gethdr; } again: @@ -400,7 +396,6 @@ again: if (pipecmdin) { char volno[sizeof("2147483647")]; -getpipecmdhdr: (void)sprintf(volno, "%ld", newvol); if (setenv("RESTORE_VOLUME", volno, 1) == -1) { fprintf(stderr, "Cannot set $RESTORE_VOLUME: %s\n", @@ -1205,17 +1200,17 @@ getmore: * Check for mid-tape short read error. * If found, skip rest of buffer and start with the next. */ - if (!pipein && numtrec < ntrec && i > 0) { + if (!pipein && !pipecmdin && numtrec < ntrec && i > 0) { dprintf(stdout, "mid-media short read error.\n"); numtrec = ntrec; } /* * Handle partial block read. */ - if (pipein && i == 0 && rd > 0) + if ((pipein || pipecmdin) && i == 0 && rd > 0) i = rd; else if (i > 0 && i != ntrec * TP_BSIZE) { - if (pipein) { + if (pipein || pipecmdin) { rd += i; cnt -= i; if (cnt > 0)