diff --git a/native/jni/Android.mk b/native/jni/Android.mk index 3e0fbed41..d67b4f281 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -90,7 +90,8 @@ LOCAL_SRC_FILES := \ magiskboot/format.cpp \ magiskboot/dtb.cpp \ magiskboot/ramdisk.cpp \ - magiskboot/pattern.cpp + magiskboot/pattern.cpp \ + utils/cpio.cpp LOCAL_LDLIBS := -lz LOCAL_LDFLAGS := -static diff --git a/native/jni/init/init.cpp b/native/jni/init/init.cpp index 663a6e447..1d7a8dbeb 100644 --- a/native/jni/init/init.cpp +++ b/native/jni/init/init.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include "binaries.h" @@ -102,25 +101,6 @@ static bool unxz(int fd, const uint8_t *buf, size_t size) { return true; } -static void decompress_ramdisk() { - constexpr char tmp[] = "tmp.cpio"; - constexpr char ramdisk_xz[] = "ramdisk.cpio.xz"; - if (access(ramdisk_xz, F_OK)) - return; - LOGD("Decompressing ramdisk from %s\n", ramdisk_xz); - uint8_t *buf; - size_t sz; - mmap_ro(ramdisk_xz, buf, sz); - int fd = xopen(tmp, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); - unxz(fd, buf, sz); - munmap(buf, sz); - close(fd); - cpio_mmap cpio(tmp); - cpio.extract(); - unlink(tmp); - unlink(ramdisk_xz); -} - int dump_magisk(const char *path, mode_t mode) { int fd = xopen(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode); if (fd < 0) @@ -236,7 +216,6 @@ int main(int argc, char *argv[]) { else init = new SARInit(argv, &cmd); } else { - decompress_ramdisk(); if (cmd.force_normal_boot) init = new FirstStageInit(argv, &cmd); else if (access("/sbin/recovery", F_OK) == 0 || access("/system/bin/recovery", F_OK) == 0) diff --git a/native/jni/utils/Android.mk b/native/jni/utils/Android.mk index 80a2a5609..8f6f0b2c8 100644 --- a/native/jni/utils/Android.mk +++ b/native/jni/utils/Android.mk @@ -11,7 +11,6 @@ LOCAL_SRC_FILES := \ misc.cpp \ selinux.cpp \ logging.cpp \ - cpio.cpp \ xwrap.cpp \ stream.cpp diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 504f97335..0fb68492e 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -447,13 +447,7 @@ install_magisk() { # Restore the original boot partition path [ "$BOOTNAND" ] && BOOTIMAGE=$BOOTNAND - - if ! flash_image new-boot.img "$BOOTIMAGE"; then - ui_print "- Compressing ramdisk to fit in partition" - ./magiskboot cpio ramdisk.cpio compress - ./magiskboot repack "$BOOTIMAGE" - flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size" - fi + flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size" ./magiskboot cleanup rm -f new-boot.img