summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2013-12-12 00:40:28 +0100
committerJP Abgrall <jpa@google.com>2013-12-13 00:27:42 +0100
commitf39989a36d4724a4852e28b9dca3d372d3f7873d (patch)
tree518ea4e803536d9bff1dc56cf33a58e1a372c838
parentam d327c63a: am c87bab10: add the functions for multi-stage packages to updater (diff)
downloadandroid_bootable_recovery-f39989a36d4724a4852e28b9dca3d372d3f7873d.tar
android_bootable_recovery-f39989a36d4724a4852e28b9dca3d372d3f7873d.tar.gz
android_bootable_recovery-f39989a36d4724a4852e28b9dca3d372d3f7873d.tar.bz2
android_bootable_recovery-f39989a36d4724a4852e28b9dca3d372d3f7873d.tar.lz
android_bootable_recovery-f39989a36d4724a4852e28b9dca3d372d3f7873d.tar.xz
android_bootable_recovery-f39989a36d4724a4852e28b9dca3d372d3f7873d.tar.zst
android_bootable_recovery-f39989a36d4724a4852e28b9dca3d372d3f7873d.zip
-rw-r--r--Android.mk2
-rw-r--r--roots.cpp27
2 files changed, 27 insertions, 2 deletions
diff --git a/Android.mk b/Android.mk
index 1308066df..c544db964 100644
--- a/Android.mk
+++ b/Android.mk
@@ -57,7 +57,7 @@ LOCAL_STATIC_LIBRARIES := \
ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
LOCAL_CFLAGS += -DUSE_EXT4
- LOCAL_C_INCLUDES += system/extras/ext4_utils
+ LOCAL_C_INCLUDES += system/extras/ext4_utils system/vold
LOCAL_STATIC_LIBRARIES += libext4_utils_static libz
endif
diff --git a/roots.cpp b/roots.cpp
index 113dba1bd..47cea0bec 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -21,6 +21,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
+#include <fcntl.h>
#include <fs_mgr.h>
#include "mtdutils/mtdutils.h"
@@ -28,6 +29,10 @@
#include "roots.h"
#include "common.h"
#include "make_ext4fs.h"
+extern "C" {
+#include "wipe.h"
+#include "cryptfs.h"
+}
static struct fstab *fstab = NULL;
@@ -191,11 +196,31 @@ int format_volume(const char* volume) {
}
if (strcmp(v->fs_type, "ext4") == 0) {
- int result = make_ext4fs(v->blk_device, v->length, volume, sehandle);
+ ssize_t length = 0;
+ if (v->length != 0) {
+ length = v->length;
+ } else if (v->key_loc != NULL && strcmp(v->key_loc, "footer") == 0) {
+ length = -CRYPT_FOOTER_OFFSET;
+ }
+ int result = make_ext4fs(v->blk_device, length, volume, sehandle);
if (result != 0) {
LOGE("format_volume: make_extf4fs failed on %s\n", v->blk_device);
return -1;
}
+
+ // if there's a key_loc that looks like a path, it should be a
+ // block device for storing encryption metadata. wipe it too.
+ if (v->key_loc != NULL && v->key_loc[0] == '/') {
+ LOGI("wiping %s\n", v->key_loc);
+ int fd = open(v->key_loc, O_WRONLY | O_CREAT, 0644);
+ if (fd < 0) {
+ LOGE("format_volume: failed to open %s\n", v->key_loc);
+ return -1;
+ }
+ wipe_block_device(fd, get_file_size(fd));
+ close(fd);
+ }
+
return 0;
}