mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
Add more comments
This commit is contained in:
parent
4e2b88b3d0
commit
76405bd984
@ -62,6 +62,11 @@ static void mount_mirrors() {
|
|||||||
|
|
||||||
// Check and mount preinit mirror
|
// Check and mount preinit mirror
|
||||||
if (struct stat st{}; stat((MAGISKTMP + "/" PREINITDEV).data(), &st) == 0 && (st.st_mode & S_IFBLK)) {
|
if (struct stat st{}; stat((MAGISKTMP + "/" PREINITDEV).data(), &st) == 0 && (st.st_mode & S_IFBLK)) {
|
||||||
|
// DO NOT mount the block device directly, as we do not know the flags and configs
|
||||||
|
// to properly mount the partition; mounting block devices directly as rw could cause
|
||||||
|
// crashes if the filesystem driver is crap (e.g. some broken F2FS drivers).
|
||||||
|
// What we do instead is to scan through the current mountinfo and find a pre-existing
|
||||||
|
// mount point mounting our desired partition, and then bind mount the target folder.
|
||||||
dev_t preinit_dev = st.st_rdev;
|
dev_t preinit_dev = st.st_rdev;
|
||||||
for (const auto &info: self_mount_info) {
|
for (const auto &info: self_mount_info) {
|
||||||
if (info.root == "/" && info.device == preinit_dev) {
|
if (info.root == "/" && info.device == preinit_dev) {
|
||||||
|
@ -129,6 +129,10 @@ static void mount_preinit_dir(string path, dev_t preinit_dev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since we are mounting the block device directly, make sure to ONLY mount the partitions
|
||||||
|
// as read-only, or else the kernel might crash due to crappy drivers.
|
||||||
|
// After the device boots up, magiskd will properly bind mount the correct partition
|
||||||
|
// on to PREINITMIRR as writable. For more details, check bootstages.cpp
|
||||||
if (mounted || mount(PREINITDEV, PREINITMNT, "ext4", MS_RDONLY, nullptr) == 0 ||
|
if (mounted || mount(PREINITDEV, PREINITMNT, "ext4", MS_RDONLY, nullptr) == 0 ||
|
||||||
mount(PREINITDEV, PREINITMNT, "f2fs", MS_RDONLY, nullptr) == 0) {
|
mount(PREINITDEV, PREINITMNT, "f2fs", MS_RDONLY, nullptr) == 0) {
|
||||||
string preinit_dir = resolve_preinit_dir(PREINITMNT);
|
string preinit_dir = resolve_preinit_dir(PREINITMNT);
|
||||||
|
Loading…
Reference in New Issue
Block a user