You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Use mmap_data more widely
This commit is contained in:
@@ -151,12 +151,9 @@ void cpio::dump(FILE *out) {
|
||||
}
|
||||
|
||||
void cpio::load_cpio(const char *file) {
|
||||
char *buf;
|
||||
size_t sz;
|
||||
mmap_ro(file, buf, sz);
|
||||
fprintf(stderr, "Loading cpio: [%s]\n", file);
|
||||
load_cpio(buf, sz);
|
||||
munmap(buf, sz);
|
||||
auto m = mmap_data(file);
|
||||
load_cpio(reinterpret_cast<char *>(m.buf), m.sz);
|
||||
}
|
||||
|
||||
void cpio::insert(string_view name, cpio_entry *e) {
|
||||
@@ -169,14 +166,11 @@ void cpio::insert(string_view name, cpio_entry *e) {
|
||||
}
|
||||
|
||||
void cpio::add(mode_t mode, const char *name, const char *file) {
|
||||
void *buf;
|
||||
size_t sz;
|
||||
mmap_ro(file, buf, sz);
|
||||
auto m = mmap_data(file);
|
||||
auto e = new cpio_entry(S_IFREG | mode);
|
||||
e->filesize = sz;
|
||||
e->data = xmalloc(sz);
|
||||
memcpy(e->data, buf, sz);
|
||||
munmap(buf, sz);
|
||||
e->filesize = m.sz;
|
||||
e->data = xmalloc(m.sz);
|
||||
memcpy(e->data, m.buf, m.sz);
|
||||
insert(name, e);
|
||||
fprintf(stderr, "Add entry [%s] (%04o)\n", name, mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user