[thin_check (rust)] factor out device detail
This commit is contained in:
parent
66b6a1ba48
commit
a88ae3ca18
@ -549,6 +549,8 @@ pub trait NodeVisitor<V: Unpack> {
|
|||||||
keys: &[u64],
|
keys: &[u64],
|
||||||
values: &[V],
|
values: &[V],
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
|
fn end_walk(&self) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -758,6 +760,7 @@ impl BTreeWalker {
|
|||||||
path.push(b.loc);
|
path.push(b.loc);
|
||||||
let r = self.walk_node_(path, visitor, kr, b, is_root);
|
let r = self.walk_node_(path, visitor, kr, b, is_root);
|
||||||
path.pop();
|
path.pop();
|
||||||
|
visitor.end_walk()?;
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,8 +846,9 @@ where
|
|||||||
V: Unpack,
|
V: Unpack,
|
||||||
{
|
{
|
||||||
path.push(b.loc);
|
path.push(b.loc);
|
||||||
let r = walk_node_threaded_(w, path, pool, visitor, kr, b, is_root);
|
let r = walk_node_threaded_(w, path, pool, visitor.clone(), kr, b, is_root);
|
||||||
path.pop();
|
path.pop();
|
||||||
|
visitor.end_walk()?;
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -992,6 +996,10 @@ impl<V: Unpack + Copy> NodeVisitor<V> for ValueCollector<V> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn end_walk(&self) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn btree_to_map<V: Unpack + Copy>(
|
pub fn btree_to_map<V: Unpack + Copy>(
|
||||||
@ -1051,6 +1059,10 @@ impl<V: Unpack + Clone> NodeVisitor<V> for ValuePathCollector<V> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn end_walk(&self) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn btree_to_map_with_path<V: Unpack + Copy>(
|
pub fn btree_to_map_with_path<V: Unpack + Copy>(
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use nom::{number::complete::*, IResult};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -14,6 +13,7 @@ use crate::pdata::space_map::*;
|
|||||||
use crate::pdata::unpack::*;
|
use crate::pdata::unpack::*;
|
||||||
use crate::report::*;
|
use crate::report::*;
|
||||||
use crate::thin::block_time::*;
|
use crate::thin::block_time::*;
|
||||||
|
use crate::thin::device_detail::*;
|
||||||
use crate::thin::superblock::*;
|
use crate::thin::superblock::*;
|
||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
@ -58,38 +58,9 @@ impl NodeVisitor<BlockTime> for BottomLevelVisitor {
|
|||||||
data_sm.inc(start, len).unwrap();
|
data_sm.inc(start, len).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------
|
fn end_walk(&self) -> btree::Result<()> {
|
||||||
|
Ok(())
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
pub struct DeviceDetail {
|
|
||||||
pub mapped_blocks: u64,
|
|
||||||
pub transaction_id: u64,
|
|
||||||
pub creation_time: u32,
|
|
||||||
pub snapshotted_time: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Unpack for DeviceDetail {
|
|
||||||
fn disk_size() -> u32 {
|
|
||||||
24
|
|
||||||
}
|
|
||||||
|
|
||||||
fn unpack(i: &[u8]) -> IResult<&[u8], DeviceDetail> {
|
|
||||||
let (i, mapped_blocks) = le_u64(i)?;
|
|
||||||
let (i, transaction_id) = le_u64(i)?;
|
|
||||||
let (i, creation_time) = le_u32(i)?;
|
|
||||||
let (i, snapshotted_time) = le_u32(i)?;
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
i,
|
|
||||||
DeviceDetail {
|
|
||||||
mapped_blocks,
|
|
||||||
transaction_id,
|
|
||||||
creation_time,
|
|
||||||
snapshotted_time,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +97,10 @@ impl<'a> NodeVisitor<u32> for OverflowChecker<'a> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn end_walk(&self) -> btree::Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
37
src/thin/device_detail.rs
Normal file
37
src/thin/device_detail.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use crate::pdata::unpack::*;
|
||||||
|
use nom::{number::complete::*, IResult};
|
||||||
|
|
||||||
|
//------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct DeviceDetail {
|
||||||
|
pub mapped_blocks: u64,
|
||||||
|
pub transaction_id: u64,
|
||||||
|
pub creation_time: u32,
|
||||||
|
pub snapshotted_time: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Unpack for DeviceDetail {
|
||||||
|
fn disk_size() -> u32 {
|
||||||
|
24
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unpack(i: &[u8]) -> IResult<&[u8], DeviceDetail> {
|
||||||
|
let (i, mapped_blocks) = le_u64(i)?;
|
||||||
|
let (i, transaction_id) = le_u64(i)?;
|
||||||
|
let (i, creation_time) = le_u32(i)?;
|
||||||
|
let (i, snapshotted_time) = le_u32(i)?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
i,
|
||||||
|
DeviceDetail {
|
||||||
|
mapped_blocks,
|
||||||
|
transaction_id,
|
||||||
|
creation_time,
|
||||||
|
snapshotted_time,
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------
|
@ -1,4 +1,5 @@
|
|||||||
pub mod block_time;
|
pub mod block_time;
|
||||||
|
pub mod device_detail;
|
||||||
pub mod superblock;
|
pub mod superblock;
|
||||||
pub mod check;
|
pub mod check;
|
||||||
pub mod xml;
|
pub mod xml;
|
||||||
|
Loading…
Reference in New Issue
Block a user