diff options
author | mckusick <mckusick@FreeBSD.org> | 2002-11-29 19:20:15 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2002-11-29 19:20:15 +0000 |
commit | 78d15991e4a00cb5c49c4ad95d7307b943ed8234 (patch) | |
tree | 4acdcf02efa2b36dc51f1fde95a0473d49d4a99a /sys/ufs | |
parent | ec73cae726e446f544ac3ffee1b7be5036ef8f63 (diff) | |
download | FreeBSD-src-78d15991e4a00cb5c49c4ad95d7307b943ed8234.zip FreeBSD-src-78d15991e4a00cb5c49c4ad95d7307b943ed8234.tar.gz |
Check to make sure that the fs_sblockloc field was properly updated
before using it to write the superblock. This is to guard against
accidentally trashing the disklabel if the superblock format missed
being upgraded by the new kernel.
Reported by: Sam Leffler <sam@errno.com>
Sponsored by: DARPA & NAI Labs.
Approved by: Murray Stokely <murray@FreeBSD.org>
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 9567bd0..568b992 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1478,6 +1478,16 @@ ffs_sbupdate(mp, waitfor) */ if (allerror) return (allerror); + if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_sblockloc != SBLOCK_UFS1) { + printf("%s: correcting fs_sblockloc from %jd to %d\n", + fs->fs_fsmnt, fs->fs_sblockloc, SBLOCK_UFS1); + fs->fs_sblockloc = SBLOCK_UFS1; + } + if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_sblockloc != SBLOCK_UFS2) { + printf("%s: correcting fs_sblockloc from %jd to %d\n", + fs->fs_fsmnt, fs->fs_sblockloc, SBLOCK_UFS2); + fs->fs_sblockloc = SBLOCK_UFS2; + } bp = getblk(mp->um_devvp, btodb(fs->fs_sblockloc), (int)fs->fs_sbsize, 0, 0); fs->fs_fmod = 0; |