Date: Tue, 30 Jul 2013 22:57:13 +0000 (UTC) From: Scott Long <scottl@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253822 - head/sbin/fsck_ffs Message-ID: <201307302257.r6UMvDho003574@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307302257.r6UMvDho003574>