vhdx: Fixed and dynamic VHDx block device implementation
Microsoft’s VHDx block device format specification is implemented
here as a crate. This commit includes the implementation for the
fixed and dynamic formats, where the other format is known as
differencing. The vhdx_header.rs, vhdx_bat.rs, vhdx_metadata.rs
implements parser and manipulators for the VHDx header, Block
Allocation Table, and metadata, respectively, for the VHDx file.
The vhdx_io.rs implements read and write routines for the VHDx file.
The vhdx.rs implements the Vhdx structure, which provides the wrapper
functions for standard I/O operations like read, write, and seek.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Fazla Mehrab <akm.fazla.mehrab@intel.com>
2021-07-26 15:50:52 +00:00
|
|
|
// Copyright © 2021 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
use byteorder::{BigEndian, ByteOrder};
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
macro_rules! div_round_up {
|
|
|
|
($n:expr,$d:expr) => {
|
|
|
|
($n + $d - 1) / $d
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod vhdx;
|
|
|
|
mod vhdx_bat;
|
|
|
|
mod vhdx_header;
|
|
|
|
mod vhdx_io;
|
|
|
|
mod vhdx_metadata;
|
|
|
|
|
2022-04-20 08:47:41 +00:00
|
|
|
pub(crate) fn uuid_from_guid(buf: &[u8]) -> Uuid {
|
vhdx: Fixed and dynamic VHDx block device implementation
Microsoft’s VHDx block device format specification is implemented
here as a crate. This commit includes the implementation for the
fixed and dynamic formats, where the other format is known as
differencing. The vhdx_header.rs, vhdx_bat.rs, vhdx_metadata.rs
implements parser and manipulators for the VHDx header, Block
Allocation Table, and metadata, respectively, for the VHDx file.
The vhdx_io.rs implements read and write routines for the VHDx file.
The vhdx.rs implements the Vhdx structure, which provides the wrapper
functions for standard I/O operations like read, write, and seek.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Fazla Mehrab <akm.fazla.mehrab@intel.com>
2021-07-26 15:50:52 +00:00
|
|
|
// The first 3 fields of UUID are stored in Big Endian format, and
|
|
|
|
// the last 8 bytes are stored as byte array. Therefore, we read the
|
|
|
|
// first 3 fields in Big Endian format instead of Little Endian.
|
|
|
|
Uuid::from_fields_le(
|
|
|
|
BigEndian::read_u32(&buf[0..4]),
|
|
|
|
BigEndian::read_u16(&buf[4..6]),
|
|
|
|
BigEndian::read_u16(&buf[6..8]),
|
2022-04-20 08:47:41 +00:00
|
|
|
buf[8..16].try_into().unwrap(),
|
vhdx: Fixed and dynamic VHDx block device implementation
Microsoft’s VHDx block device format specification is implemented
here as a crate. This commit includes the implementation for the
fixed and dynamic formats, where the other format is known as
differencing. The vhdx_header.rs, vhdx_bat.rs, vhdx_metadata.rs
implements parser and manipulators for the VHDx header, Block
Allocation Table, and metadata, respectively, for the VHDx file.
The vhdx_io.rs implements read and write routines for the VHDx file.
The vhdx.rs implements the Vhdx structure, which provides the wrapper
functions for standard I/O operations like read, write, and seek.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Fazla Mehrab <akm.fazla.mehrab@intel.com>
2021-07-26 15:50:52 +00:00
|
|
|
)
|
|
|
|
}
|