exfat: style fix param/variable renaming

Pass the partition size into the default name, not the device size,
this makes the variable names match the comment.

There is no functional change here, the variable names got renamed
to make it more clear what's happening. We want show the partition
size, not the device size, and we want to error if the device size is less
than the partition size, not if the partition size is less than the device size.
This commit is contained in:
John Scipione 2014-02-06 16:17:36 -05:00
parent 9f44851e0a
commit 3472fc553e
4 changed files with 16 additions and 14 deletions

View File

@ -48,20 +48,20 @@ get_volume_name(struct exfat_entry* entry, char* name, size_t length)
void
get_default_volume_name(off_t diskSize, char* name, size_t length)
get_default_volume_name(off_t partitionSize, char* name, size_t length)
{
off_t divisor = 1ULL << 40;
char unit = 'T';
if (diskSize < divisor) {
if (partitionSize < divisor) {
divisor = 1UL << 30;
unit = 'G';
if (diskSize < divisor) {
if (partitionSize < divisor) {
divisor = 1UL << 20;
unit = 'M';
}
}
double size = double((10 * diskSize + divisor - 1) / divisor);
double size = double((10 * partitionSize + divisor - 1) / divisor);
// %g in the kernel does not support precision...
snprintf(name, length, "%g%ciB ExFAT Volume", size / 10, unit);

View File

@ -65,11 +65,11 @@ status_t get_volume_name(struct exfat_entry* entry, char* name, size_t length);
/*! Writes a more or less descriptive volume name to \a name.
\param diskSize The disk size in bytes
\param partitionSize The partion size in bytes.
\param name The \a name array to fill out.
\param length The \a length of the name array in bytes.
*/
void get_default_volume_name(off_t diskSize, char* name, size_t length);
void get_default_volume_name(off_t partitionSize, char* name, size_t length);
#endif // UTILITY_H

View File

@ -333,14 +333,14 @@ Volume::Mount(const char* deviceName, uint32 flags)
TRACE("block size %" B_PRIu32 "\n", fBlockSize);
fEntriesPerBlock = (fBlockSize / sizeof(struct exfat_entry));
// check if the device size is large enough to hold the file system
off_t fileSystemSize;
status = opener.GetSize(&fileSystemSize);
// check that the device is large enough to hold the partition
off_t deviceSize;
status = opener.GetSize(&deviceSize);
if (status != B_OK)
return status;
off_t deviceSize = (off_t)fSuperBlock.NumBlocks() << fSuperBlock.BlockShift();
if (fileSystemSize < deviceSize)
off_t partitionSize = (off_t)fSuperBlock.NumBlocks() << fSuperBlock.BlockShift();
if (deviceSize < partitionSize)
return B_BAD_VALUE;
fBlockCache = opener.InitCache(fSuperBlock.NumBlocks(), fBlockSize);
@ -373,7 +373,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
iterator.Iterate(visitor);
if (fName[0] == '\0')
get_default_volume_name(deviceSize, fName, sizeof(fName));
get_default_volume_name(partitionSize, fName, sizeof(fName));
return B_OK;
}

View File

@ -115,8 +115,10 @@ exfat_identify_partition(int fd, partition_data* partition, void** _cookie)
}
if (cookie->name[0] == '\0') {
off_t deviceSize = (off_t)superBlock.NumBlocks() << superBlock.BlockShift();
get_default_volume_name(deviceSize, cookie->name, sizeof(cookie->name));
off_t fileSystemSize = (off_t)superBlock.NumBlocks()
<< superBlock.BlockShift();
get_default_volume_name(fileSystemSize, cookie->name,
sizeof(cookie->name));
}
*_cookie = cookie;