exfat: recheck device size is big enough to hold fs
I didn't mean to omit this check, I just need to save deviceSize below for get_default_volume_name() so that it will match the mount point name. Checked to make sure the calculation works on a 2GiB, 32GiB, and 128GiB (virtual) exfat volume.
This commit is contained in:
@@ -334,6 +334,15 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
|||||||
fEntriesPerBlock = (fBlockSize / sizeof(struct exfat_entry));
|
fEntriesPerBlock = (fBlockSize / sizeof(struct exfat_entry));
|
||||||
|
|
||||||
// check if the device size is large enough to hold the file system
|
// check if the device size is large enough to hold the file system
|
||||||
|
off_t fileSystemSize;
|
||||||
|
status = opener.GetSize(&fileSystemSize);
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
off_t deviceSize = (off_t)fSuperBlock.NumBlocks() << fSuperBlock.BlockShift();
|
||||||
|
if (fileSystemSize < deviceSize)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
fBlockCache = opener.InitCache(fSuperBlock.NumBlocks(), fBlockSize);
|
fBlockCache = opener.InitCache(fSuperBlock.NumBlocks(), fBlockSize);
|
||||||
if (fBlockCache == NULL)
|
if (fBlockCache == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -363,11 +372,8 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
|||||||
LabelVisitor visitor(this);
|
LabelVisitor visitor(this);
|
||||||
iterator.Iterate(visitor);
|
iterator.Iterate(visitor);
|
||||||
|
|
||||||
if (fName[0] == '\0') {
|
if (fName[0] == '\0')
|
||||||
off_t deviceSize = (off_t)fSuperBlock.NumBlocks()
|
|
||||||
<< fSuperBlock.BlockShift();
|
|
||||||
get_default_volume_name(deviceSize, fName, sizeof(fName));
|
get_default_volume_name(deviceSize, fName, sizeof(fName));
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user