aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authorWes Peters <wes@FreeBSD.org>2003-11-16 07:10:55 +0000
committerWes Peters <wes@FreeBSD.org>2003-11-16 07:10:55 +0000
commit3b7e1bf6b58ed4bfe85f0f7d5a77c3be0985c8fd (patch)
treecf6652569cf4d0c53e8443052ed743bed28462ff /sbin/fsck_ffs
parentec52df8eb99de2689788041632404ac919eee661 (diff)
downloadsrc-3b7e1bf6b58ed4bfe85f0f7d5a77c3be0985c8fd.tar.gz
src-3b7e1bf6b58ed4bfe85f0f7d5a77c3be0985c8fd.zip
Catch and report on filesystems that were interrupted during newfs,
sporting the new 'BAD' magic number. Exit with a unique error code (11) so callers who care about this can respond appropriately.
Notes
Notes: svn path=/head/; revision=122784
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r--sbin/fsck_ffs/setup.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index f162c06602eb..f6e541d3e186 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -288,6 +288,10 @@ badsb:
*/
static int sblock_try[] = SBLOCKSEARCH;
+#define BAD_MAGIC_MSG \
+"The previous newfs operation on this volume did not complete.\n" \
+"You must complete newfs before mounting this volume.\n"
+
/*
* Read in the super block and its summary info.
*/
@@ -301,6 +305,10 @@ readsb(int listerr)
super = bflag;
if ((bread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE)))
return (0);
+ if (sblock.fs_magic == FS_BAD2_MAGIC) {
+ fprintf(stderr, BAD_MAGIC_MSG);
+ exit(11);
+ }
if (sblock.fs_magic != FS_UFS1_MAGIC &&
sblock.fs_magic != FS_UFS2_MAGIC) {
fprintf(stderr, "%d is not a file system superblock\n",
@@ -313,6 +321,10 @@ readsb(int listerr)
if ((bread(fsreadfd, (char *)&sblock, super,
(long)SBLOCKSIZE)))
return (0);
+ if (sblock.fs_magic == FS_BAD2_MAGIC) {
+ fprintf(stderr, BAD_MAGIC_MSG);
+ exit(11);
+ }
if ((sblock.fs_magic == FS_UFS1_MAGIC ||
(sblock.fs_magic == FS_UFS2_MAGIC &&
sblock.fs_sblockloc == sblock_try[i])) &&