From owner-svn-src-all@FreeBSD.ORG Tue Jul 30 22:57:14 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0608F407; Tue, 30 Jul 2013 22:57:14 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CCD9D2EF4; Tue, 30 Jul 2013 22:57:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6UMvDLg003578; Tue, 30 Jul 2013 22:57:13 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6UMvDho003574; Tue, 30 Jul 2013 22:57:13 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <201307302257.r6UMvDho003574@svn.freebsd.org> From: Scott Long Date: Tue, 30 Jul 2013 22:57:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253822 - head/sbin/fsck_ffs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jul 2013 22:57:14 -0000 Author: scottl Date: Tue Jul 30 22:57:12 2013 New Revision: 253822 URL: http://svnweb.freebsd.org/changeset/base/253822 Log: Add a 'surrender' mode to fsck_ffs. With the -S flag, once hard read errors are encountered, the fsck will stop instead of wasting time chewing through possibly other errors. Obtained from: Netflix MFC after: 3 days Modified: head/sbin/fsck_ffs/fsck.h head/sbin/fsck_ffs/fsutil.c head/sbin/fsck_ffs/main.c Modified: head/sbin/fsck_ffs/fsck.h ============================================================================== --- head/sbin/fsck_ffs/fsck.h Tue Jul 30 21:35:02 2013 (r253821) +++ head/sbin/fsck_ffs/fsck.h Tue Jul 30 22:57:12 2013 (r253822) @@ -324,6 +324,7 @@ char skipclean; /* skip clean file syst int fsmodified; /* 1 => write done to file system */ int fsreadfd; /* file descriptor for reading file system */ int fswritefd; /* file descriptor for writing file system */ +int surrender; /* Give up if reads fail */ ufs2_daddr_t maxfsblock; /* number of blocks in the file system */ char *blockmap; /* ptr to primary blk allocation map */ Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Tue Jul 30 21:35:02 2013 (r253821) +++ head/sbin/fsck_ffs/fsutil.c Tue Jul 30 22:57:12 2013 (r253822) @@ -549,7 +549,18 @@ blread(int fd, char *buf, ufs2_daddr_t b slowio_end(); return (0); } - rwerror("READ BLK", blk); + + /* + * This is handled specially here instead of in rwerror because + * rwerror is used for all sorts of errors, not just true read/write + * errors. It should be refactored and fixed. + */ + if (surrender) { + pfatal("CANNOT READ_BLK: %ld", (long)blk); + errx(EEXIT, "ABORTING DUE TO READ ERRORS"); + } else + rwerror("READ BLK", blk); + if (lseek(fd, offset, 0) < 0) rwerror("SEEK BLK", blk); errs = 0; Modified: head/sbin/fsck_ffs/main.c ============================================================================== --- head/sbin/fsck_ffs/main.c Tue Jul 30 21:35:02 2013 (r253821) +++ head/sbin/fsck_ffs/main.c Tue Jul 30 22:57:12 2013 (r253822) @@ -82,7 +82,7 @@ main(int argc, char *argv[]) sync(); skipclean = 1; inoopt = 0; - while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:npryZ")) != -1) { + while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:nprSyZ")) != -1) { switch (ch) { case 'b': skipclean = 0; @@ -142,6 +142,10 @@ main(int argc, char *argv[]) inoopt++; break; + case 'S': + surrender = 1; + break; + case 'y': yflag++; nflag = 0;