1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-11 09:50:12 +00:00

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.
This commit is contained in:
Wes Peters 2003-11-16 07:10:55 +00:00
parent ec52df8eb9
commit 3b7e1bf6b5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122784

View File

@ -288,6 +288,10 @@ setup(char *dev)
*/
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])) &&