backup/image_index.rs: use little endian

This commit is contained in:
Dietmar Maurer 2019-01-04 08:45:04 +01:00
parent 4968bc3ac0
commit 48d0d35688
1 changed files with 8 additions and 8 deletions

View File

@ -62,14 +62,14 @@ impl <'a> ImageIndexReader<'a> {
bail!("got unknown magic number for {:?}", path); bail!("got unknown magic number for {:?}", path);
} }
let version = u32::from_be(header.version); let version = u32::from_le(header.version);
if version != 1 { if version != 1 {
bail!("got unsupported version number ({})", version); bail!("got unsupported version number ({})", version);
} }
let size = u64::from_be(header.size) as usize; let size = u64::from_le(header.size) as usize;
let ctime = u64::from_be(header.ctime); let ctime = u64::from_le(header.ctime);
let chunk_size = u64::from_be(header.chunk_size) as usize; let chunk_size = u64::from_le(header.chunk_size) as usize;
let index_size = ((size + chunk_size - 1)/chunk_size)*32; let index_size = ((size + chunk_size - 1)/chunk_size)*32;
@ -200,10 +200,10 @@ impl <'a> ImageIndexWriter<'a> {
let header = unsafe { &mut * (buffer.as_ptr() as *mut ImageIndexHeader) }; let header = unsafe { &mut * (buffer.as_ptr() as *mut ImageIndexHeader) };
header.magic = *b"PROXMOX-IIDX"; header.magic = *b"PROXMOX-IIDX";
header.version = u32::to_be(1); header.version = u32::to_le(1);
header.ctime = u64::to_be(ctime); header.ctime = u64::to_le(ctime);
header.size = u64::to_be(size as u64); header.size = u64::to_le(size as u64);
header.chunk_size = u64::to_be(chunk_size as u64); header.chunk_size = u64::to_le(chunk_size as u64);
header.uuid = *uuid.as_bytes(); header.uuid = *uuid.as_bytes();
file.write_all(&buffer)?; file.write_all(&buffer)?;