src/pxar/format_definitions.rs: move header type in PxarHeader and hash in PxarGoodbyeItem to top of struct

By this it is possible to read and check just the first u64 of the corresponding
structs in order to identify the items.
This is needed for the fuse implementation in order to get entries based on the
archive offset, used as inode.
Directories are referenced by the offset to the goodbye tail while other items
are referenced by the offset of the filename followed by the entry.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-09-03 14:14:31 +02:00 committed by Dietmar Maurer
parent 75933d1e83
commit f92e8266ae
1 changed files with 5 additions and 5 deletions

View File

@ -38,10 +38,10 @@ pub const PXAR_GOODBYE_TAIL_MARKER: u64 = 0x57446fa533702943;
#[derive(Debug, Endian)] #[derive(Debug, Endian)]
#[repr(C)] #[repr(C)]
pub struct PxarHeader { pub struct PxarHeader {
/// The size of the item, including the size of `PxarHeader`.
pub size: u64,
/// The item type (see `PXAR_` constants). /// The item type (see `PXAR_` constants).
pub htype: u64, pub htype: u64,
/// The size of the item, including the size of `PxarHeader`.
pub size: u64,
} }
#[derive(Endian)] #[derive(Endian)]
@ -64,6 +64,9 @@ pub struct PxarDevice {
#[derive(Endian)] #[derive(Endian)]
#[repr(C)] #[repr(C)]
pub struct PxarGoodbyeItem { pub struct PxarGoodbyeItem {
/// SipHash24 of the directory item name. The last GOODBYE item
/// uses the special hash value `PXAR_GOODBYE_TAIL_MARKER`.
pub hash: u64,
/// The offset from the start of the GOODBYE object to the start /// The offset from the start of the GOODBYE object to the start
/// of the matching directory item (point to a FILENAME). The last /// of the matching directory item (point to a FILENAME). The last
/// GOODBYE item points to the start of the matching ENTRY /// GOODBYE item points to the start of the matching ENTRY
@ -72,9 +75,6 @@ pub struct PxarGoodbyeItem {
/// The overall size of the directory item. The last GOODBYE item /// The overall size of the directory item. The last GOODBYE item
/// repeats the size of the GOODBYE item. /// repeats the size of the GOODBYE item.
pub size: u64, pub size: u64,
/// SipHash24 of the directory item name. The last GOODBYE item
/// uses the special hash value `PXAR_GOODBYE_TAIL_MARKER`.
pub hash: u64,
} }
/// Helper function to extract file names from binary archive. /// Helper function to extract file names from binary archive.