5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2024-12-22 21:33:50 +03:00
pxar/examples/mk-format-hashes.rs
Christian Ebner be5d68aa8a format/encoder/decoder: new pxar entry type Prelude
Introduces a new pxar format entry type `Prelude` and the associated
encoder and decoder methods.
A prelude starts with header marker `PXAR_PRELUDE` followed by raw
byte content, used to store additional metadata associated with the
pxar archive, e.g. command line arguments passed on archive creation.

The prelude's content has no fixed encoding format but is stored as
an raw, arbitrary byte slice. A prelude entry is encoded right after
a pxar format version entry, both being encoded in the metadata
archive in case of an archive with dedicated payload output.

The prelude is not backwards compatible to pxar format version 1.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00

90 lines
2.7 KiB
Rust

use pxar::format::hash_filename;
const CONSTANTS: &[(&str, &str, &str)] = &[
(
"Pxar format version entry, fallback to version 1 if not present",
"PXAR_FORMAT_VERSION",
"__PROXMOX_FORMAT_VERSION__",
),
(
"Beginning of an entry (current version).",
"PXAR_ENTRY",
"__PROXMOX_FORMAT_ENTRY_V2__",
),
(
"Previous version of the entry struct",
"PXAR_ENTRY_V1",
"__PROXMOX_FORMAT_ENTRY__",
),
("", "PXAR_PRELUDE", "__PROXMOX_FORMAT_PRELUDE__"),
("", "PXAR_FILENAME", "__PROXMOX_FORMAT_FILENAME__"),
("", "PXAR_SYMLINK", "__PROXMOX_FORMAT_SYMLINK__"),
("", "PXAR_DEVICE", "__PROXMOX_FORMAT_DEVICE__"),
("", "PXAR_XATTR", "__PROXMOX_FORMAT_XATTR__"),
("", "PXAR_ACL_USER", "__PROXMOX_FORMAT_ACL_USER__"),
("", "PXAR_ACL_GROUP", "__PROXMOX_FORMAT_ACL_GROUP__"),
("", "PXAR_ACL_GROUP_OBJ", "__PROXMOX_FORMAT_ACL_GROUP_OBJ__"),
("", "PXAR_ACL_DEFAULT", "__PROXMOX_FORMAT_ACL_DEFAULT__"),
(
"",
"PXAR_ACL_DEFAULT_USER",
"__PROXMOX_FORMAT_ACL_DEFAULT_USER__",
),
(
"",
"PXAR_ACL_DEFAULT_GROUP",
"__PROXMOX_FORMAT_ACL_DEFAULT_GROUP__",
),
("", "PXAR_FCAPS", "__PROXMOX_FORMAT_FCAPS__"),
("", "PXAR_QUOTA_PROJID", "__PROXMOX_FORMAT_QUOTA_PROJID__"),
(
"Marks item as hardlink",
"PXAR_HARDLINK",
"__PROXMOX_FORMAT_HARDLINK__",
),
(
"Marks the beginning of the payload (actual content) of regular files",
"PXAR_PAYLOAD",
"__PROXMOX_FORMAT_PXAR_PAYLOAD__",
),
(
"Marks the beginning of a payload reference for regular files",
"PXAR_PAYLOAD_REF",
"__PROXMOX_FORMAT_PXAR_PAYLOAD_REF__",
),
(
"Marks item as entry of goodbye table",
"PXAR_GOODBYE",
"__PROXMOX_FORMAT_GOODBYE__",
),
(
"The end marker used in the GOODBYE object",
"PXAR_GOODBYE_TAIL_MARKER",
"__PROXMOX_FORMAT_PXAR_GOODBYE_TAIL_MARKER__",
),
(
"The start marker used in the separate payload stream",
"PXAR_PAYLOAD_START_MARKER",
"__PROXMOX_FORMAT_PXAR_PAYLOAD_START_MARKER__",
),
(
"The end marker used in the separate payload stream",
"PXAR_PAYLOAD_TAIL_MARKER",
"__PROXMOX_FORMAT_PXAR_PAYLOAD_TAIL_MARKER__",
),
];
fn main() {
println!("// Generated by `cargo run --example mk-format-hashes`");
for constant in CONSTANTS {
if !constant.0.is_empty() {
println!("/// {}", constant.0);
}
println!(
"pub const {}: u64 = 0x{:016x};",
constant.1,
hash_filename(constant.2.as_bytes()),
)
}
}