From 20903784a47286b45b40037c6584e9deb4c1a95e Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 3 Jun 2017 02:26:12 +0800 Subject: [PATCH] Support file based encryption and several small updates --- jni/magiskboot/cpio.c | 5 ++--- jni/magiskboot/repack.c | 3 --- jni/magiskboot/utils.c | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/jni/magiskboot/cpio.c b/jni/magiskboot/cpio.c index 96057cadc..2d0edb2f0 100644 --- a/jni/magiskboot/cpio.c +++ b/jni/magiskboot/cpio.c @@ -243,12 +243,11 @@ static void cpio_dmverity(struct vector *v) { static void cpio_forceencrypt(struct vector *v) { cpio_file *f; size_t read, write; - #define ENCRYPT_LIST_SIZE 2 - const char *ENCRYPT_LIST[ENCRYPT_LIST_SIZE] = { "forceencrypt", "forcefdeorfbe" }; + const char *ENCRYPT_LIST[] = { "forceencrypt", "forcefdeorfbe", "fileencryptioninline", NULL }; vec_for_each(v, f) { if (strstr(f->filename, "fstab") != NULL && S_ISREG(f->mode)) { for (read = 0, write = 0; read < f->filesize; ++read, ++write) { - for (int i = 0 ; i < ENCRYPT_LIST_SIZE; ++i) { + for (int i = 0 ; ENCRYPT_LIST[i]; ++i) { if (strncmp(f->data + read, ENCRYPT_LIST[i], strlen(ENCRYPT_LIST[i])) == 0) { memcpy(f->data + write, "encryptable", 11); printf("Replace [%s] with [%s] in [%s]\n", ENCRYPT_LIST[i], "encryptable", f->filename); diff --git a/jni/magiskboot/repack.c b/jni/magiskboot/repack.c index c7afae877..26a9a22b5 100644 --- a/jni/magiskboot/repack.c +++ b/jni/magiskboot/repack.c @@ -132,8 +132,5 @@ void repack(const char* orig_image, const char* out_image) { print_info(); munmap(orig, size); - if (lseek(fd, 0, SEEK_END) > size) { - LOGE(2, "Boot partition too small!\n"); - } close(fd); } diff --git a/jni/magiskboot/utils.c b/jni/magiskboot/utils.c index 6cdc87f48..a47d6d09b 100644 --- a/jni/magiskboot/utils.c +++ b/jni/magiskboot/utils.c @@ -139,7 +139,6 @@ void cleanup() { unlink(RAMDISK_FILE ".unsupport"); unlink(SECOND_FILE); unlink(DTB_FILE); - unlink(NEW_BOOT); for (int i = 0; SUP_EXT_LIST[i]; ++i) { sprintf(name, "%s.%s", RAMDISK_FILE, SUP_EXT_LIST[i]); unlink(name);