diff options
author | jhb <jhb@FreeBSD.org> | 2004-08-19 11:09:13 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2004-08-19 11:09:13 +0000 |
commit | e4ddba3ab3c1d8feb380c67b73a7b5a94962ed80 (patch) | |
tree | 45f017c4cc96d8db9146025f6c51e6c24f770021 /sbin | |
parent | e22c3c721308d1e8f0a24ce8b45f6e9c0e39e109 (diff) | |
download | FreeBSD-src-e4ddba3ab3c1d8feb380c67b73a7b5a94962ed80.zip FreeBSD-src-e4ddba3ab3c1d8feb380c67b73a7b5a94962ed80.tar.gz |
Generalize the UFS bad magic value used to determine when a filesystem
has only been partly initialized via newfs(8) so that it applies to both
UFS1 and UFS2.
Submitted by: "Xin LI" delphij at frontfree dot net
MFC: maybe?
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ffs/setup.c | 4 | ||||
-rw-r--r-- | sbin/newfs/mkfs.c | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 11004a5..e95a6ad 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -306,7 +306,7 @@ readsb(int listerr) super = bflag; if ((bread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE))) return (0); - if (sblock.fs_magic == FS_BAD2_MAGIC) { + if (sblock.fs_magic == FS_BAD_MAGIC) { fprintf(stderr, BAD_MAGIC_MSG); exit(11); } @@ -322,7 +322,7 @@ readsb(int listerr) if ((bread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE))) return (0); - if (sblock.fs_magic == FS_BAD2_MAGIC) { + if (sblock.fs_magic == FS_BAD_MAGIC) { fprintf(stderr, BAD_MAGIC_MSG); exit(11); } diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 17519ae..66074c7 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -236,8 +236,14 @@ mkfs(struct partition *pp, char *fsys) } sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize); sblock.fs_size = fssize = dbtofsb(&sblock, fssize); + + /* + * Before the filesystem is finally initialized, mark it + * as incompletely initialized. + */ + sblock.fs_magic = FS_BAD_MAGIC; + if (Oflag == 1) { - sblock.fs_magic = FS_UFS1_MAGIC; sblock.fs_sblockloc = SBLOCK_UFS1; sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs1_daddr_t); sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode); @@ -257,7 +263,6 @@ mkfs(struct partition *pp, char *fsys) sblock.fs_old_postblformat = 1; sblock.fs_old_nrpos = 1; } else { - sblock.fs_magic = FS_BAD2_MAGIC; sblock.fs_sblockloc = SBLOCK_UFS2; sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs2_daddr_t); sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode); @@ -455,8 +460,8 @@ mkfs(struct partition *pp, char *fsys) } if (Eflag == 2) printf("** Leaving BAD MAGIC on Eflag 2\n"); - else if (Oflag != 1) - sblock.fs_magic = FS_UFS2_MAGIC; + else + sblock.fs_magic = (Oflag != 1) ? FS_UFS2_MAGIC : FS_UFS1_MAGIC; /* * Now build the cylinders group blocks and |