From owner-freebsd-bugs Wed Mar 20 7:20:10 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 37B0337B419 for ; Wed, 20 Mar 2002 07:20:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2KFK2781176; Wed, 20 Mar 2002 07:20:02 -0800 (PST) (envelope-from gnats) Received: from nerve.riss-telecom.ru (nerve.riss-telecom.ru [80.66.65.3]) by hub.freebsd.org (Postfix) with ESMTP id BDF8837B400 for ; Wed, 20 Mar 2002 07:18:23 -0800 (PST) Received: (from frol@localhost) by nerve.riss-telecom.ru (8.11.6/8.11.6) id g2KFILs49998; Wed, 20 Mar 2002 21:18:21 +0600 (NOVT) (envelope-from frol) Message-Id: <200203201518.g2KFILs49998@nerve.riss-telecom.ru> Date: Wed, 20 Mar 2002 21:18:21 +0600 (NOVT) From: Dmitry Frolov Reply-To: Dmitry Frolov To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/36136: savecore -z option does not work Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36136 >Category: bin >Synopsis: savecore -z option does not work >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Mar 20 07:20:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Dmitry Frolov >Release: FreeBSD 4.5-STABLE i386 >Organization: RISS-Telecom >Environment: System: FreeBSD nerve.riss-telecom.ru 4.5-STABLE FreeBSD 4.5-STABLE #0: Thu Mar 7 22:35:51 NOVT 2002 root@nerve.riss-telecom.ru:/usr/src/sys/compile/NERVE i386 >Description: When saving kernel core dump, savecore attempts to find blocks of zeroes in dump, and calls fseek on output stream when finds such block. If -z option is specified, stream is created with zlib "zopen" function, and fseek on that stream fails. Problem represented by commit at Feb 16 2001 (savecore.c revision 1.37). >How-To-Repeat: # savecore -z /var/crash savecore: reboot after panic: page fault savecore: system went down at Wed Mar 20 19:54:18 2002 savecore: writing compressed core to /var/crash/vmcore.0.gz savecore: /var/crash/vmcore.0.gz: Illegal seek savecore: WARNING: vmcore may be incomplete >Fix: savecore.c: Don't search for zeroes if -z option is specified. --- sbin/savecore/savecore.c.old Wed Mar 20 21:03:18 2002 +++ sbin/savecore/savecore.c Wed Mar 20 21:05:05 2002 @@ -432,14 +432,17 @@ nw = fwrite(buf, 1, nr, fp); } else { for (nw = 0; nw < nr; nw = he) { - /* find a contiguous block of zeroes */ - for (hs = nw; hs < nr; hs += BLOCKSIZE) { - for (he = hs; he < nr && buf[he] == 0; ++he) - /* nothing */ ; - /* is the hole long enough to matter? */ - if (he >= hs + BLOCKSIZE) - break; - } + if (compress) + hs = he = nr; + else + /* find a contiguous block of zeroes */ + for (hs = nw; hs < nr; hs += BLOCKSIZE) { + for (he = hs; he < nr && buf[he] == 0; ++he) + /* nothing */ ; + /* is the hole long enough to matter? */ + if (he >= hs + BLOCKSIZE) + break; + } /* back down to a block boundary */ he &= BLOCKMASK; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message