diff options
author | Scott Long <scottl@FreeBSD.org> | 2013-07-30 22:57:12 +0000 |
---|---|---|
committer | Scott Long <scottl@FreeBSD.org> | 2013-07-30 22:57:12 +0000 |
commit | ce779f375668d05f372d18959043225b41106682 (patch) | |
tree | d9647feaaaa44c41d2ce4450a5c48b8d34e7edba /sbin/fsck_ffs | |
parent | bd3d1456a5a4d15f03508365ec8da816dc52a28a (diff) | |
download | src-ce779f375668d05f372d18959043225b41106682.tar.gz src-ce779f375668d05f372d18959043225b41106682.zip |
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
Notes
Notes:
svn path=/head/; revision=253822
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r-- | sbin/fsck_ffs/fsck.h | 1 | ||||
-rw-r--r-- | sbin/fsck_ffs/fsutil.c | 13 | ||||
-rw-r--r-- | sbin/fsck_ffs/main.c | 6 |
3 files changed, 18 insertions, 2 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index 45b242c4bd4a..632d45433da2 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -324,6 +324,7 @@ char skipclean; /* skip clean file systems if preening */ 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 */ diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index f177408ec191..abc987afe20b 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -549,7 +549,18 @@ blread(int fd, char *buf, ufs2_daddr_t blk, long size) 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; diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index d0744472e2ff..1a1c03bc7d85 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -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; |