vold: Add encrypted ASEC support via devmapper
- Supports up to 4096 containers
- Keys are now implemented - specifying a key of 'none' means no encryption.
Otherwise, the key must be a string of 32 characters
Signed-off-by: San Mehat <san@google.com>
diff --git a/Loop.cpp b/Loop.cpp
index 1b3879a..b8106ef 100644
--- a/Loop.cpp
+++ b/Loop.cpp
@@ -43,7 +43,9 @@
sprintf(filename, "/dev/block/loop%d", i);
if ((fd = open(filename, O_RDWR)) < 0) {
- LOGE("Unable to open %s (%s)", filename, strerror(errno));
+ if (errno != ENOENT) {
+ LOGE("Unable to open %s (%s)", filename, strerror(errno));
+ }
return -1;
}
@@ -88,7 +90,7 @@
* are created on-demand if needed.
*/
mode_t mode = 0660 | S_IFBLK;
- dev_t dev = (7 << 8) | i;
+ unsigned int dev = (0xff & i) | ((i << 12) & 0xfff00000) | (7 << 8);
if (mknod(filename, mode, dev) < 0) {
if (errno != EEXIST) {
LOGE("Error creating loop device node (%s)", strerror(errno));
@@ -189,7 +191,7 @@
return -1;
}
- if (ftruncate(fd, (sizeMb * (1024 * 1024))) < 0) {
+ if (ftruncate(fd, 1024 + (sizeMb * (1024 * 1024))) < 0) {
LOGE("Error truncating imagefile (%s)", strerror(errno));
close(fd);
return -1;