Fix compile errors and cleanup

This commit is contained in:
topjohnwu
2023-06-10 17:11:02 -07:00
committed by John Wu
parent e58f98e844
commit 6b21091fe2
10 changed files with 66 additions and 57 deletions
+16 -5
View File
@@ -1,11 +1,13 @@
use crate::cpio::{Cpio, CpioEntry};
use crate::ffi::{patch_encryption, patch_verity};
use base::libc::{S_IFDIR, S_IFMT, S_IFREG};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::env;
use std::str::from_utf8;
use base::libc::{S_IFDIR, S_IFMT, S_IFREG};
use crate::cpio::{Cpio, CpioEntry};
use crate::ffi::{patch_encryption, patch_verity};
pub trait MagiskCpio {
fn patch(&mut self);
fn test(&self) -> i32;
@@ -40,17 +42,24 @@ impl MagiskCpio for Cpio {
if !keep_verity {
if fstab {
eprintln!("Found fstab file [{}]", name);
patch_verity(entry.data.as_mut_slice());
let len = patch_verity(entry.data.as_mut_slice());
if len != entry.data.len() {
entry.data.resize(len, 0);
}
} else if name == "verity_key" {
return false;
}
}
if !keep_force_encrypt && fstab {
patch_encryption(entry.data.as_mut_slice());
let len = patch_encryption(entry.data.as_mut_slice());
if len != entry.data.len() {
entry.data.resize(len, 0);
}
}
true
});
}
fn test(&self) -> i32 {
let mut ret = 0;
for file in [
@@ -78,6 +87,7 @@ impl MagiskCpio for Cpio {
}
ret
}
fn restore(&mut self) -> anyhow::Result<()> {
let mut backups = HashMap::<String, CpioEntry>::new();
let mut rm_list = String::new();
@@ -106,6 +116,7 @@ impl MagiskCpio for Cpio {
Ok(())
}
fn backup(&mut self, origin: &str) -> anyhow::Result<()> {
let mut backups = HashMap::<String, CpioEntry>::new();
let mut rm_list = String::new();