Check the sectorsize of the underlying disk before trying to

bread() the UFS superblock.  Should eliminate crashes when trying
to do: mount -t ufs on an audio CD.

PR:		kern/85893
Reported by:	Russell Francis <rfrancis at ev dot net>
MFC after:	1 week
This commit is contained in:
Craig Rodrigues 2006-06-03 21:20:37 +00:00
parent 49b94bfc54
commit 71ac2d7c7c

View File

@ -616,7 +616,14 @@ ffs_mountfs(devvp, mp, td)
* Try reading the superblock in each of its possible locations.
*/
for (i = 0; sblock_try[i] != -1; i++) {
if ((error = bread(devvp, sblock_try[i] / DEV_BSIZE, SBLOCKSIZE,
if ((SBLOCKSIZE % cp->provider->sectorsize) != 0) {
error = EINVAL;
vfs_mount_error(mp,
"Invalid sectorsize %d for superblock size %d",
cp->provider->sectorsize, SBLOCKSIZE);
goto out;
}
if ((error = bread(devvp, btodb(sblock_try[i]), SBLOCKSIZE,
cred, &bp)) != 0)
goto out;
fs = (struct fs *)bp->b_data;