From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v3 pxar 2/6] format: add helper for payload header consistency checks
Date: Wed, 12 Jun 2024 10:23:56 +0200 [thread overview]
Message-ID: <20240612082400.110789-3-c.ebner@proxmox.com> (raw)
In-Reply-To: <20240612082400.110789-1-c.ebner@proxmox.com>
The helper method will be used to check the payload header being
consistent with what was encoded as paylaod reference for split
pxar archives.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 2:
- limit to be pub(crate)
src/format/mod.rs | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/format/mod.rs b/src/format/mod.rs
index 59d40e1..0648924 100644
--- a/src/format/mod.rs
+++ b/src/format/mod.rs
@@ -823,3 +823,24 @@ pub fn check_file_name(path: &Path) -> io::Result<()> {
Ok(())
}
}
+
+/// Check if provided header is of type payload and the headers content size matches given size.
+///
+/// Returns an [`io::Error`](std::io::Error) of type [`Other`](std::io::ErrorKind::Other) if that's
+/// not the case.
+pub(crate) fn check_payload_header_and_size(header: &Header, size: u64) -> io::Result<()> {
+ header.check_header_size()?;
+
+ if header.htype != PXAR_PAYLOAD {
+ io_bail!("unexpected header: expected {PXAR_PAYLOAD:x?} , got {header:x?}");
+ }
+
+ if header.content_size() != size {
+ io_bail!(
+ "encountered size mismatch: expected {}, got {size}",
+ header.content_size()
+ );
+ }
+
+ Ok(())
+}
--
2.39.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-06-12 8:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 8:23 [pbs-devel] [PATCH v3 pxar proxmox-backp 0/6] fix fuse mount performance for split archives Christian Ebner
2024-06-12 8:23 ` [pbs-devel] [PATCH v3 pxar 1/6] accessor: fix minor formatting issue Christian Ebner
2024-06-12 8:23 ` Christian Ebner [this message]
2024-06-12 8:23 ` [pbs-devel] [PATCH v3 pxar 3/6] format: add helper type ContentRange Christian Ebner
2024-06-12 9:27 ` Fabian Grünbichler
[not found] ` <CAFtnzVcG1CFUhs9WiePBLuDKihHQM8mOiuJKKjhFy+rmuxY4pw@mail.gmail.com>
2024-06-12 11:47 ` Fabian Grünbichler
2024-06-12 11:50 ` Christian Ebner
2024-06-12 8:23 ` [pbs-devel] [PATCH v3 pxar 4/6] decoder: move payload header check for split input Christian Ebner
2024-06-12 8:23 ` [pbs-devel] [PATCH v3 pxar 5/6] accessor: add payload checks for split archives Christian Ebner
2024-06-12 8:24 ` [pbs-devel] [PATCH v3 proxmox-backup 6/6] client: pxar: fix fuse mount performance " Christian Ebner
2024-06-12 9:27 ` [pbs-devel] partially-applied: [PATCH v3 pxar proxmox-backp 0/6] " Fabian Grünbichler
2024-06-12 13:18 ` [pbs-devel] " Christian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240612082400.110789-3-c.ebner@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.