Magisk/native/jni
topjohnwu f1112fdf37 Logical Resizable Android Partitions support
The way how logical partition, or "Logical Resizable Android Partitions"
as they say in AOSP source code, is setup makes it impossible to early
mount the partitions from the shared super partition with just
a few lines of code; in fact, AOSP has a whole "fs_mgr" folder which
consist of multiple complex libraries, with 15K lines of code just
to deal with the device mapper shenanigans.

In order to keep the already overly complicated MagiskInit more
managable, I chose NOT to go the route of including fs_mgr directly
into MagiskInit. Luckily, starting from Android Q, Google decided to
split init startup into 3 stages, with the first stage doing _only_
early mount. This is great news, because we can simply let the stock
init do its own thing for us, and we intercept the bootup sequence.

So the workflow can be visualized roughly below:

Magisk First Stage --> First Stage Mount --> Magisk Second Stage --+
   (MagiskInit)         (Original Init)         (MagiskInit)       +
                                                                   +
                                                                   +
     ...Rest of the boot... <-- Second Stage <-- Selinux Setup  <--+
      (__________________ Original Init ____________________)

The catch here is that after doing all the first stage mounting, /init
will pivot /system as root directory (/), leaving us impossible to
regain control after we hand it over. So the solution here is to patch
fstab in /first_stage_ramdisk on-the-fly to redirect /system to
/system_root, making the original init do all the hard work for
us and mount required early mount partitions, but skips the step of
switching root directory. It will also conveniently hand over execution
back to MagiskInit, which we will reuse the routine for patching
root directory in normal system-as-root situations.
2019-06-29 01:25:54 -07:00
..
core MagiskHide is coming back strong 2019-06-27 00:28:34 -07:00
external Update native external dependencies 2019-04-30 01:31:07 -04:00
include Load custom sepolicy 2019-06-25 21:34:02 -07:00
init Logical Resizable Android Partitions support 2019-06-29 01:25:54 -07:00
magiskboot magiskboot: don't clobber /overlay with cpio restore anymore 2019-06-27 18:59:54 -04:00
magiskhide Kill blastula pool when magiskhide init 2019-06-27 00:49:27 -07:00
magiskpolicy Start Magisk in SAR 2019-06-25 23:31:59 -07:00
resetprop Make parse prop file a util function 2019-03-05 20:27:09 -05:00
su Properly isolate mount namespace 2019-06-04 21:21:27 -07:00
systemproperties Some code adjustments 2019-02-24 23:09:34 -05:00
utils Start Magisk in SAR 2019-06-25 23:31:59 -07:00
.gitignore Add entrypoint to build test 2019-04-01 02:46:09 -04:00
Android.mk Boot MagiskInit as actual system-as-root 2019-06-23 15:14:47 -07:00
Application.mk Build with -Wall 2019-04-29 21:26:43 -04:00