MFC 1.316 (substitute vfs_mount_error for printf):

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>
This commit is contained in:
rodrigc 2006-06-17 14:58:59 +00:00
parent 5e5961f729
commit b1311a5d14

View File

@ -594,7 +594,13 @@ 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;
printf("Invalid sectorsize %d for superblock size %d\n",
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;