From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 425321FF398 for ; Mon, 27 May 2024 16:33:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2430B4CAE; Mon, 27 May 2024 16:33:46 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Mon, 27 May 2024 16:32:18 +0200 Message-Id: <20240527143323.456002-5-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240527143323.456002-1-c.ebner@proxmox.com> References: <20240527143323.456002-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v7 pxar 04/69] format/examples: add header type `PXAR_PAYLOAD_REF` 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Introduces the header type `PXAR_PAYLOAD_REF` to mark regular file entry payloads, not encoded within the regular pxar archive but rather redirected to a dedicated payload output writer. It therefore substitutes the `PXAR_PAYLOAD` header type for these entries. The header marks the start and size for a `PayloadRef` typed object in the archive, storing the offset to the payload header offset in the payload stream of the dedicated payload output as well as the payload size. The `PayloadRef` provides the means to store, serialize and deserialize the entry. Signed-off-by: Christian Ebner --- changes since version 6: - patch reordered 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..5d7a652 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 optional payload file (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 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel