From 259fedfc3c31b8d9e7baaea3ffe4112cea37511a Mon Sep 17 00:00:00 2001 From: mckusick Date: Tue, 25 Feb 2003 23:21:08 +0000 Subject: Change the field used to test whether the superblock has been updated from the filesystem size field to the filesystem maximum blocksize field. The problem is that older versions of growfs updated only the new size field and not the old size field. This resulted in the old (smaller) size field being copied up to the new size field which caused the filesystem to appear to fsck to be badly trashed. This also adds a sanity check to ensure that the superblock is not being updated when the filesystem is mounted read-only. Obviously such an update should never happen. Reported by: Nate Lawson Sponsored by: DARPA & NAI Labs. --- sys/ufs/ffs/ffs_vfsops.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 17e9a40..1d9cd21 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -872,7 +872,7 @@ ffs_oldfscompat_read(fs, ump, sblockloc) /* * If not yet done, update UFS1 superblock with new wider fields. */ - if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_size != fs->fs_old_size) { + if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_maxbsize != fs->fs_bsize) { fs->fs_maxbsize = fs->fs_bsize; fs->fs_time = fs->fs_old_time; fs->fs_size = fs->fs_old_size; @@ -1469,6 +1469,10 @@ ffs_sbupdate(mp, waitfor) void *space; int i, size, error, allerror = 0; + if (fs->fs_ronly == 1 && + (mp->um_mountp->mnt_flag & (MNT_RDONLY | MNT_UPDATE)) != + (MNT_RDONLY | MNT_UPDATE)) + panic("ffs_sbupdate: write read-only filesystem"); /* * First write back the summary information. */ -- cgit v1.1