mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-29 22:14:27 +02:00
Format code
This commit is contained in:
parent
caad129d69
commit
b1e17706a4
@ -1,12 +1,16 @@
|
||||
use crate::ffi::{magisk_proxy_main, BootConfig, MagiskInit};
|
||||
use crate::logging::setup_klog;
|
||||
use crate::{
|
||||
ffi::{magisk_proxy_main, BootConfig, MagiskInit},
|
||||
logging::setup_klog,
|
||||
};
|
||||
use base::{
|
||||
cstr, debug, info,
|
||||
libc::{basename, getpid, mount, umask},
|
||||
raw_cstr, FsPath, LibcReturn, LoggedResult, ResultExt, Utf8CStr,
|
||||
};
|
||||
use std::ffi::{c_char, CStr};
|
||||
use std::ptr::null as nullptr;
|
||||
use std::{
|
||||
ffi::{c_char, CStr},
|
||||
ptr::null,
|
||||
};
|
||||
|
||||
impl MagiskInit {
|
||||
fn new(argv: *mut *mut c_char) -> Self {
|
||||
@ -83,7 +87,7 @@ impl MagiskInit {
|
||||
raw_cstr!("/proc"),
|
||||
raw_cstr!("proc"),
|
||||
0,
|
||||
nullptr(),
|
||||
null(),
|
||||
)
|
||||
}
|
||||
.as_os_err()?;
|
||||
@ -97,7 +101,7 @@ impl MagiskInit {
|
||||
raw_cstr!("/sys"),
|
||||
raw_cstr!("sysfs"),
|
||||
0,
|
||||
nullptr(),
|
||||
null(),
|
||||
)
|
||||
}
|
||||
.as_os_err()?;
|
||||
|
@ -1,12 +1,17 @@
|
||||
use base::libc::{
|
||||
makedev, mknod, syscall, SYS_dup3, O_CLOEXEC, O_RDWR, O_WRONLY, STDERR_FILENO, STDIN_FILENO,
|
||||
STDOUT_FILENO, S_IFCHR,
|
||||
use base::{
|
||||
cstr,
|
||||
libc::{
|
||||
makedev, mknod, syscall, SYS_dup3, O_CLOEXEC, O_RDWR, O_WRONLY, STDERR_FILENO,
|
||||
STDIN_FILENO, STDOUT_FILENO, S_IFCHR,
|
||||
},
|
||||
open_fd, raw_cstr, FsPath, LogLevel, Logger, Utf8CStr, LOGGER,
|
||||
};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{IoSlice, Write},
|
||||
mem,
|
||||
os::fd::{FromRawFd, IntoRawFd, RawFd},
|
||||
};
|
||||
use base::{cstr, open_fd, raw_cstr, FsPath, LogLevel, Logger, Utf8CStr, LOGGER};
|
||||
use std::fs::File;
|
||||
use std::io::{IoSlice, Write};
|
||||
use std::mem;
|
||||
use std::os::fd::{FromRawFd, IntoRawFd, RawFd};
|
||||
|
||||
// SAFETY: magiskinit is single threaded
|
||||
static mut KMSG: RawFd = -1;
|
||||
|
@ -1,11 +1,3 @@
|
||||
use cxx::CxxString;
|
||||
use std::{
|
||||
collections::BTreeSet,
|
||||
ops::Bound::{Excluded, Unbounded},
|
||||
pin::Pin,
|
||||
ptr::null as nullptr,
|
||||
};
|
||||
|
||||
use crate::ffi::MagiskInit;
|
||||
use base::{
|
||||
cstr, debug, libc,
|
||||
@ -13,6 +5,13 @@ use base::{
|
||||
parse_mount_info, raw_cstr, Directory, FsPath, LibcReturn, LoggedResult, ResultExt, StringExt,
|
||||
Utf8CStr,
|
||||
};
|
||||
use cxx::CxxString;
|
||||
use std::{
|
||||
collections::BTreeSet,
|
||||
ops::Bound::{Excluded, Unbounded},
|
||||
pin::Pin,
|
||||
ptr::null as nullptr,
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
static environ: *const *mut libc::c_char;
|
||||
|
@ -2,11 +2,13 @@ use base::{
|
||||
debug, libc, Directory, LibcReturn, LoggedResult, ResultExt, Utf8CStr, Utf8CStrBuf,
|
||||
Utf8CStrBufArr, WalkResult,
|
||||
};
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::mem;
|
||||
use std::os::fd::{FromRawFd, RawFd};
|
||||
use std::sync::OnceLock;
|
||||
use std::{
|
||||
fs::File,
|
||||
io::Write,
|
||||
mem,
|
||||
os::fd::{FromRawFd, RawFd},
|
||||
sync::OnceLock,
|
||||
};
|
||||
|
||||
pub static OVERLAY_ATTRS: OnceLock<Vec<(String, String)>> = OnceLock::new();
|
||||
|
||||
|
@ -1,16 +1,13 @@
|
||||
use crate::ffi::MagiskInit;
|
||||
use base::libc::{mount, MS_BIND, O_WRONLY};
|
||||
use base::{
|
||||
clone_attr, cstr, debug, error, info,
|
||||
libc::{
|
||||
fstatat, stat, statfs, umount2, AT_SYMLINK_NOFOLLOW, MNT_DETACH, O_CLOEXEC, O_CREAT,
|
||||
O_RDONLY, TMPFS_MAGIC,
|
||||
fstatat, mount, stat, statfs, umount2, AT_SYMLINK_NOFOLLOW, MNT_DETACH, MS_BIND, O_CLOEXEC,
|
||||
O_CREAT, O_RDONLY, O_WRONLY, TMPFS_MAGIC,
|
||||
},
|
||||
raw_cstr, FsPath, LibcReturn, MappedFile, MutBytesExt, ResultExt,
|
||||
};
|
||||
use std::ffi::c_long;
|
||||
use std::io::Write;
|
||||
use std::ptr::null;
|
||||
use std::{ffi::c_long, io::Write, ptr::null};
|
||||
|
||||
impl MagiskInit {
|
||||
pub(crate) fn first_stage(&self) {
|
||||
@ -19,16 +16,11 @@ impl MagiskInit {
|
||||
|
||||
if unsafe {
|
||||
let mut st: stat = std::mem::zeroed();
|
||||
fstatat(
|
||||
-1,
|
||||
raw_cstr!("/sdcard"),
|
||||
std::ptr::from_mut(&mut st),
|
||||
AT_SYMLINK_NOFOLLOW,
|
||||
) != 0
|
||||
fstatat(-1, raw_cstr!("/sdcard"), &mut st, AT_SYMLINK_NOFOLLOW) != 0
|
||||
&& fstatat(
|
||||
-1,
|
||||
raw_cstr!("/first_stage_ramdisk/sdcard"),
|
||||
std::ptr::from_mut(&mut st),
|
||||
&mut st,
|
||||
AT_SYMLINK_NOFOLLOW,
|
||||
) != 0
|
||||
} {
|
||||
@ -151,7 +143,7 @@ impl MagiskInit {
|
||||
|
||||
// Some weird devices like meizu, uses 2SI but still have legacy rootfs
|
||||
let mut sfs: statfs = std::mem::zeroed();
|
||||
statfs(raw_cstr!("/"), std::ptr::from_mut(&mut sfs));
|
||||
statfs(raw_cstr!("/"), &mut sfs);
|
||||
if sfs.f_type == 0x858458f6 || sfs.f_type as c_long == TMPFS_MAGIC {
|
||||
// We are still on rootfs, so make sure we will execute the init of the 2nd stage
|
||||
let init_path = FsPath::from(cstr!("/init"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user