diff --git a/native/src/boot/cpio.rs b/native/src/boot/cpio.rs index 43892fe2c..d04dea889 100644 --- a/native/src/boot/cpio.rs +++ b/native/src/boot/cpio.rs @@ -94,7 +94,7 @@ struct CpioHeader { } pub(crate) struct Cpio { - pub(crate) entries: BTreeMap, + pub(crate) entries: BTreeMap>, } pub(crate) struct CpioEntry { @@ -138,14 +138,14 @@ impl Cpio { continue; } let file_size = x8u::(&hdr.filesize)?; - let entry = CpioEntry { + let entry = Box::new(CpioEntry { mode: x8u(&hdr.mode)?, uid: x8u(&hdr.uid)?, gid: x8u(&hdr.gid)?, rdevmajor: x8u(&hdr.rdevmajor)?, rdevminor: x8u(&hdr.rdevminor)?, data: data[pos..pos + file_size].to_vec(), - }; + }); pos += file_size; cpio.entries.insert(name, entry); pos = align_4(pos); @@ -303,14 +303,14 @@ impl Cpio { }; self.entries.insert( norm_path(path), - CpioEntry { + Box::new(CpioEntry { mode, uid: 0, gid: 0, rdevmajor, rdevminor, data: content, - }, + }), ); eprintln!("Add file [{}] ({:04o})", path, mode); Ok(()) @@ -319,14 +319,14 @@ impl Cpio { fn mkdir(&mut self, mode: &mode_t, dir: &str) { self.entries.insert( norm_path(dir), - CpioEntry { + Box::new(CpioEntry { mode: *mode | S_IFDIR, uid: 0, gid: 0, rdevmajor: 0, rdevminor: 0, data: vec![], - }, + }), ); eprintln!("Create directory [{}] ({:04o})", dir, mode); } @@ -334,14 +334,14 @@ impl Cpio { fn ln(&mut self, src: &str, dst: &str) { self.entries.insert( norm_path(dst), - CpioEntry { + Box::new(CpioEntry { mode: S_IFLNK, uid: 0, gid: 0, rdevmajor: 0, rdevminor: 0, data: norm_path(src).as_bytes().to_vec(), - }, + }), ); eprintln!("Create symlink [{}] -> [{}]", dst, src); } diff --git a/native/src/boot/ramdisk.rs b/native/src/boot/ramdisk.rs index f0e5d4121..faf6f66fe 100644 --- a/native/src/boot/ramdisk.rs +++ b/native/src/boot/ramdisk.rs @@ -90,7 +90,7 @@ impl MagiskCpio for Cpio { } fn restore(&mut self) -> anyhow::Result<()> { - let mut backups = HashMap::::new(); + let mut backups = HashMap::>::new(); let mut rm_list = String::new(); self.entries .drain_filter(|name, _| name.starts_with(".backup/")) @@ -121,18 +121,18 @@ impl MagiskCpio for Cpio { } fn backup(&mut self, origin: &Utf8CStr) -> anyhow::Result<()> { - let mut backups = HashMap::::new(); + let mut backups = HashMap::>::new(); let mut rm_list = String::new(); backups.insert( ".backup".to_string(), - CpioEntry { + Box::new(CpioEntry { mode: S_IFDIR, uid: 0, gid: 0, rdevmajor: 0, rdevminor: 0, data: vec![], - }, + }), ); let mut o = Cpio::load_from_file(origin)?; o.rm(".backup", true); @@ -143,7 +143,7 @@ impl MagiskCpio for Cpio { loop { enum Action<'a> { - Backup(String, CpioEntry), + Backup(String, Box), Record(&'a String), Noop, } @@ -190,14 +190,14 @@ impl MagiskCpio for Cpio { if !rm_list.is_empty() { backups.insert( ".backup/.rmlist".to_string(), - CpioEntry { + Box::new(CpioEntry { mode: S_IFREG, uid: 0, gid: 0, rdevmajor: 0, rdevminor: 0, data: rm_list.as_bytes().to_vec(), - }, + }), ); } self.entries.extend(backups);