vold: fix 64 bit ioctl error

Changing the num_sectors used in ioctl with BLKGETSIZE because
the kernel expects an unsigned long type and then changes 64 bits
with a 64 bits userspace. This overwrites what's located close to
the parameter location if any.

Change-Id: I78fd61a1084de2741f39b926aa436462518709a0
Signed-off-by: Mateusz Nowak <mateusz.nowak@intel.com>
Signed-off-by: Zhiquan Liu <zhiquan.liu@intel.com>
diff --git a/fs/Ext4.cpp b/fs/Ext4.cpp
index 3ae4159..4cb9d31 100644
--- a/fs/Ext4.cpp
+++ b/fs/Ext4.cpp
@@ -151,17 +151,17 @@
     return rc;
 }
 
-status_t Resize(const std::string& source, unsigned int numSectors) {
+status_t Resize(const std::string& source, unsigned long numSectors) {
     std::vector<std::string> cmd;
     cmd.push_back(kResizefsPath);
     cmd.push_back("-f");
     cmd.push_back(source);
-    cmd.push_back(StringPrintf("%u", numSectors));
+    cmd.push_back(StringPrintf("%lu", numSectors));
 
     return ForkExecvp(cmd);
 }
 
-status_t Format(const std::string& source, unsigned int numSectors,
+status_t Format(const std::string& source, unsigned long numSectors,
         const std::string& target) {
     std::vector<std::string> cmd;
     cmd.push_back(kMkfsPath);
@@ -172,7 +172,7 @@
 
     if (numSectors) {
         cmd.push_back("-l");
-        cmd.push_back(StringPrintf("%u", numSectors * 512));
+        cmd.push_back(StringPrintf("%lu", numSectors * 512));
     }
 
     // Always generate a real UUID
diff --git a/fs/Ext4.h b/fs/Ext4.h
index a5efa74..f78dc95 100644
--- a/fs/Ext4.h
+++ b/fs/Ext4.h
@@ -30,9 +30,9 @@
 status_t Check(const std::string& source, const std::string& target);
 status_t Mount(const std::string& source, const std::string& target, bool ro,
         bool remount, bool executable);
-status_t Format(const std::string& source, unsigned int numSectors,
+status_t Format(const std::string& source, unsigned long numSectors,
         const std::string& target);
-status_t Resize(const std::string& source, unsigned int numSectors);
+status_t Resize(const std::string& source, unsigned long numSectors);
 
 }  // namespace ext4
 }  // namespace vold
diff --git a/fs/Vfat.cpp b/fs/Vfat.cpp
index 7bd05ec..7338c1e 100644
--- a/fs/Vfat.cpp
+++ b/fs/Vfat.cpp
@@ -164,7 +164,7 @@
     return rc;
 }
 
-status_t Format(const std::string& source, unsigned int numSectors) {
+status_t Format(const std::string& source, unsigned long numSectors) {
     std::vector<std::string> cmd;
     cmd.push_back(kMkfsPath);
     cmd.push_back("-F");
@@ -177,7 +177,7 @@
 
     if (numSectors) {
         cmd.push_back("-s");
-        cmd.push_back(StringPrintf("%u", numSectors));
+        cmd.push_back(StringPrintf("%lu", numSectors));
     }
 
     cmd.push_back(source);
diff --git a/fs/Vfat.h b/fs/Vfat.h
index 306c7db..40be5f6 100644
--- a/fs/Vfat.h
+++ b/fs/Vfat.h
@@ -31,7 +31,7 @@
 status_t Mount(const std::string& source, const std::string& target, bool ro,
         bool remount, bool executable, int ownerUid, int ownerGid, int permMask,
         bool createLost);
-status_t Format(const std::string& source, unsigned int numSectors);
+status_t Format(const std::string& source, unsigned long numSectors);
 
 }  // namespace vfat
 }  // namespace vold