5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2024-12-21 17:33:52 +03:00
Commit Graph

285 Commits

Author SHA1 Message Date
Fabian Grünbichler
16773abdda update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-11-26 11:13:08 +01:00
Fabian Grünbichler
410f326a08 bump version to 0.12.1-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-11-26 11:10:34 +01:00
Fabian Grünbichler
47d9fc75f2 build: add dsc target
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-11-26 11:10:06 +01:00
Fabian Grünbichler
cafb4d24b0 run cargo fmt
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-11-26 10:31:10 +01:00
Christian Ebner
ae6c050a4f decoder: fix incorrect accounting for header in payload input
Payload entries are separated by headers of type PAYLOAD within the
payload stream of split pxar archives, used for consistency checks
when accessing the file contents via a reader instance.

Commit 5b8204d0 moved these consistency checks, so they only happen
when actually accessing the content, thereby drastically improving
performance when navigating contents via the metadata archive.

The commit however also incorrectly increased the `Decoder`s
`payload_consumed` field by the size of the header, in case the file
payload has not been accessed by the `content_reader`.

As this filed is used to account for consumed bytes while sequentially
reading to possibly skip over entries, this leads to incorrectly
skipping of bytes in the stream (less than required). The main
manifestation being that a pxar extract with provided match pattern
failed.

Therefore, drop the incorrect accounting of the payload header.

Fixes: 5b8204d0 ("decoder: move payload header check for split input")

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-26 10:27:32 +01:00
Wolfgang Bumiller
0b89a316c9 doc fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-30 15:52:41 +02:00
Wolfgang Bumiller
aad6fb706c fixup upload command
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:35:49 +02:00
Wolfgang Bumiller
efd3af01f3 bump version to 0.12.0-2 (released)
previous bump was still marked as UNRELEASED and uploaded to wrong
repo.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:34:58 +02:00
Wolfgang Bumiller
6b767d07d6 build system upgrade
and detect upload-distro...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:34:34 +02:00
Wolfgang Bumiller
9a57a081f3 bump version to 0.12.0-2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:08:21 +02:00
Wolfgang Bumiller
6a217790f8 drop bitflags dependency
we aren't using it...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:06:56 +02:00
Fabian Grünbichler
8f1e415834 move .cargo/config to .cargo/config.toml
the old location has been deprecated for a while, and rustc 1.78 will start to warn about it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-20 12:38:23 +02:00
Fabian Grünbichler
2294fb923c update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-17 10:19:21 +02:00
Fabian Grünbichler
ebe402c01c bump version to 0.12.0-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-14 12:50:49 +02:00
Christian Ebner
c13df75243 accessor: adapt and restrict contents access
Add checks for split variant inputs when accessing the payload
contents via the accessor instance. Both cases, accessing via the
safe `contents` method and via the previousely unsafe
`open_contents_at_range` call are covered.

Reduce possible misuse by wrapping the current plain content range
into an opaque `ContentRange` type with an additional optional
payload reference field to check consistency between the payload
reference encoded in the metadata archive and the payload header'
found in the payload data archive.

Because of the additional type wrapping and the payload header check,
the `open_contents_at_range` is considered safe now, dropping the
previously unsafe implementation.
The corresponding interfaces have been adapted accordingly.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-13 09:24:35 +02:00
Christian Ebner
d0dda0eda4 tests: adapt tests to decoder interface changes
The `Decoder`s `contents` method call can fail because of an added
consistency check when using split variant inputs.

Therefore, the additional error has to be handled by the callers.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-13 09:24:35 +02:00
Fabian Grünbichler
10645277ed remove unnecessary unsafe in test
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-12 11:26:06 +02:00
Christian Ebner
5b8204d09b decoder: move payload header check for split input
The payload entries in the payload output for split pxar archives are
separated by payload headers, which allow to perform consistency
checks for the payload references encoded in the metadata archive.

Currently, this consistency check is performed right after reading the
entry in the metadata archive, which however has the downside that the
payload has to be fetched and decoded just for this consistency check.
This greatly impacts performance when accessing a metadata archive
with attached payload input reader, e.g. in the fuse implementation to
mount pxar archives, being especially severe when accessed over the
network in combination with a remote chunk reader as the Proxmox
Backup Server does.

Therefore, move this check to the contents reader instantiation
instead and add an additional flag to the decoder's `InPayload` state.

Getting the decoder now needs to be async and the method must return
an error when the check fails.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-12 11:24:56 +02:00
Christian Ebner
e67489f059 format: add helper for payload header consistency checks
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>
2024-06-12 10:53:20 +02:00
Christian Ebner
d121b920de accessor: fix minor formatting issue
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-12 10:53:20 +02:00
Fabian Grünbichler
5d232d7282 update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-10 13:45:23 +02:00
Fabian Grünbichler
cd97f8d0f4 bump version to 0.11.1-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-10 13:36:27 +02:00
Fabian Grünbichler
9ff9d1c265 cargo fmt
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-10 13:35:48 +02:00
Fabian Grünbichler
60068f0391 prelude: drop OsStr implementation
this was leftover and not does not make sense with the current version of the
Prelude, which is an opaque blob of bytes.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-10 13:35:17 +02:00
Fabian Grünbichler
032a7b235d update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-05 16:04:41 +02:00
Fabian Grünbichler
066625f1df bump version to 0.11.0-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-05 16:02:48 +02:00
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
Christian Ebner
0983094c87 format/encoder/decoder: new pxar entry type Version
Introduces a new pxar format entry type `Version` and the associated
encoder and decoder methods. The format version entry is only allowed
once, as the first entry of the pxar archive, marked with a
`PXAR_FORMAT_VERSION` header followed by the encoded version number.
If not present, the default format version 1 is assumed as encoding
format for the archive.

The entry allows to early detect incompatibility with an encoded
archive and bail or switch mode based on the encountered version.

The format version entry 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
Christian Ebner
ef8b723734 format: add payload stream start marker
Mark the beginning of the payload stream with a magic number. Allows for
version and file type detection.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
d51db63953 encoder/format: finish payload stream with marker
Mark the end of the optional payload stream, this makes sure that at
least some bytes are written to the stream (as empty archives are not
allowed by the proxmox backup server) and possible injected chunks
must be consumed.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
7e8af7b6e0 encoder: add payload advance capability
Allows to advance the payload writer position by a given size.
This is used to update the encoders payload input position when
injecting reused chunks for files with unchanged metadata.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
2c1daa75fa encoder: add payload position capability
Allows to read the current payload offset from the dedicated payload
input stream. This is required to get the current offset for calculation
of forced boundaries in the proxmox-backup-client, when injecting reused
payload chunks into the payload stream.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
15fbb28319 encoder: add payload reference capability
Allows to encode regular files with a payload reference within a
separate payload archive rather than encoding the payload within the
regular archive.

Following the PXAR_PAYLOAD_REF marked header, the payload offset and
size are encoded.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
1c30a6547b decoder: set payload input range when decoding via accessor
When accessing the file contents via the sequential file restore
the range of the payload contents cannot be inferred a-priori but need
to be calculated based on the payload references encountered during
decoding.

Extending the `SeqRead` trait by the method `update_range` allows to
set the range in the payload reader instance by implementing the
method for `SeqReadAtAdapter`, thereby setting the correct content
range to be accessed.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
3ee98e1072 decoder/accessor: allow for split input stream variant
When a pxar archive was encoded using the split stream output
variant, access to the payload of regular files has to be redirected
to the corresponding dedicated input.

Allow to pass the split input variant to the decoder and accessor
instances to handle the split streams accordingly and decode split
stream archives.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
99d4f646be encoder: allow split output writer for archive creation
During regular pxar archive encoding, the payload of regular files is
written as part of the archive.

This patch introduces functionality to instead attach a writer variant
with a split payload writer instance to redirect the payload to a
different output.
The separation of data and metadata streams allows for efficient
reuse of payload data by referencing the payload writer byte offset,
without having to reencode it.

Whenever the payload of regular files is redirected to a dedicated
output writer, encode a payload reference header followed by the
required data to locate the data, instead of adding the regular payload
header followed by the encoded payload to the archive.

This is in preparation for reusing payload chunks for unchanged files
of backups created via the proxmox-backup-client.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
2a7b789bbd decoder: add method to read payload references
This is in preparation for reading payloads from a dedicated payload
input stream.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 14:39:11 +02:00
Christian Ebner
d3447d0149 format/examples: add header type PXAR_PAYLOAD_REF
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 <c.ebner@proxmox.com>
2024-05-23 14:39:11 +02:00
Christian Ebner
48431e5e38 encoder: move to stack based state tracking
In preparation for the proxmox-backup-client look-ahead caching,
where a passing around of different encoder instances with internal
references is not feasible.

Instead of creating a new encoder instance for each directory level
and keeping references to the parent state, use an internal stack.
Adds additional helper functions to solve borrow issues, when both
the state and writers have to be accessed by a mutable reference.

This is a breaking change in the pxar library API.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 14:39:11 +02:00
Christian Ebner
a79ae33c14 lib: add type for input/output variant differentiation
Introduce an enum which stores 2 different possible variants of
inputs or outputs to be passed to encoder and decoder/accessor
instances, depending whether to read/write a fully self contained
pxar archive or whether to split off the payload stream into a
separate input/output.

Co-authored-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 11:26:23 +02:00
Christian Ebner
e5b9854989 decoder: factor out skip part from skip_entry
Make the skip part reusable for a different input.

In preparation for skipping payload paddings in a separated input.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 11:26:08 +02:00
Fabian Grünbichler
675ecff32f encoder: fix some more typos/phrasing
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-04-03 11:11:40 +02:00
Christian Ebner
237917b741 encoder: fix two typos in comments
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-04-03 11:09:26 +02:00
Christian Ebner
f5be8e5c6d format/examples: Fix typo in PXAR_PAYLOAD description
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-02-28 19:09:31 +01:00
Wolfgang Bumiller
fab6470854 doc fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-04 13:11:03 +02:00
Max Carrara
4355e8e619 decoder: aio: Make TokioReader public
This exposes `decoder::aio::TokioReader<T>` in a similar manner to
`decoder::sync::StandardReader<T>`, which is necessary if one wants
to remain generic over `T: tokio::io::AsyncRead`, e.g.:

> struct FooDecoder<T: tokio::io::AsyncRead> {
>    decoder: aio::Decoder<aio::TokioReader<T>>,
> }

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2023-08-04 13:09:09 +02:00
Fabian Grünbichler
de472e826d d/changelog: fix typo
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-07-31 15:45:17 +02:00
Christian Ebner
00d36bf97b format: Document source of format const values
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2023-05-17 11:27:08 +02:00
Wolfgang Bumiller
6ad046f9f9 drop custom poll_fn, require rust 1.64
this was added to std in 1.64

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-01-13 13:37:43 +01:00
Fabian Grünbichler
375865b729 update d/control
after debcargo update

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-09 13:33:47 +01:00