MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / write_bat_entries

Method write_bat_entries

block/src/vhdx/vhdx_bat.rs:86–105  ·  view source on GitHub ↗

Routine for writing BAT entries to the disk

(
        f: &mut File,
        bat_offset: u64,
        bat_entries: &[BatEntry],
    )

Source from the content-addressed store, hash-verified

84
85 // Routine for writing BAT entries to the disk
86 pub fn write_bat_entries(
87 f: &mut File,
88 bat_offset: u64,
89 bat_entries: &[BatEntry],
90 ) -> Result<()> {
91 for i in 0..bat_entries.len() as u64 {
92 f.seek(SeekFrom::Start(bat_offset + i * size_of::<u64>() as u64))
93 .map_err(VhdxBatError::WriteBat)?;
94 let bat_entry = match bat_entries.get(i as usize) {
95 Some(entry) => entry.0,
96 None => {
97 return Err(VhdxBatError::InvalidBatEntry);
98 }
99 };
100
101 f.write_u64::<LittleEndian>(bat_entry)
102 .map_err(VhdxBatError::WriteBat)?;
103 }
104 Ok(())
105 }
106}

Callers

nothing calls this directly

Calls 3

lenMethod · 0.45
seekMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected