backup/dynamic_index: use static assertion, fix size
The type was sized properly but the number was still wrong, fixed this. TODO! Once unions with non-Copy values are stable make this a `union { full: [u8; 4096], data: TheActualHeader }`; Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
bcb664cb69
commit
990b930f22
|
@ -27,9 +27,14 @@ pub struct DynamicIndexHeader {
|
|||
pub ctime: u64,
|
||||
/// Sha256 over the index ``SHA256(offset1||digest1||offset2||digest2||...)``
|
||||
pub index_csum: [u8; 32],
|
||||
reserved: [u8; 4030], // overall size is one page (4096 bytes)
|
||||
reserved: [u8; 4032], // overall size is one page (4096 bytes)
|
||||
}
|
||||
|
||||
proxmox::tools::static_assert_size!(DynamicIndexHeader, 4096);
|
||||
// TODO: Once non-Copy unions are stabilized, use:
|
||||
// union DynamicIndexHeader {
|
||||
// reserved: [u8; 4096],
|
||||
// pub data: DynamicIndexHeaderData,
|
||||
// }
|
||||
|
||||
pub struct DynamicIndexReader {
|
||||
_file: File,
|
||||
|
@ -74,9 +79,6 @@ impl DynamicIndexReader {
|
|||
|
||||
let header_size = std::mem::size_of::<DynamicIndexHeader>();
|
||||
|
||||
// todo: use static assertion when available in rust
|
||||
if header_size != 4096 { bail!("got unexpected header size"); }
|
||||
|
||||
let buffer = file.read_exact_allocated(header_size)?;
|
||||
|
||||
let header = unsafe { &* (buffer.as_ptr() as *const DynamicIndexHeader) };
|
||||
|
|
Loading…
Reference in New Issue