You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Migrate module mounting to Rust
This commit is contained in:
@@ -82,7 +82,7 @@ impl MagiskInit {
|
||||
debug!("Mount [{}] -> [{}]", src, dest);
|
||||
clone_attr(&dest, &src)?;
|
||||
dest.get_secontext(&mut con)?;
|
||||
src.bind_mount_to(&dest)?;
|
||||
src.bind_mount_to(&dest, false)?;
|
||||
self.overlay_con
|
||||
.push(OverlayAttr(dest.to_owned(), con.to_owned()));
|
||||
mount_list.push_str(dest.as_str());
|
||||
|
||||
@@ -49,13 +49,13 @@ enum SePatchStrategy {
|
||||
fn mock_fifo(target: &Utf8CStr, mock: &Utf8CStr) -> LoggedResult<()> {
|
||||
debug!("Hijack [{}]", target);
|
||||
mock.mkfifo(0o666)?;
|
||||
mock.bind_mount_to(target).log()
|
||||
mock.bind_mount_to(target, false).log()
|
||||
}
|
||||
|
||||
fn mock_file(target: &Utf8CStr, mock: &Utf8CStr) -> LoggedResult<()> {
|
||||
debug!("Hijack [{}]", target);
|
||||
drop(mock.create(libc::O_RDONLY, 0o666)?);
|
||||
mock.bind_mount_to(target).log()
|
||||
mock.bind_mount_to(target, false).log()
|
||||
}
|
||||
|
||||
impl MagiskInit {
|
||||
|
||||
@@ -37,7 +37,7 @@ pub(crate) fn hexpatch_init_for_second_stage(writable: bool) {
|
||||
}
|
||||
let attr = src.follow_link().get_attr()?;
|
||||
dest.set_attr(&attr)?;
|
||||
dest.bind_mount_to(src)?;
|
||||
dest.bind_mount_to(src, false)?;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -89,12 +89,15 @@ impl MagiskInit {
|
||||
cstr!("/init").rename_to(cstr!("/sdcard")).log_ok();
|
||||
|
||||
// First try to mount magiskinit from rootfs to workaround Samsung RKP
|
||||
if cstr!("/sdcard").bind_mount_to(cstr!("/sdcard")).is_ok() {
|
||||
if cstr!("/sdcard")
|
||||
.bind_mount_to(cstr!("/sdcard"), false)
|
||||
.is_ok()
|
||||
{
|
||||
debug!("Bind mount /sdcard -> /sdcard");
|
||||
} else {
|
||||
// Binding mounting from rootfs is not supported before Linux 3.12
|
||||
cstr!("/data/magiskinit")
|
||||
.bind_mount_to(cstr!("/sdcard"))
|
||||
.bind_mount_to(cstr!("/sdcard"), false)
|
||||
.log_ok();
|
||||
debug!("Bind mount /data/magiskinit -> /sdcard");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user