From d31e380bd9689dd9629b510ffe324707e261b439 Mon Sep 17 00:00:00 2001 From: San Mehat Date: Thu, 18 Feb 2010 08:37:45 -0800 Subject: [PATCH] vold2: Don't allow containers < 1mb, and clean up some logging Signed-off-by: San Mehat --- Devmapper.cpp | 2 -- Loop.cpp | 2 +- VolumeManager.cpp | 6 ++++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Devmapper.cpp b/Devmapper.cpp index 800ee69..02f7d98 100644 --- a/Devmapper.cpp +++ b/Devmapper.cpp @@ -71,7 +71,6 @@ int Devmapper::lookupActive(const char *name, char *ubuffer, size_t len) { unsigned minor = (io->dev & 0xff) | ((io->dev >> 12) & 0xfff00); free(buffer); - LOGD("Newly created devmapper instance minor = %d\n", minor); snprintf(ubuffer, len, "/dev/block/dm-%u", minor); return 0; } @@ -128,7 +127,6 @@ int Devmapper::create(const char *name, const char *loopFile, const char *key, } unsigned minor = (io->dev & 0xff) | ((io->dev >> 12) & 0xfff00); - LOGD("Newly created devmapper instance minor = %d\n", minor); snprintf(ubuffer, len, "/dev/block/dm-%u", minor); // Load the table diff --git a/Loop.cpp b/Loop.cpp index a54d73e..5e11ee2 100644 --- a/Loop.cpp +++ b/Loop.cpp @@ -184,7 +184,7 @@ int Loop::destroyByFile(const char *loopFile) { int Loop::createImageFile(const char *file, unsigned int numSectors) { int fd; - LOGD("Creating ASEC image file %s (%u sectors)", file, numSectors); + LOGD("Creating image file %s (%u sectors)", file, numSectors); if ((fd = creat(file, 0600)) < 0) { LOGE("Error creating imagefile (%s)", strerror(errno)); diff --git a/VolumeManager.cpp b/VolumeManager.cpp index b21a36e..251e11c 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp @@ -171,6 +171,12 @@ int VolumeManager::getAsecMountPath(const char *id, char *buffer, int maxlen) { int VolumeManager::createAsec(const char *id, unsigned int numSectors, const char *fstype, const char *key, int ownerUid) { + if (numSectors < ((1024*1024)/512)) { + LOGE("Invalid container size specified (%d sectors)", numSectors); + errno = EINVAL; + return -1; + } + mkdir("/sdcard/android_secure", 0777); if (lookupVolume(id)) {