mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 13:17:39 +02:00
Support A only System-as-root Devices
Most Chinese devices (and supposedly Galaxy S10) running Android Pie is using system-as-root without A/B partition. https://source.android.com/devices/bootloader/system-as-root#about-system-as-root According to the docs above, these devices will have a ramdisk block with size 0 in their boot images. Since magiskinit can run independently on system-as-root devices, we simply just create an empty ramdisk with magiskinit added as init. Huge thanks to @vvb2060 for the heads up and original PR. Close #980, close #1102
This commit is contained in:
@ -149,11 +149,15 @@ void cpio::output(OutStream &out) {
|
||||
out_align();
|
||||
}
|
||||
|
||||
cpio_rw::cpio_rw(const char *filename) {
|
||||
cpio_rw::cpio_rw(const char *file) {
|
||||
load_cpio(file);
|
||||
}
|
||||
|
||||
void cpio_rw::load_cpio(const char *file) {
|
||||
char *buf;
|
||||
size_t sz;
|
||||
mmap_ro(filename, buf, sz);
|
||||
fprintf(stderr, "Loading cpio: [%s]\n", filename);
|
||||
mmap_ro(file, buf, sz);
|
||||
fprintf(stderr, "Loading cpio: [%s]\n", file);
|
||||
load_cpio(buf, sz);
|
||||
munmap(buf, sz);
|
||||
}
|
||||
@ -182,7 +186,7 @@ void cpio_rw::add(mode_t mode, const char *name, const char *file) {
|
||||
fprintf(stderr, "Add entry [%s] (%04o)\n", name, mode);
|
||||
}
|
||||
|
||||
void cpio_rw::makedir(mode_t mode, const char *name) {
|
||||
void cpio_rw::mkdir(mode_t mode, const char *name) {
|
||||
insert(new cpio_entry(name, S_IFDIR | mode));
|
||||
fprintf(stderr, "Create directory [%s] (%04o)\n", name, mode);
|
||||
}
|
||||
@ -241,9 +245,9 @@ void cpio_rw::load_cpio(char *buf, size_t sz) {
|
||||
}
|
||||
}
|
||||
|
||||
cpio_mmap::cpio_mmap(const char *filename) {
|
||||
mmap_ro(filename, buf, sz);
|
||||
fprintf(stderr, "Loading cpio: [%s]\n", filename);
|
||||
cpio_mmap::cpio_mmap(const char *file) {
|
||||
mmap_ro(file, buf, sz);
|
||||
fprintf(stderr, "Loading cpio: [%s]\n", file);
|
||||
size_t pos = 0;
|
||||
cpio_newc_header *header;
|
||||
unique_ptr<cpio_entry_base> entry;
|
||||
|
@ -53,21 +53,23 @@ protected:
|
||||
|
||||
class cpio_rw : public cpio {
|
||||
public:
|
||||
explicit cpio_rw(const char *filename);
|
||||
void insert(cpio_entry *e);
|
||||
cpio_rw() = default;
|
||||
explicit cpio_rw(const char *file);
|
||||
void load_cpio(const char *file);
|
||||
void add(mode_t mode, const char *name, const char *file);
|
||||
void makedir(mode_t mode, const char *name);
|
||||
void mkdir(mode_t mode, const char *name);
|
||||
void ln(const char *target, const char *name);
|
||||
bool mv(const char *from, const char *to);
|
||||
|
||||
protected:
|
||||
void insert(cpio_entry *e);
|
||||
void mv(entry_map::iterator &it, const char *to);
|
||||
void load_cpio(char *buf, size_t sz);
|
||||
};
|
||||
|
||||
class cpio_mmap : public cpio {
|
||||
public:
|
||||
explicit cpio_mmap(const char *filename);
|
||||
explicit cpio_mmap(const char *file);
|
||||
~cpio_mmap();
|
||||
private:
|
||||
char *buf;
|
||||
|
Reference in New Issue
Block a user