mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-08 20:14:30 +00:00
AVB blobs expect to be 4096-byte aligned
This commit is contained in:
parent
1c8ebfacb0
commit
0a28dfe1e2
@ -504,8 +504,10 @@ int unpack(const char *image, bool skip_decomp, bool hdr) {
|
|||||||
return boot.flags[CHROMEOS_FLAG] ? 2 : 0;
|
return boot.flags[CHROMEOS_FLAG] ? 2 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define file_align() \
|
#define file_align_with(page_size) \
|
||||||
write_zero(fd, align_off(lseek(fd, 0, SEEK_CUR) - off.header, boot.hdr->page_size()))
|
write_zero(fd, align_off(lseek(fd, 0, SEEK_CUR) - off.header, page_size))
|
||||||
|
|
||||||
|
#define file_align() file_align_with(boot.hdr->page_size())
|
||||||
|
|
||||||
void repack(const char *src_img, const char *out_img, bool skip_comp) {
|
void repack(const char *src_img, const char *out_img, bool skip_comp) {
|
||||||
const boot_img boot(src_img);
|
const boot_img boot(src_img);
|
||||||
@ -682,8 +684,11 @@ void repack(const char *src_img, const char *out_img, bool skip_comp) {
|
|||||||
file_align();
|
file_align();
|
||||||
|
|
||||||
// vbmeta
|
// vbmeta
|
||||||
off.vbmeta = lseek(fd, 0, SEEK_CUR);
|
|
||||||
if (boot.flags[AVB_FLAG]) {
|
if (boot.flags[AVB_FLAG]) {
|
||||||
|
// According to avbtool.py, if the input is not an Android sparse image
|
||||||
|
// (which boot images are not), the default block size is 4096
|
||||||
|
file_align_with(4096);
|
||||||
|
off.vbmeta = lseek(fd, 0, SEEK_CUR);
|
||||||
uint64_t vbmeta_size = __builtin_bswap64(boot.avb_footer->vbmeta_size);
|
uint64_t vbmeta_size = __builtin_bswap64(boot.avb_footer->vbmeta_size);
|
||||||
xwrite(fd, boot.avb_meta, vbmeta_size);
|
xwrite(fd, boot.avb_meta, vbmeta_size);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user