Fixed type mismatch for ioctl(BLKGETSIZE)
ioctl(BLKGETSIZE) expects unsigned long
(8 bytes on 64 bit environment).
This is fixing fails in android.os.storage.StorageManagerIntegrationTest
(in FrameworkCoreTests).
To verify, install FrameworksCoreTests.apk and do:
adb shell am instrument -r -w -e class android.os.storage.\
StorageManagerIntegrationTest#testMountSingleEncryptedObb \
com.android.frameworks.coretests/android.test.InstrumentationTestRunner
Change-Id: Ib6d5c7490c02521c93f107c35ad0aac49f6a3f1a
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 4c5bb58..d6907f2 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -52,6 +52,7 @@
#include "Devmapper.h"
#include "Process.h"
#include "Asec.h"
+#include "VoldUtil.h"
#include "cryptfs.h"
#define MASS_STORAGE_FILE_PATH "/sys/class/android_usb/android0/f_mass_storage/lun/file"
@@ -759,7 +760,7 @@
return -1;
}
- unsigned int nr_sec = 0;
+ unsigned long nr_sec = 0;
struct asec_superblock sb;
if (Loop::lookupInfo(loopDevice, &sb, &nr_sec)) {
@@ -822,7 +823,7 @@
return -1;
}
- unsigned int nr_sec = 0;
+ unsigned long nr_sec = 0;
struct asec_superblock sb;
if (Loop::lookupInfo(loopDevice, &sb, &nr_sec)) {
@@ -1297,7 +1298,7 @@
char dmDevice[255];
bool cleanupDm = false;
- unsigned int nr_sec = 0;
+ unsigned long nr_sec = 0;
struct asec_superblock sb;
if (Loop::lookupInfo(loopDevice, &sb, &nr_sec)) {
@@ -1403,7 +1404,7 @@
char dmDevice[255];
bool cleanupDm = false;
int fd;
- unsigned int nr_sec = 0;
+ unsigned long nr_sec = 0;
if ((fd = open(loopDevice, O_RDWR)) < 0) {
SLOGE("Failed to open loopdevice (%s)", strerror(errno));
@@ -1411,7 +1412,8 @@
return -1;
}
- if (ioctl(fd, BLKGETSIZE, &nr_sec)) {
+ get_blkdev_size(fd, &nr_sec);
+ if (nr_sec == 0) {
SLOGE("Failed to get loop size (%s)", strerror(errno));
Loop::destroyByDevice(loopDevice);
close(fd);
@@ -1420,7 +1422,7 @@
close(fd);
- if (setupDevMapperDevice(dmDevice, sizeof(loopDevice), loopDevice, img,key, idHash , nr_sec, &cleanupDm, mDebug)) {
+ if (setupDevMapperDevice(dmDevice, sizeof(loopDevice), loopDevice, img,key, idHash, nr_sec, &cleanupDm, mDebug)) {
Loop::destroyByDevice(loopDevice);
return -1;
}