You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Introduce cstr_buf helper functions
This commit is contained in:
@@ -6,8 +6,8 @@ use base::libc::{
|
||||
timespec, tm, O_CLOEXEC, O_RDWR, O_WRONLY, PIPE_BUF, SIGPIPE, SIG_BLOCK, SIG_SETMASK,
|
||||
};
|
||||
use base::{
|
||||
const_format::concatcp, libc, raw_cstr, FsPathBuf, LogLevel, Logger, ReadExt, Utf8CStr,
|
||||
Utf8CStrBuf, Utf8CStrBufArr, WriteExt, LOGGER,
|
||||
const_format::concatcp, cstr_buf, libc, raw_cstr, FsPathBuf, LogLevel, Logger, ReadExt,
|
||||
Utf8CStr, Utf8CStrBuf, WriteExt, LOGGER,
|
||||
};
|
||||
use bytemuck::{bytes_of, write_zeroes, Pod, Zeroable};
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
@@ -130,7 +130,7 @@ fn write_log_to_pipe(mut logd: &File, prio: i32, msg: &Utf8CStr) -> io::Result<u
|
||||
let io2 = IoSlice::new(msg);
|
||||
let result = logd.write_vectored(&[io1, io2]);
|
||||
if let Err(ref e) = result {
|
||||
let mut buf = Utf8CStrBufArr::default();
|
||||
let mut buf = cstr_buf::default();
|
||||
buf.write_fmt(format_args!("Cannot write_log_to_pipe: {}", e))
|
||||
.ok();
|
||||
android_log_write(LogLevel::Error, &buf);
|
||||
@@ -266,7 +266,7 @@ extern "C" fn logfile_writer(arg: *mut c_void) -> *mut c_void {
|
||||
|
||||
let mut meta = LogMeta::zeroed();
|
||||
let mut msg_buf = [0u8; MAX_MSG_LEN];
|
||||
let mut aux = Utf8CStrBufArr::<64>::new();
|
||||
let mut aux = cstr_buf::new::<64>();
|
||||
|
||||
loop {
|
||||
// Read request
|
||||
|
||||
@@ -8,8 +8,8 @@ use num_traits::AsPrimitive;
|
||||
|
||||
use base::libc::{c_uint, dev_t};
|
||||
use base::{
|
||||
cstr, debug, info, libc, parse_mount_info, raw_cstr, warn, FsPath, FsPathBuf, LibcReturn,
|
||||
LoggedResult, MountInfo, ResultExt, Utf8CStr, Utf8CStrBufArr,
|
||||
cstr, cstr_buf, debug, info, libc, parse_mount_info, raw_cstr, warn, FsPath, FsPathBuf,
|
||||
LibcReturn, LoggedResult, MountInfo, ResultExt, Utf8CStr,
|
||||
};
|
||||
|
||||
use crate::consts::{MODULEMNT, MODULEROOT, PREINITDEV, PREINITMIRR, WORKERDIR};
|
||||
@@ -45,7 +45,7 @@ pub fn setup_mounts() {
|
||||
let preinit_dir = Utf8CStr::from_string(&mut preinit_dir);
|
||||
let r: LoggedResult<()> = try {
|
||||
FsPath::from(preinit_dir).mkdir(0o700)?;
|
||||
let mut buf = Utf8CStrBufArr::default();
|
||||
let mut buf = cstr_buf::default();
|
||||
if mnt_path.parent(&mut buf) {
|
||||
FsPath::from(&buf).mkdirs(0o755)?;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ pub fn find_preinit_device() -> String {
|
||||
let preinit_dir = FsPath::from(Utf8CStr::from_string(&mut preinit_dir));
|
||||
let _: LoggedResult<()> = try {
|
||||
preinit_dir.mkdirs(0o700)?;
|
||||
let mut buf = Utf8CStrBufArr::default();
|
||||
let mut buf = cstr_buf::default();
|
||||
if mirror_dir.parent(&mut buf) {
|
||||
FsPath::from(&buf).mkdirs(0o755)?;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::ffi::{get_magisk_tmp, install_apk, uninstall_pkg, DbEntryKey};
|
||||
use base::libc::{O_CLOEXEC, O_CREAT, O_RDONLY, O_TRUNC, O_WRONLY};
|
||||
use base::WalkResult::{Abort, Continue, Skip};
|
||||
use base::{
|
||||
cstr, error, fd_get_attr, open_fd, warn, BufReadExt, Directory, FsPath, FsPathBuf,
|
||||
LoggedResult, ReadExt, ResultExt, Utf8CStrBuf, Utf8CStrBufArr,
|
||||
cstr, cstr_buf, error, fd_get_attr, open_fd, warn, BufReadExt, Directory, FsPath, FsPathBuf,
|
||||
LoggedResult, ReadExt, ResultExt, Utf8CStrBuf,
|
||||
};
|
||||
use bit_set::BitSet;
|
||||
use cxx::CxxString;
|
||||
@@ -273,7 +273,7 @@ impl ManagerInfo {
|
||||
}
|
||||
|
||||
fn check_stub(&mut self, user: i32, pkg: &str) -> Status {
|
||||
let mut arr = Utf8CStrBufArr::default();
|
||||
let mut arr = cstr_buf::default();
|
||||
if find_apk_path(pkg, &mut arr).is_err() {
|
||||
return Status::NotInstalled;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ impl ManagerInfo {
|
||||
}
|
||||
|
||||
fn check_orig(&mut self, user: i32) -> Status {
|
||||
let mut arr = Utf8CStrBufArr::default();
|
||||
let mut arr = cstr_buf::default();
|
||||
if find_apk_path(APP_PACKAGE_NAME, &mut arr).is_err() {
|
||||
return Status::NotInstalled;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ use crate::ffi::{
|
||||
use crate::socket::{IpcRead, UnixSocketExt};
|
||||
use base::libc::{O_CLOEXEC, O_CREAT, O_RDONLY, STDOUT_FILENO};
|
||||
use base::{
|
||||
cstr, error, fork_dont_care, libc, open_fd, raw_cstr, warn, Directory, FsPathBuf, LoggedError,
|
||||
LoggedResult, ResultExt, Utf8CStrBufArr, WriteExt,
|
||||
cstr, cstr_buf, error, fork_dont_care, libc, open_fd, raw_cstr, warn, Directory, FsPathBuf,
|
||||
LoggedError, LoggedResult, ResultExt, WriteExt,
|
||||
};
|
||||
use std::fmt::Write;
|
||||
use std::os::fd::{AsRawFd, FromRawFd, RawFd};
|
||||
@@ -39,7 +39,7 @@ fn exec_zygiskd(is_64_bit: bool, remote: UnixStream) {
|
||||
|
||||
let exe = FsPathBuf::<64>::new().join(get_magisk_tmp()).join(magisk);
|
||||
|
||||
let mut fd_str = Utf8CStrBufArr::<16>::new();
|
||||
let mut fd_str = cstr_buf::new::<16>();
|
||||
write!(fd_str, "{}", remote.as_raw_fd()).ok();
|
||||
unsafe {
|
||||
libc::execl(
|
||||
|
||||
Reference in New Issue
Block a user