From 6288a669519a7fbdfd0465318c62c56d1b223e17 Mon Sep 17 00:00:00 2001 From: wes Date: Sun, 16 Nov 2003 07:10:55 +0000 Subject: 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. --- sbin/fsck_ffs/setup.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sbin/fsck_ffs') 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])) && -- cgit v1.1