mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-19 07:34:07 +00:00
Well, /dev/zero cannot be used like that...
This commit is contained in:
@@ -21,9 +21,6 @@ static void restore_buf(int fd, const void *buf, size_t size) {
|
||||
}
|
||||
|
||||
void repack(const char* orig_image, const char* out_image) {
|
||||
zero = open("/dev/zero", O_RDONLY);
|
||||
if (zero < 0) error(1, "Cannot open /dev/zero");
|
||||
|
||||
size_t size;
|
||||
unsigned char *orig;
|
||||
char name[PATH_MAX];
|
||||
@@ -51,12 +48,12 @@ void repack(const char* orig_image, const char* out_image) {
|
||||
hdr.dt_size = 0;
|
||||
|
||||
// Skip a page for header
|
||||
sendfile(fd, zero, NULL, hdr.page_size);
|
||||
write_zero(fd, hdr.page_size);
|
||||
|
||||
// Restore kernel
|
||||
if (mtk_kernel) {
|
||||
mtk_kernel_off = lseek(fd, 0, SEEK_CUR);
|
||||
sendfile(fd, zero, NULL, 512);
|
||||
write_zero(fd, 512);
|
||||
memcpy(&mtk_kernel_hdr, kernel, sizeof(mtk_kernel_hdr));
|
||||
}
|
||||
hdr.kernel_size = restore(KERNEL_FILE, fd);
|
||||
@@ -65,7 +62,7 @@ void repack(const char* orig_image, const char* out_image) {
|
||||
// Restore ramdisk
|
||||
if (mtk_ramdisk) {
|
||||
mtk_ramdisk_off = lseek(fd, 0, SEEK_CUR);
|
||||
sendfile(fd, zero, NULL, 512);
|
||||
write_zero(fd, 512);
|
||||
memcpy(&mtk_ramdisk_hdr, ramdisk, sizeof(mtk_ramdisk_hdr));
|
||||
}
|
||||
if (access(RAMDISK_FILE, R_OK) == 0) {
|
||||
|
Reference in New Issue
Block a user