Skip to content

Commit 278d5df

Browse files
committed
Add more logging when storing images.
1 parent 30b6b9d commit 278d5df

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

pixie-uefi/src/os/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mod timer;
5555

5656
pub use net::{TcpStream, UdpHandle, PACKET_SIZE};
5757

58-
struct BytesFmt(u64);
58+
pub struct BytesFmt(pub u64);
5959

6060
impl Display for BytesFmt {
6161
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -547,7 +547,7 @@ impl UefiOS {
547547
}
548548

549549
os.messages.push_back((time, level, target.into(), msg));
550-
const MAX_MESSAGES: usize = 5;
550+
const MAX_MESSAGES: usize = 10;
551551
if os.messages.len() > MAX_MESSAGES {
552552
os.messages.pop_front();
553553
}

pixie-uefi/src/parse_disk.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ use crate::{
22
os::{
33
disk::Disk,
44
error::{Error, Result},
5+
BytesFmt,
56
},
67
store::ChunkInfo,
78
};
89
use alloc::vec::Vec;
10+
use log::info;
911

1012
fn le16(buf: &[u8], lo: usize) -> u16 {
1113
(0..2).map(|i| (buf[lo + i] as u16) << (8 * i)).sum()
@@ -244,12 +246,28 @@ async fn get_swap_chunks(disk: &Disk, start: u64, end: u64) -> Result<Option<Vec
244246
/// Returns chunks *relative to the start of the partition*.
245247
async fn parse_partition(disk: &Disk, start: u64, end: u64) -> Result<Vec<ChunkInfo>> {
246248
if let Some(chunks) = get_ext4_chunks(disk, start, end).await? {
249+
info!(
250+
"Ext4 partition with {} chunks of size {}",
251+
chunks.len(),
252+
BytesFmt(chunks.iter().map(|x| x.size as u64).sum::<u64>())
253+
);
247254
Ok(chunks)
248255
} else if let Some(chunks) = get_ntfs_chunks(disk, start, end).await? {
256+
info!(
257+
"NTFS partition with {} chunks of size {}",
258+
chunks.len(),
259+
BytesFmt(chunks.iter().map(|x| x.size as u64).sum::<u64>())
260+
);
249261
Ok(chunks)
250262
} else if let Some(chunks) = get_swap_chunks(disk, start, end).await? {
263+
info!(
264+
"Swap partition with {} chunks of size {}",
265+
chunks.len(),
266+
BytesFmt(chunks.iter().map(|x| x.size as u64).sum::<u64>())
267+
);
251268
Ok(chunks)
252269
} else {
270+
info!("Unknown partition type");
253271
Ok(vec![ChunkInfo {
254272
start: 0,
255273
size: (end - start) as usize,
@@ -268,6 +286,10 @@ async fn parse_gpt(disk: &mut Disk) -> Result<Option<Vec<ChunkInfo>>> {
268286
for partition in partitions {
269287
let begin = partition.byte_start as usize;
270288
let end = partition.byte_end as usize;
289+
info!(
290+
"Partition starting at {begin}, size {}",
291+
BytesFmt((end - begin) as u64)
292+
);
271293

272294
if pos < begin {
273295
chunks.push(ChunkInfo {

pixie-uefi/src/store.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use crate::{
22
os::{
33
error::{Error, Result},
4-
mpsc, TcpStream, UefiOS,
4+
mpsc, BytesFmt, TcpStream, UefiOS,
55
},
66
parse_disk, MIN_MEMORY,
77
};
88
use alloc::{rc::Rc, vec::Vec};
99
use core::{cell::RefCell, net::SocketAddrV4};
10+
use log::info;
1011
use lz4_flex::compress;
1112
use pixie_shared::{Chunk, Image, Offset, TcpRequest, UdpRequest, MAX_CHUNK_SIZE};
1213
use uefi::proto::console::text::Color;
@@ -69,6 +70,10 @@ pub async fn store(os: UefiOS, server_address: SocketAddrV4) -> Result<()> {
6970

7071
let mut disk = os.open_first_disk();
7172
let chunks = parse_disk::parse_disk(&mut disk).await?;
73+
info!(
74+
"Total size of chunks: {}",
75+
BytesFmt(chunks.iter().map(|x| x.size as u64).sum::<u64>())
76+
);
7277

7378
// Split up chunks.
7479
let mut final_chunks = Vec::<ChunkInfo>::new();

0 commit comments

Comments
 (0)