mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-12 00:52:09 +00:00
Migrate magiskinit selinux.cpp to Rust
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use cxx::{type_id, ExternType};
|
||||
use cxx::{ExternType, type_id};
|
||||
use libc::c_char;
|
||||
use std::borrow::Borrow;
|
||||
use std::cmp::min;
|
||||
@@ -479,6 +479,11 @@ impl FsPath {
|
||||
unsafe { mem::transmute(value.as_ref()) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub const fn from_utfcstr(value: &Utf8CStr) -> &FsPath {
|
||||
unsafe { mem::transmute(value) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn from_mut<T: AsMut<Utf8CStr> + ?Sized>(value: &mut T) -> &mut FsPath {
|
||||
unsafe { mem::transmute(value.as_mut()) }
|
||||
@@ -781,14 +786,10 @@ macro_rules! cstr {
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! raw_cstr {
|
||||
($str:expr) => {{
|
||||
$crate::cstr!($str).as_ptr()
|
||||
}};
|
||||
($str:expr) => {{ $crate::cstr!($str).as_ptr() }};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! path {
|
||||
($str:expr) => {{
|
||||
$crate::FsPath::from($crate::cstr!($str))
|
||||
}};
|
||||
($str:expr) => {{ $crate::FsPath::from_utfcstr($crate::cstr!($str)) }};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user