Commit Graph

200 Commits

Author SHA1 Message Date
Christian Ebner e66621182b src/pxar/decoder.rs: impl lookup for `Decoder`
Allows to lookup an entry in a directory based on the provided `DirectoryEntry`.
This is needed to navigate the filesystem based on `DirectoryEntry`s and similar
to the find_goodbye_entry() function in src/pxar/fuse.rs

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-11-06 10:00:41 +01:00
Christian Ebner fb2554de29 src/pxar/decoder.rs: fix wrong filename check for Decoder::restore()
As it turns out the original implementation was correct and the start in
`DirectoryEntry` points to the `PxarEntry` and not as wrongly stated to the
filename.
This reverts the incorrect code and adds comments to the fields clarifying this.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-11-06 09:59:35 +01:00
Christian Ebner 33ad183a40 src/pxar/decoder.rs: allow to pass match pattern to restore
In order to partially restore the archive starting from the directory provided as
parameter.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-11-05 14:19:09 +01:00
Christian Ebner 5e8d600c71 src/pxar/decoder.rs: fix issue with restore
`Decoder::restore()` calls the `SequentialDecoder::restore()` which expects to
encounter a `PxarEntry` at first. But the start of `DirectoryEntry` points to the
filename (except for the root dir), so skip over it.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-11-05 14:18:29 +01:00
Christian Ebner 9708b2d98c src/pxar/fuse.rs: refactor Iterator: use find() instead of position()
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-11-04 13:59:16 +01:00
Dietmar Maurer 62ee2eb405 avoid some clippy warnings 2019-10-26 11:42:05 +02:00
Dietmar Maurer 834a2f95a0 avoid some clippy warnings 2019-10-25 18:44:51 +02:00
Dietmar Maurer f58f426e86 src/pxar/binary_search_tree.rs: allow(clippy::many_single_char_names) 2019-10-25 18:22:19 +02:00
Christian Ebner 8abd12f1f3 pxar: decoder: cleanup un-needed Decoder::get_dir()
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-23 08:02:23 +02:00
Christian Ebner 9c25c0330a pxar: fuse: optimize fuse readdir callback
The expensive call to Decoder::read_directory_entry() can be omitted as
Decoder::attributes() returns all the information the fuse response needs.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-23 08:02:03 +02:00
Dietmar Maurer ffe171c5db src/pxar/encoder.rs: avoid duplicate check for MAX_DIRECTORY_ENTRIES
Simply by reordering code.
2019-10-23 07:55:56 +02:00
Christian Ebner 62d123e50a pxar: add functionality to pass exclude MatchPatterns on create
This exposes the option to pass a list of exclude MatchPattern via the
'--exclude' option.
The list is encoded as file '.pxarexclude-cli' in the archives root directory.
If such a file is present in the filesystem, it is skipped and not included in
the archive in order to avoid conflicting information.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-23 07:31:49 +02:00
Christian Ebner ba8165c607 pxar: encoder: add encode_pxar_exclude_cli() function.
This provides the functionality needed to encode MatchPatterns passed on the cli
in the root directory.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-23 07:30:30 +02:00
Dietmar Maurer 920243b12d pxar: simplify MatchPattern::to_bytes 2019-10-23 07:29:02 +02:00
Christian Ebner e50a90e010 pxar: Implement to_bytes() for MatchPattern in order to write them to file.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-23 07:21:11 +02:00
Christian Ebner 40c9ff9d81 src/pxar/encoder.rs: include .pxarexclude files into the catalog
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-17 10:25:20 +02:00
Christian Ebner 20feec9fac pxar: fuse: include nsec information in stat
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-17 10:24:13 +02:00
Christian Ebner d388e244f5 src/pxar/fuse.rs: make verbose flag independent from deamonize by adding this as new flag
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-20 08:00:04 +02:00
Christian Ebner e717e9a3bf src/pxar/fuse.rs: refactor Session::new()
and add Session::from_decoder() in order to be able to create a fuse session
with a `Decoder` given as argument.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-20 07:59:51 +02:00
Christian Ebner 946b72a6b2 src/pxar/fuse.rs: introduce `Context` in order to add caching.
This patch introduces `Context` to hold the decoder, ino_offset and caches for
the attributes and the goodbye table.
By caching, certain callbacks can be handled without the need to read additional
data via the decoder, which improves performance.
The searching of the goodbye table is refactored as well, avoiding recursive
function calls in case of a hash collision.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-20 07:56:40 +02:00
Christian Ebner 1c93182371 src/pxar/decoder.rs: fix bug in decoder read
`offset` points to the `PXAR_FILENAME`, therefore read the filename before
the `PXAR_ENTRY`.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-20 07:54:16 +02:00
Christian Ebner 0e20b336e1 pxar: fuse: avoid possible hash collision in lookup by additional checking against filename
The hash of the filename in the goodbye table items allows to quickly compare to
a hashed filename.
Unfortunately, a matching hash is no garantee for matching filenames as hash
collisions are possible.
This patch fixes such possible collisions by further checking the filenames once
a matching hash has been found.
This introduces no significant extra cost (except for the filename comparison)
for cases with matching hashes, as the lookup call has to seek and read the file
attributes (including the filename) anyway.
In cases with hash collision, the next matching item is read and treaded
analogously (what means we need at least one extra seek).
As collisions should be not that frequent, this should be an acceptable penalty.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-16 10:22:22 +02:00
Wolfgang Bumiller 653b1ca10e some clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-09-11 12:14:05 +02:00
Christian Ebner 03310bea12 src/pxar/fuse.rs: s/Buf/ReplyBuf/ and s/BufState/ReplyBufState/
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-11 11:27:18 +02:00
Christian Ebner 48cc1b8234 src/pxar/fuse.rs: refactor stat and fix i-node mapping
The functionality of stat is split into smaller sub-functions, which allows
to reuse them more flexible, as the code flow is similar but not always the same.
By this, the ugly and incorrect re-setting of the i-node in the lookup callback
function is avoided.
The correct i-node is now calculated beforehand and stat simply creates a
`libc::stat` struct from the provided parameters.
Also, this fixes incorrect i-node assignments in the readdir callback function.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-11 11:26:55 +02:00
Christian Ebner 22eaa905a4 src/pxar/fuse.rs: impl readdir callback for fuse
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 11:38:58 +02:00
Christian Ebner 1652192f4d src/pxar/fuse.rs: impl readlink callback for fuse
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 11:38:48 +02:00
Christian Ebner 3710b23db5 src/pxar/decoder.rs: read_link has to read filename before entry.
The offset points to the start of the item, which is the filename

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 11:36:04 +02:00
Christian Ebner 7eb9848ba7 src/pxar/fuse.rs: impl opendir callback for fuse
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 11:35:13 +02:00
Christian Ebner 2c5fd378d3 src/pxar/fuse.rs: impl read callback for fuse
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 11:34:55 +02:00
Christian Ebner 97e4db9dd5 src/pxar/fuse.rs: impl open callback for fuse
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 11:34:18 +02:00
Christian Ebner b00689254a src/pxar/fuse.rs: impl lookup callback for fuse
The lookup call checks if the given filename is found in the directory referenced
by the i-node by calclulating the filenames hash and looking it up in the
directories goodbye table.
If found, the entries parameters are returned.
In order to be able to lookup the parent offset by a given file offset in the
readdir callback, this also stores the corresponding values in a HashMap.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 10:54:23 +02:00
Christian Ebner 1443927c02 src/pxar/decoder.rs: correctly handle hardlinks in `Decoder`s attribute function
If the attributes are then returned by seeking to the new offset.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 10:46:39 +02:00
Christian Ebner d00097a0e6 src/pxar/decoder.rs: split functionality of list_dir into list_dir and goodbye_table
In order to read the contents of the goodbye table while keeping the
functionality of list_dir in place as is.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 10:46:29 +02:00
Christian Ebner ac12570e99 src/pxar/decoder.rs: make read_directory_entry usable by fuse
... and thereby allow it to read a single directory entry based on the
start and end archive offsets.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 10:32:48 +02:00
Christian Ebner 3f7f4f34be src/pxar/decoder.rs: remove `DirectoryEntry` start_offset and end_offset functions
... as they are not needed with the latest iteration of the fuse callback
function impl (which never made it into the repos).

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 10:30:45 +02:00
Christian Ebner ac30bc3326 src/pxar/decoder.rs: correctly read, check and skip filename
The previous implementation simply skipped over `size` bytes, which is not
correct as size includes also the header.
By relying on `SequentailDecoder`s read_filename function, this is correctly
taken care of plus some more integrity checks.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-10 10:30:21 +02:00
Christian Ebner d21ae955a6 src/pxar/fuse.rs: impl getattr callback for fuse
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-06 12:24:14 +02:00
Christian Ebner ec04ea81f2 src/pxar/fuse.rs: Refactor run_in_context and remove inode_to_offset and offset_to_inode
as their functionality is used only once so it makes more sense to keep them
inline.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-06 12:22:53 +02:00
Christian Ebner 8413083fc5 src/pxar/fuse.rs: Improve comments, add rustfmt skip tag and reafctor
Also, removes an unused println statement in the decoder callback function and
fixes a typo.
Further, use ABI compatible Option<&T> for FFI to avoid use of raw pointers.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-06 12:22:17 +02:00
Christian Ebner bbd055bf45 src/pxar/decoder.rs: impl functionality needed for fuse implementation
Implements functions attributes, open, read, read_link and get_dir
to be used by the fuse implementation which uses file offsets within the archive
as inodes to reference the archives items.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-06 07:18:14 +02:00
Christian Ebner 132cb0d0db src/pxar/decoder.rs: Add comment for unsolved issue and refactor if statement.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-06 07:16:31 +02:00
Christian Ebner 70b03a07c8 src/pxar/sequential_decoder.rs: make functions needed in non-sequential decoder accessible from within crate
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-04 06:15:05 +02:00
Christian Ebner f92e8266ae src/pxar/format_definitions.rs: move header type in PxarHeader and hash in PxarGoodbyeItem to top of struct
By this it is possible to read and check just the first u64 of the corresponding
structs in order to identify the items.
This is needed for the fuse implementation in order to get entries based on the
archive offset, used as inode.
Directories are referenced by the offset to the goodbye tail while other items
are referenced by the offset of the filename followed by the entry.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-04 06:14:30 +02:00
Christian Ebner 75933d1e83 src/pxar/fuse.rs: add function to map offset to inode and vice versa
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-04 06:13:59 +02:00
Christian Ebner c7fee396c6 src/pxar/decoder.rs: add getter functions to obtain start/end offsets for directories
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-04 06:10:56 +02:00
Christian Ebner 3626ac611f src/pxar/decoder.rs: rustfmt fixups
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-04 06:09:17 +02:00
Christian Ebner bcb664cb69 pxar/fuse: add pxar cli flag to set single- or multi-threaded session loop
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-23 09:43:14 +02:00
Christian Ebner de2791868a src/pxar/sequentail_decoder.rs: followup: cleanup S_IFMT masking
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-23 09:42:22 +02:00
Christian Ebner 9cb9e1b7db src/pxar/sequential_decoder.rs: style fixups
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-23 09:42:19 +02:00
Christian Ebner dac88033ba src/pxar/dir_stack.rs: style fixups
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-23 09:39:14 +02:00
Christian Ebner b69169e7be src/pxar/fuse.rs: style fixups
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-23 09:37:58 +02:00
Christian Ebner d792dc3cd2 src/pxar/match_pattern.rs: style fixups
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-23 09:37:56 +02:00
Christian Ebner 4ea22b68d9 src/pxar/format_definition.rs: style fixup
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-23 09:37:53 +02:00
Christian Ebner 35dfd3ceb7 src/pxar/encoder.rs: style fixups by rustfmt
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 13:29:11 +02:00
Christian Ebner 1af30bc2fe (pxar: replace deprecated std::mem::uninitialized()
... and use std::mem::MaybeUninit or proxmox::tools::vec::uninitialized() instead.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 13:27:25 +02:00
Christian Ebner e5471b4836 pxar/decoder: avoid failing on hardlinks and return corresponding target file entry
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
[Fixup: remove unnecessary 'mut']
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 09:32:52 +02:00
Christian Ebner 58262f40f7 src/pxar/decoder.rs: get correct stats for root directory
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 09:31:41 +02:00
Christian Ebner 7d26720e79 src/pxar/decoder.rs: move GOODBYE_ITEM_SIZE from function to module scope.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 09:31:39 +02:00
Dietmar Maurer 9d135fe617 src/backup/catalog_blob.rs: moved catalog impl. from pxar
And avoid loading catalog into memory.
2019-08-16 12:27:17 +02:00
Christian Ebner ac0b435344 src/pxar/fuse.rs: fix compiler warnings
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-14 15:14:57 +02:00
Christian Ebner 41d08aa6de src/pxar/fuse.rs: enable libfuse debug output in verbose mode
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-14 08:59:15 +02:00
Christian Ebner 742e64ea0b src/pxar/fuse.rs: cleanup callback interface and store decoder within session context
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-14 08:58:44 +02:00
Christian Ebner 7750b7f2b7 pxar: decoder: take ownership of underlying reader
By taking ownership it is easier to move the decoder into another struct,
e.g. into a session context in fuse.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-14 08:55:08 +02:00
Christian Ebner f50b4fd6a0 src/pxar/decoder.rs: cleanup s/CaDirectoryEntry/DirectoryEntry
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-14 08:54:08 +02:00
Christian Ebner c50f87442c pxar: add basic code for FUSE implementation.
This adds the basic code in order to create a fuse session and mount an archive.
It adds libfuse3-3 as runtime dependency and libfuse3-dev as build dependency.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-09 16:42:31 +02:00
Dietmar Maurer 9049a8cfe6 src/bin/proxmox-backup-client.rs: implement catalog command 2019-08-09 11:36:33 +02:00
Dietmar Maurer 2761d6a4f3 src/pxar/encoder.rs: use BackupCatalogWriter 2019-08-09 09:46:49 +02:00
Dietmar Maurer aea0815d32 src/pxar/catalog.rs: new catalog helper 2019-08-09 09:41:43 +02:00
Christian Ebner eecb182845 pxar: add initial docs for MatchPattern
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-06 09:03:02 +02:00
Christian Ebner 43e892d293 pxar: add error handling for MatchPattern::matches_filename()
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-06 09:02:44 +02:00
Dietmar Maurer b86f263ced use new proxmox::sys::linux::magic 2019-08-03 09:28:57 +02:00
Christian Ebner 4ea0f7d95b pxar: remove flag to change digest algorithm
The flag CA_FORMAT_SHA512_256 is used to switch between sha512 and sha256 to
calculate digest in casync.

As we use sha256, we can get rid of this flag for now.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-03 08:57:53 +02:00
Christian Ebner 4d142ea79e pxar: cleanup: refactor and rename exclude pattern
The original name PxarExcludePattern makes no sense anymore as the patterns are
also used to match filenames during restore of the archive.

Therefore, exclude_pattern.rs is moved to match_pattern.rs and PxarExcludePattern
rename to MatchPattern.
Further, since it makes more sense the MatchTypes are now declared as None,
Positive, Negative, PartialPositive or PartialNegative, as this makes more sense
and seems more readable.
Positive matches are those without '!' prefix, Negatives with '!' prefix.

This makes also the filename matching in the encoder/decoder more intuitive and
the logic was adapted accordingly.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-03 08:52:32 +02:00
Christian Ebner fe076c8259 pxar: cleanup: s/PxarDirBuf/PxarDirStack/g and move dir_buffer.rs to dir_stack.rs
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-03 08:52:10 +02:00
Christian Ebner ead7546a96 pxar: change uid and gid to u32 instead of u64
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-03 08:51:51 +02:00
Christian Ebner 5e50c606b0 pxar: cleanup: s/CA_FORMAT/PXAR/g and s/CaFormat/Pxar/g
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-03 08:51:33 +02:00
Christian Ebner 47651f9530 pxar: cleanup: move feature flags to src/pxar/flags.rs and omit CA_FORMAT prefix on all of them
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-03 08:51:06 +02:00
Christian Ebner 91451c4355 pxar: cleanup: move filesystem related magic numbers to tools/fs/magic.rs
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-03 08:48:12 +02:00
Christian Ebner 81a9905e0a pxar: implement feature flag support for device nodes, fifos and sockets
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:55:17 +02:00
Christian Ebner 8abc95a145 pxar: remove some unused feature flags from format definition
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:54:46 +02:00
Christian Ebner 3a905cac2b src/pxar/sequential_decoder.rs: remove of obsolete function dir_mkdirat
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:52:49 +02:00
Christian Ebner beffac999f src/pxar/sequentail_decoder.rs: fix issue when restoring with glob pattern.
Partial extraction of an archive with a glob pattern, e.g. '**/*.conf' lead to
the unexpected behaviour of restoring all partially matched directories (in this
example all of them).

This patch fixes this unexpected behaviour by only restoring those directories
were the directory or one of its sub-items fully matched the pattern and should
therefore be restored.

To achive this behavoiur, directory metadata is pushed onto a stack and restored
on demand.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:49:47 +02:00
Christian Ebner 51ac99c314 src/pxar/exclude_pattern.rs: add Clone and Copy trait to MatchType
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:49:47 +02:00
Christian Ebner 6a584cfd76 pxar: add PxarDir and PxarDirBuf to buffer directory metadata
In order to restore only directories when some of their content fully matched
a match pattern on partial restores, these directories and their metadata are
pushed onto this buffer and only restored successivley on demand.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:45:12 +02:00
Dietmar Maurer 27e6e180b6 src/pxar/format_definition.rs - PxarAttributes: derive Default
And remove unnecessary impl new().
2019-08-02 07:16:10 +02:00
Christian Ebner a92e6c9011 src/pxar/sequential_decoder.rs: split read and restore of attributes into separate functions
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:11:38 +02:00
Christian Ebner e60cfbcdd0 src/pxar/format_definition.rs: add struct PxarAttributes
This structure contains all the attributes allowing to easily store those within
a e.g. dir buffer.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 07:10:22 +02:00
Christian Ebner 2be3eff5c3 pxar: avoid taking ownership of xattrs, fcaps and quota_projid on corresponding restore functions.
By borrowing these objects we preserve the functionality but make sure
that ownership doesn't change, avoiding problems when contained within other
structs such as e.g. a buffer storing these attributes.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-08-02 06:44:00 +02:00
Christian Ebner 9731c8b862 pxar: add support for storing/restoring the quota project id on ZFS
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-30 09:40:48 +02:00
Christian Ebner 6a87910949 pxar: implement allow_existing_dirs for pxar decoder
By default, restoring an archive will fail if files with the same filename
already exist in the target directory.

By setting the allow_existing_dirs flag, the restore will not fail if an
existing directory is encountered.
The metadata (permissions, acls, ...) of the existing directory will be set
to the ones from the archive.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-30 09:40:30 +02:00
Dietmar Maurer 5b72c9b4f7 src/pxar/encoder.rs: add new skip_lost_and_found parameter 2019-07-24 12:21:25 +02:00
Dietmar Maurer 2eeaacb974 src/pxar/encoder.rs: allow to pass list of devices
For better mount point include control...
2019-07-24 08:11:59 +02:00
Christian Ebner 1fdef50f52 src/pxar/sequential_decoder.rs: Call callback only on restored paths.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-19 11:58:51 +02:00
Christian Ebner fa7e957ca3 pxar: Adapt SequentialDecoder::restore() calls to pass empty match pattern for full restore
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 12:19:31 +02:00
Christian Ebner d32c2e4d27 src/pxar/sequential_decoder.rs: adapt code for partial restore by match pattern
Allows to partially restore an archive by passing match patterns to the restore
function.
The whole restore is performed in sequential, therefore the whole archive has to
be read.
By wrapping the RawFd into an Option it can be controlled if the corresponding
part is restored (in case of Some(fd)) or if the Reader reads over it
without restore (in case of None).

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 12:11:37 +02:00
Christian Ebner 4902291673 src/pxar/sequential_decoder.rs: implement match_filename to match include pattern for partial restores
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 12:07:54 +02:00
Christian Ebner 894cd49ac4 src/pxar/sequential_decoder.rs: Also check for nul bytes when reading the filename
Check if the filename does not contain invalid nul byes when reading it from the
archive.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 12:04:41 +02:00
Christian Ebner 0b39674895 src/pxar/sequential_decoder.rs: remove old comments and refactoring
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 09:46:02 +02:00
Christian Ebner 9f8fcdd050 src/pxar/encoder.rs: refactoring of match_exclude_pattern()
match_exclude_pattern() does not need a '&mut self' reference to the encoder,
move it therefore out of the impl.
Further, this patch contains some naming and formatting cosmetics.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 09:45:19 +02:00