Skip to content

Commit 3fca9cc

Browse files
committed
Update rootdir.rs
1 parent e99f94f commit 3fca9cc

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

native/src/init/rootdir.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::consts::{PREINITMIRR, ROOTMNT, ROOTOVL};
22
use crate::ffi::MagiskInit;
33
use base::libc::{O_CLOEXEC, O_CREAT, O_RDONLY, O_WRONLY};
44
use base::{
5-
BufReadExt, Directory, FsPath, FsPathBuilder, FsPathMnt, LoggedResult, ResultExt, Utf8CStr, Utf8CString,
6-
clone_attr, const_format::concatcp, cstr, debug,
5+
BufReadExt, Directory, FsPath, FsPathBuilder, FsPathMnt, LoggedResult, ResultExt, Utf8CStr,
6+
Utf8CString, clone_attr, const_format::concatcp, cstr, debug,
77
};
88
use std::io::BufReader;
99
use std::{
@@ -73,9 +73,9 @@ impl MagiskInit {
7373

7474
pub(crate) fn load_overlay_rc(&mut self, overlay: &Utf8CStr, module_path: &Utf8CStr) {
7575
if let Ok(mut dir) = Directory::open(overlay) {
76-
let init_rc = FsPathBuf::from(cstr::buf::dynamic(256))
77-
.join(overlay)
78-
.join("init.rc");
76+
let init_rc = cstr::buf::dynamic(256)
77+
.join_path(overlay)
78+
.join_path("init.rc");
7979
if init_rc.exists() {
8080
// Do not allow overwrite init.rc
8181
init_rc.remove().log_ok();
@@ -84,26 +84,23 @@ impl MagiskInit {
8484
match dir.read() {
8585
Ok(None) => break,
8686
Ok(Some(e)) => {
87-
let recursive = FsPathBuf::from(cstr::buf::dynamic(256))
88-
.join(module_path)
89-
.exists();
87+
let recursive = cstr::buf::dynamic(256).join_path(module_path).exists();
9088
if (recursive && e.is_dir()) || e.is_file() {
9189
let buf = &mut cstr::buf::dynamic(256);
9290
e.path(buf).log_ok();
9391
if e.is_file() && buf.ends_with(".rc") {
9492
let mut path;
9593
if recursive {
96-
path = FsPathBuf::from(cstr::buf::dynamic(256))
97-
.join(buf.replace(module_path.as_str(), ""));
94+
path = cstr::buf::dynamic(256)
95+
.join_path(buf.replace(module_path.as_str(), ""));
9896
} else {
99-
path = FsPathBuf::from(cstr::buf::dynamic(256))
100-
.join("/")
101-
.join(e.name());
97+
path =
98+
cstr::buf::dynamic(256).join_path("/").join_path(e.name());
10299
}
103100
if path.exists() {
104101
debug!("Replace rc script [{}] -> [{}]", path, buf);
105102
} else {
106-
path = FsPathBuf::from(cstr::buf::dynamic(256)).join(buf);
103+
path = cstr::buf::dynamic(256).join_path(buf);
107104
debug!("Found rc script [{}]", path);
108105
let mut rc_content = String::new();
109106
if let Ok(mut file) = path.open(O_RDONLY | O_CLOEXEC) {
@@ -134,9 +131,9 @@ impl MagiskInit {
134131
Ok(Some(e)) if e.is_dir() => {
135132
let buf = &mut cstr::buf::dynamic(256);
136133
e.path(buf).log_ok();
137-
let path = FsPathBuf::from(cstr::buf::dynamic(256)).join(&mut *buf);
134+
let path = cstr::buf::dynamic(256).join_path(&mut *buf);
138135
self.load_overlay_rc(&path, buf);
139-
let desc_path = FsPathBuf::from(cstr::buf::dynamic(256)).join(root_dir);
136+
let desc_path = cstr::buf::dynamic(256).join_path(root_dir);
140137
path.copy_to(&desc_path).log_ok();
141138
}
142139
Ok(_) => continue,

0 commit comments

Comments
 (0)