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/Loop.cpp b/Loop.cpp
index 059b963..a5863b3 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -253,7 +253,7 @@
return -1;
}
-int Loop::createImageFile(const char *file, unsigned int numSectors) {
+int Loop::createImageFile(const char *file, unsigned long numSectors) {
int fd;
if ((fd = creat(file, 0600)) < 0) {
@@ -270,7 +270,7 @@
return 0;
}
-int Loop::resizeImageFile(const char *file, unsigned int numSectors) {
+int Loop::resizeImageFile(const char *file, unsigned long numSectors) {
int fd;
if ((fd = open(file, O_RDWR | O_CLOEXEC)) < 0) {
@@ -278,7 +278,7 @@
return -1;
}
- SLOGD("Attempting to increase size of %s to %d sectors.", file, numSectors);
+ SLOGD("Attempting to increase size of %s to %lu sectors.", file, numSectors);
if (fallocate(fd, 0, 0, numSectors * 512)) {
if (errno == ENOSYS || errno == ENOTSUP) {