From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1345BBBF7A for ; Thu, 28 Mar 2024 13:37:36 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E781B9D15 for ; Thu, 28 Mar 2024 13:37:35 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 28 Mar 2024 13:37:34 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A1CF142900 for ; Thu, 28 Mar 2024 13:37:34 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Thu, 28 Mar 2024 13:36:11 +0100 Message-Id: <20240328123707.336951-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328123707.336951-1-c.ebner@proxmox.com> References: <20240328123707.336951-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.031 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mk-format-hashes.rs, mod.rs] Subject: [pbs-devel] [PATCH v3 pxar 02/58] format/examples: add PXAR_PAYLOAD_REF entry header X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Mar 2024 12:37:36 -0000 Introduces a new PXAR_PAYLOAD_REF entry header to mark regular file payloads which are not encoded within the regular pxar archive stream but rather redirected to a different output stream. The corresponding header marks the entry containing all the necessary data for restoring the actual payload from the dedicated payload stream. Further, add a dedicated type to store offset and size as well as the methods to serialize its values for encoding. Signed-off-by: Christian Ebner --- changes since version 2: - Added struct and serialization method examples/mk-format-hashes.rs | 5 +++++ src/format/mod.rs | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/examples/mk-format-hashes.rs b/examples/mk-format-hashes.rs index 6e00654..83adb38 100644 --- a/examples/mk-format-hashes.rs +++ b/examples/mk-format-hashes.rs @@ -41,6 +41,11 @@ const CONSTANTS: &[(&str, &str, &str)] = &[ "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", diff --git a/src/format/mod.rs b/src/format/mod.rs index bfea9f6..1fda535 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -22,6 +22,7 @@ //! * `FCAPS` -- file capability in Linux disk format //! * `QUOTA_PROJECT_ID` -- the ext4/xfs quota project ID //! * `PAYLOAD` -- file contents, if it is one +//! * `PAYLOAD_REF` -- reference to file offset in split payload archive (introduced in v2) //! * `SYMLINK` -- symlink target, if it is one //! * `DEVICE` -- device major/minor, if it is a block/char device //! @@ -99,6 +100,8 @@ pub const PXAR_QUOTA_PROJID: u64 = 0xe07540e82f7d1cbb; pub const PXAR_HARDLINK: u64 = 0x51269c8422bd7275; /// Marks the beginning of the payload (actual content) of regular files pub const PXAR_PAYLOAD: u64 = 0x28147a1b0b7c1a25; +/// Marks the beginning of a payload reference for regular files +pub const PXAR_PAYLOAD_REF: u64 = 0x419d3d6bc4ba977e; /// Marks item as entry of goodbye table pub const PXAR_GOODBYE: u64 = 0x2fec4fa642d5731d; /// The end marker used in the GOODBYE object @@ -152,6 +155,7 @@ impl Header { PXAR_QUOTA_PROJID => size_of::() as u64, PXAR_ENTRY => size_of::() as u64, PXAR_PAYLOAD | PXAR_GOODBYE => u64::MAX - (size_of::() as u64), + PXAR_PAYLOAD_REF => size_of::() as u64, _ => u64::MAX - (size_of::() as u64), } } @@ -192,6 +196,7 @@ impl Display for Header { PXAR_QUOTA_PROJID => "QUOTA_PROJID", PXAR_ENTRY => "ENTRY", PXAR_PAYLOAD => "PAYLOAD", + PXAR_PAYLOAD_REF => "PAYLOAD_REF", PXAR_GOODBYE => "GOODBYE", _ => "UNKNOWN", }; @@ -723,6 +728,21 @@ impl GoodbyeItem { } } +/// References a regular file payload found in a separated payload archive +#[derive(Clone, Debug, Endian)] +pub struct PayloadRef { + pub offset: u64, + pub size: u64, +} + +impl PayloadRef { + pub(crate) fn data(&self) -> Vec { + let mut data = self.offset.to_le_bytes().to_vec(); + data.append(&mut self.size.to_le_bytes().to_vec()); + data + } +} + /// Hash a file name for use in the goodbye table. pub fn hash_filename(name: &[u8]) -> u64 { use std::hash::Hasher; -- 2.39.2