Pre-dirpref versions of fsck may zero out the new superblock fields

fs_contigdirs, fs_avgfilesize and fs_avgfpdir. This could cause
panics if these fields were zeroed while a filesystem was mounted
read-only, and then remounted read-write.

Add code to ffs_reload() which copies the fs_contigdirs pointer
from the previous superblock, and reinitialises fs_avgf* if necessary.

Reviewed by:	mckusick
This commit is contained in:
Ian Dowse 2001-04-24 00:37:16 +00:00
parent 38c7e4a631
commit 5d69bac493
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75892

View File

@ -423,12 +423,18 @@ ffs_reload(mp, cred, p)
*/
newfs->fs_csp = fs->fs_csp;
newfs->fs_maxcluster = fs->fs_maxcluster;
newfs->fs_contigdirs = fs->fs_contigdirs;
bcopy(newfs, fs, (u_int)fs->fs_sbsize);
if (fs->fs_sbsize < SBSIZE)
bp->b_flags |= B_INVAL | B_NOCACHE;
brelse(bp);
mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen;
ffs_oldfscompat(fs);
/* An old fsck may have zeroed these fields, so recheck them. */
if (fs->fs_avgfilesize <= 0) /* XXX */
fs->fs_avgfilesize = AVFILESIZ; /* XXX */
if (fs->fs_avgfpdir <= 0) /* XXX */
fs->fs_avgfpdir = AFPDIR; /* XXX */
/*
* Step 3: re-read summary information from disk.