[haiku-commits] haiku: hrev46831 - src/add-ons/kernel/file_systems/exfat

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 6 Feb 2014 22:29:13 +0100 (CET)

hrev46831 adds 1 changeset to branch 'master'
old head: 9f44851e0aa5f3161256cb5ef37a574fcb2a699d
new head: 3472fc553eb5a8e2d9ff40c9a33f083b6f303081
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=3472fc5+%5E9f44851

----------------------------------------------------------------------------

3472fc5: 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.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46831
Commit:      3472fc553eb5a8e2d9ff40c9a33f083b6f303081
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3472fc5
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Feb  6 21:17:36 2014 UTC

----------------------------------------------------------------------------

4 files changed, 16 insertions(+), 14 deletions(-)
src/add-ons/kernel/file_systems/exfat/Utility.cpp        |  8 ++++----
src/add-ons/kernel/file_systems/exfat/Utility.h          |  4 ++--
src/add-ons/kernel/file_systems/exfat/Volume.cpp         | 12 ++++++------
.../kernel/file_systems/exfat/kernel_interface.cpp       |  6 ++++--

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/exfat/Utility.cpp 
b/src/add-ons/kernel/file_systems/exfat/Utility.cpp
index 9a301eb..5764fb9 100644
--- a/src/add-ons/kernel/file_systems/exfat/Utility.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/Utility.cpp
@@ -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);
diff --git a/src/add-ons/kernel/file_systems/exfat/Utility.h 
b/src/add-ons/kernel/file_systems/exfat/Utility.h
index 6143f8a..d88f616 100644
--- a/src/add-ons/kernel/file_systems/exfat/Utility.h
+++ b/src/add-ons/kernel/file_systems/exfat/Utility.h
@@ -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
diff --git a/src/add-ons/kernel/file_systems/exfat/Volume.cpp 
b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
index 757f7ce..c302570 100644
--- a/src/add-ons/kernel/file_systems/exfat/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
@@ -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;
 }
diff --git a/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp 
b/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp
index bda5b1c..dcb4243 100644
--- a/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp
@@ -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;


Other related posts:

  • » [haiku-commits] haiku: hrev46831 - src/add-ons/kernel/file_systems/exfat - jscipione