From 49d8776e0336b16eec91f42c284c191e2b13315a Mon Sep 17 00:00:00 2001 From: rodrigc Date: Mon, 17 Oct 2005 03:27:35 +0000 Subject: Use the actual sector size of the media instead of hard-coding it to 2048. This eliminates KASSERTs in GEOM if we accidentally mount an audio CD as a cd9660 filesystem. --- sys/fs/cd9660/cd9660_vfsops.c | 15 ++++++++++++--- sys/isofs/cd9660/cd9660_vfsops.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'sys') diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index cd7e375..6266fb8 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -247,9 +247,18 @@ iso_mountfs(devvp, mp, td) /* This is the "logical sector size". The standard says this * should be 2048 or the physical sector size on the device, - * whichever is greater. For now, we'll just use a constant. + * whichever is greater. */ - iso_bsize = ISO_DEFAULT_BLOCK_SIZE; + if ((ISO_DEFAULT_BLOCK_SIZE % cp->provider->sectorsize) != 0) { + DROP_GIANT(); + g_topology_lock(); + g_vfs_close(cp, td); + g_topology_unlock(); + PICKUP_GIANT(); + return (EINVAL); + } + + iso_bsize = cp->provider->sectorsize; joliet_level = 0; if (1 != vfs_scanopt(mp->mnt_optnew, "ssector", "%d", &ssector)) @@ -257,7 +266,7 @@ iso_mountfs(devvp, mp, td) for (iso_blknum = 16 + ssector; iso_blknum < 100 + ssector; iso_blknum++) { - if ((error = bread(devvp, iso_blknum * btodb(iso_bsize), + if ((error = bread(devvp, iso_blknum * btodb(ISO_DEFAULT_BLOCK_SIZE), iso_bsize, NOCRED, &bp)) != 0) goto out; diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index cd7e375..6266fb8 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -247,9 +247,18 @@ iso_mountfs(devvp, mp, td) /* This is the "logical sector size". The standard says this * should be 2048 or the physical sector size on the device, - * whichever is greater. For now, we'll just use a constant. + * whichever is greater. */ - iso_bsize = ISO_DEFAULT_BLOCK_SIZE; + if ((ISO_DEFAULT_BLOCK_SIZE % cp->provider->sectorsize) != 0) { + DROP_GIANT(); + g_topology_lock(); + g_vfs_close(cp, td); + g_topology_unlock(); + PICKUP_GIANT(); + return (EINVAL); + } + + iso_bsize = cp->provider->sectorsize; joliet_level = 0; if (1 != vfs_scanopt(mp->mnt_optnew, "ssector", "%d", &ssector)) @@ -257,7 +266,7 @@ iso_mountfs(devvp, mp, td) for (iso_blknum = 16 + ssector; iso_blknum < 100 + ssector; iso_blknum++) { - if ((error = bread(devvp, iso_blknum * btodb(iso_bsize), + if ((error = bread(devvp, iso_blknum * btodb(ISO_DEFAULT_BLOCK_SIZE), iso_bsize, NOCRED, &bp)) != 0) goto out; -- cgit v1.1