diff --git a/src/add-ons/kernel/file_systems/fat/dosfs.c b/src/add-ons/kernel/file_systems/fat/dosfs.c index 3fb5f849d5..bfa61481ab 100644 --- a/src/add-ons/kernel/file_systems/fat/dosfs.c +++ b/src/add-ons/kernel/file_systems/fat/dosfs.c @@ -398,6 +398,14 @@ volume_init(int fd, uint8* buf, } } + /* check that the partition is large enough to contain the file system */ + if (geo != NULL + && vol->total_sectors > + geo->sectors_per_track * geo->cylinder_count + * geo->head_count) { + dprintf("dosfs: volume extends past end of partition, mounting read-only\n"); + vol->flags |= B_FS_IS_READONLY; + } // now we are convinced of the drive's validity @@ -595,14 +603,6 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags, goto error1; } - /* check that the partition is large enough to contain the file system */ - if (vol->total_sectors > geo.sectors_per_track * geo.cylinder_count - * geo.head_count) { - dprintf("dosfs: volume extends past end of partition\n"); - err = B_PARTITION_TOO_SMALL; - goto error2; - } - vol->volume = _vol; vol->id = _vol->id; strncpy(vol->device, path, sizeof(vol->device));