32 bit checksums
This commit is contained in:
		@@ -1,6 +1,5 @@
 | 
			
		||||
use btrfs_parse_derive::AllVariants;
 | 
			
		||||
use btrfs_parse_derive::ParseBin;
 | 
			
		||||
use std::any::TypeId;
 | 
			
		||||
use std::fmt;
 | 
			
		||||
use std::error;
 | 
			
		||||
use std::ffi::CString;
 | 
			
		||||
@@ -97,6 +96,7 @@ pub enum Value {
 | 
			
		||||
	ExtentData(ExtentDataItem),
 | 
			
		||||
	Ref(Vec<RefItem>),
 | 
			
		||||
	RootRef(Vec<RootRefItem>),
 | 
			
		||||
	Checksum(Vec<u32>),
 | 
			
		||||
	Unknown(Vec<u8>),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -482,7 +482,7 @@ impl From<&str> for ParseError {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub trait ParseBin where Self: Sized {
 | 
			
		||||
pub trait ParseBin: Sized {
 | 
			
		||||
	fn parse_len(bytes: &[u8]) -> Result<(Self, usize), ParseError>;
 | 
			
		||||
 | 
			
		||||
	fn parse(bytes: &[u8]) -> Result<Self, ParseError> {
 | 
			
		||||
@@ -692,6 +692,13 @@ impl ParseBin for Node {
 | 
			
		||||
						}
 | 
			
		||||
						Value::RootRef(result)
 | 
			
		||||
					},
 | 
			
		||||
					ItemType::ExtentCsum => {
 | 
			
		||||
						let mut checksums: Vec<u32> = Vec::new();
 | 
			
		||||
						for i in 0..data_slice.len()/4 {
 | 
			
		||||
							checksums.push(u32::from_le_bytes(data_slice[i*4 .. (i+1)*4].try_into().unwrap()));
 | 
			
		||||
						}
 | 
			
		||||
						Value::Checksum(checksums)
 | 
			
		||||
					},
 | 
			
		||||
					_ =>
 | 
			
		||||
						Value::Unknown(Vec::from(data_slice)),
 | 
			
		||||
				};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user