Create Utf8CStrBuffer type

This commit is contained in:
topjohnwu
2025-04-14 18:20:31 -07:00
committed by John Wu
parent 55b036c071
commit 084d89fcce
6 changed files with 105 additions and 54 deletions

View File

@@ -11,7 +11,8 @@ use crate::package::ManagerInfo;
use crate::su::SuInfo;
use base::libc::{O_CLOEXEC, O_RDONLY};
use base::{
AtomicArc, BufReadExt, FsPathBuf, ResultExt, Utf8CStr, cstr, error, info, libc, open_fd, path,
AtomicArc, BufReadExt, FsPathBuf, ResultExt, Utf8CStr, cstr, cstr_buf, error, info, libc,
open_fd, path,
};
use std::fs::File;
use std::io::BufReader;
@@ -228,7 +229,7 @@ pub fn daemon_entry() {
|| get_prop(cstr!("ro.product.device"), false).contains("vsoc");
// Load config status
let path = FsPathBuf::<64>::new()
let path = FsPathBuf::from(cstr_buf::new::<64>())
.join(get_magisk_tmp())
.join(MAIN_CONFIG);
let mut is_recovery = false;

View File

@@ -7,8 +7,8 @@ use num_traits::AsPrimitive;
use base::libc::{c_uint, dev_t};
use base::{
FsPath, FsPathBuf, LibcReturn, LoggedResult, MountInfo, ResultExt, Utf8CStr, cstr, debug, info,
libc, parse_mount_info, path, warn,
FsPath, FsPathBuf, LibcReturn, LoggedResult, MountInfo, ResultExt, Utf8CStr, cstr, cstr_buf,
debug, info, libc, parse_mount_info, path, warn,
};
use crate::consts::{MODULEMNT, MODULEROOT, PREINITDEV, PREINITMIRR, WORKERDIR};
@@ -21,7 +21,9 @@ pub fn setup_mounts() {
let magisk_tmp = get_magisk_tmp();
// Mount preinit directory
let dev_path = FsPathBuf::<64>::new().join(magisk_tmp).join(PREINITDEV);
let dev_path = FsPathBuf::from(cstr_buf::new::<64>())
.join(magisk_tmp)
.join(PREINITDEV);
let mut linked = false;
if let Ok(attr) = dev_path.get_attr() {
if attr.st.st_mode & libc::S_IFMT as c_uint == libc::S_IFBLK.as_() {

View File

@@ -37,7 +37,9 @@ fn exec_zygiskd(is_64_bit: bool, remote: UnixStream) {
#[cfg(target_pointer_width = "32")]
let magisk = "magisk";
let exe = FsPathBuf::<64>::new().join(get_magisk_tmp()).join(magisk);
let exe = FsPathBuf::from(cstr_buf::new::<64>())
.join(get_magisk_tmp())
.join(magisk);
let mut fd_str = cstr_buf::new::<16>();
write!(fd_str, "{}", remote.as_raw_fd()).ok();