summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authorwes <wes@FreeBSD.org>2003-11-16 07:10:55 +0000
committerwes <wes@FreeBSD.org>2003-11-16 07:10:55 +0000
commit6288a669519a7fbdfd0465318c62c56d1b223e17 (patch)
treecf6652569cf4d0c53e8443052ed743bed28462ff /sbin/fsck_ffs
parent546aec2dd673375b176313efbc3150f607e196de (diff)
downloadFreeBSD-src-6288a669519a7fbdfd0465318c62c56d1b223e17.zip
FreeBSD-src-6288a669519a7fbdfd0465318c62c56d1b223e17.tar.gz
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.
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 f162c06..f6e541d 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])) &&
OpenPOWER on IntegriCloud