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