fat: If the filesystem extends past the end of the partition, mount read-only.
instead of failing to mount at all. This matches behavior of Linux and the BSDs. Fixes #14539.
This commit is contained in:
@@ -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
|
// 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;
|
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->volume = _vol;
|
||||||
vol->id = _vol->id;
|
vol->id = _vol->id;
|
||||||
strncpy(vol->device, path, sizeof(vol->device));
|
strncpy(vol->device, path, sizeof(vol->device));
|
||||||
|
|||||||
Reference in New Issue
Block a user