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:
topjohnwu
2019-02-28 05:46:36 -05:00
parent 99d6bd8efc
commit e72c6685ed
4 changed files with 43 additions and 20 deletions

View File

@ -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;