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/Loop.cpp b/Loop.cpp
index 1ed5bd0..b1e9f6a 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -35,6 +35,7 @@
#include <sysutils/SocketClient.h>
#include "Loop.h"
#include "Asec.h"
+#include "VoldUtil.h"
#include "sehandle.h"
int Loop::dumpState(SocketClient *c) {
@@ -296,7 +297,7 @@
return 0;
}
-int Loop::lookupInfo(const char *loopDevice, struct asec_superblock *sb, unsigned int *nr_sec) {
+int Loop::lookupInfo(const char *loopDevice, struct asec_superblock *sb, unsigned long *nr_sec) {
int fd;
struct asec_superblock buffer;
@@ -306,7 +307,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));
destroyByDevice(loopDevice);
close(fd);