Move BootConfig::print to rust

This commit is contained in:
LoveSy 2025-01-30 21:59:42 +08:00 committed by John Wu
parent c99f4a591b
commit 563f0d5ad5
3 changed files with 23 additions and 13 deletions

View File

@ -158,18 +158,6 @@ void BootConfig::set(const kv_pairs &kv) noexcept {
}
}
void BootConfig::print() const noexcept {
LOGD("skip_initramfs=[%d]\n", skip_initramfs);
LOGD("force_normal_boot=[%d]\n", force_normal_boot);
LOGD("rootwait=[%d]\n", rootwait);
LOGD("slot=[%s]\n", slot.data());
LOGD("dt_dir=[%s]\n", dt_dir.data());
LOGD("fstab_suffix=[%s]\n", fstab_suffix.data());
LOGD("hardware=[%s]\n", hardware.data());
LOGD("hardware.platform=[%s]\n", hardware_plat.data());
LOGD("emulator=[%d]\n", emulator);
}
#define read_dt(name, key) \
ssprintf(file_name, sizeof(file_name), "%s/" name, dt_dir.data()); \
if (access(file_name, R_OK) == 0) { \

View File

@ -0,0 +1,20 @@
use std::ffi::CStr;
use base::debug;
use crate::ffi::BootConfig;
impl BootConfig {
pub(crate) fn print(&self) {
debug!("skip_initramfs=[{}]", self.skip_initramfs);
debug!("force_normal_boot=[{}]", self.force_normal_boot);
debug!("rootwait=[{}]", self.rootwait);
unsafe {
debug!("slot=[{:?}]", CStr::from_ptr(self.slot.as_ptr()));
debug!("dt_dir=[{:?}]", CStr::from_ptr(self.dt_dir.as_ptr()));
debug!("fstab_suffix=[{:?}]", CStr::from_ptr(self.fstab_suffix.as_ptr()));
debug!("hardware=[{:?}]", CStr::from_ptr(self.hardware.as_ptr()));
debug!("hardware.platform=[{:?}]", CStr::from_ptr(self.hardware_plat.as_ptr()));
}
debug!("emulator=[{}]", self.emulator);
debug!("partition_map=[{:?}]", self.partition_map);
}
}

View File

@ -18,9 +18,11 @@ use std::ptr::null as nullptr;
mod logging;
mod mount;
mod rootdir;
mod getinfo;
#[cxx::bridge]
pub mod ffi {
#[derive(Debug)]
struct KeyValue {
key: String,
value: String,
@ -57,6 +59,7 @@ pub mod ffi {
}
extern "Rust" {
fn print(self: &BootConfig);
fn prepare_data(self: &MagiskInit);
fn exec_init(self: &MagiskInit);
}
@ -68,7 +71,6 @@ pub mod ffi {
#[cxx_name = "Utf8CStr"]
type Utf8CStrRef<'a> = base::ffi::Utf8CStrRef<'a>;
fn init(self: &mut BootConfig);
fn print(self: &BootConfig);
type kv_pairs;
fn set(self: &mut BootConfig, config: &kv_pairs);