From 1528afc4ba4df4a1a324c156591ff1560486be19 Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Sat, 9 Nov 2024 21:11:44 +0700 Subject: [PATCH] Writes mounted from --- Cargo.lock | 6 +++--- dumper/src/main.rs | 28 +++++++++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86c7739..39613d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,7 +24,7 @@ version = "0.1.0" [[package]] name = "okf" version = "0.1.0" -source = "git+https://github.com/obhq/kernel-framework.git#ae34788ea44c7ce2c53dc5dcbfee9cb842b0447d" +source = "git+https://github.com/obhq/kernel-framework.git#dd2974f037b0bf793a29c374d7ddfc9a43d7a6dd" dependencies = [ "bitflags", "okf-macros", @@ -33,7 +33,7 @@ dependencies = [ [[package]] name = "okf-1100" version = "0.1.0" -source = "git+https://github.com/obhq/kernel-framework.git#ae34788ea44c7ce2c53dc5dcbfee9cb842b0447d" +source = "git+https://github.com/obhq/kernel-framework.git#dd2974f037b0bf793a29c374d7ddfc9a43d7a6dd" dependencies = [ "okf", ] @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "okf-macros" version = "0.1.0" -source = "git+https://github.com/obhq/kernel-framework.git#ae34788ea44c7ce2c53dc5dcbfee9cb842b0447d" +source = "git+https://github.com/obhq/kernel-framework.git#dd2974f037b0bf793a29c374d7ddfc9a43d7a6dd" dependencies = [ "proc-macro2", "quote", diff --git a/dumper/src/main.rs b/dumper/src/main.rs index 091a6e2..e339285 100644 --- a/dumper/src/main.rs +++ b/dumper/src/main.rs @@ -11,7 +11,7 @@ use core::panic::PanicInfo; use obfw::FirmwareDump; use okf::fd::{openat, write_all, OpenFlags, AT_FDCWD}; use okf::lock::MtxLock; -use okf::mount::{Filesystem, Mount}; +use okf::mount::{Filesystem, FsStats, Mount}; use okf::pcpu::Pcpu; use okf::uio::UioSeg; use okf::{kernel, Allocator, Kernel}; @@ -168,12 +168,26 @@ unsafe fn dump_mount(k: K, fd: c_int, mp: *mut K::Mount, lock: MtxLoc return true; } - // Write header. - if !write_dump( - k, - fd, - core::slice::from_ref(&FirmwareDump::<()>::ITEM_PARTITION), - ) { + // Write entry type. + if !write_dump(k, fd, &[FirmwareDump::<()>::ITEM_PARTITION]) { + return false; + } + + // Write entry version. + if !write_dump(k, fd, &[0]) { + return false; + } + + // Write filesystem type. + if !write_dump(k, fd, &name.len().to_le_bytes()) || !write_dump(k, fd, name) { + return false; + } + + // Write mounted from. + let stats = (*mp).stats(); + let path = CStr::from_ptr((*stats).mounted_from()).to_bytes(); + + if !write_dump(k, fd, &path.len().to_le_bytes()) || write_dump(k, fd, path) { return false; }