Commit Graph

200 Commits

Author SHA1 Message Date
Christian Ebner 3ff4ef28e6 src/pxar/encoder.rs: remove unneeded dir_count
dir_count was used to track the number of directory entries to store in the
archive and bail if the maximum is exceeded.
As the number of entries is equally obtained from the list of the filenames to
include, use that one instead.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 09:44:59 +02:00
Christian Ebner a771f90745 src/pxar/exclude_pattern.rs: do not return partial matches for files
Partial matches make only sense for directories, files are always leafs of the
tree. Take this into account in order to avoid restoring of files which only
matched the front of a match pattern.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-17 09:44:06 +02:00
Christian Ebner 3f5192730e src/pxar/format_definition.rs: fix typo
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-15 10:49:34 +02:00
Christian Ebner be9b39e17a src/pxar/sequential_decoder.rs: major refactoring of restore_sequential()
This splits the functionality of restore_sequential() into several smaller
functions in order to allow to reuse them when restoring by seeking based on
the goodbye table offsets.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-05 06:45:50 +02:00
Christian Ebner 48a4509c67 src/pxar/encoder.rs: fix bug with incorrect offset stored in goodbye table
Commit cd7dc87903 introduced the special treatment
for .pxarexclude files when stored in the archive.
The incorrect placement of a code snipplet from this path leads to an incorrect
offset and size stored in the goodbye table.
This fix places the start to the correct position, restoring the previously
correct behaviour.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-05 06:39:39 +02:00
Christian Ebner 7dcbe051e9 pxar: Refactor SequentialDecoder to store the callback function within the struct
Reduces the number of arguments for the function calls within the decoder.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-05 06:38:22 +02:00
Christian Ebner 0d70535a36 src/pxar/encoder.rs: refactor simple match statements to map_err()
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-03 12:18:36 +02:00
Christian Ebner 6e1c31163b src/pxar/sequential_decoder.rs: refactoring of simple match statements to map_err()
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-03 12:18:24 +02:00
Christian Ebner 9d227350a3 src/pxar/sequential_decoder.rs: Cleanup and fix incorrect error message
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-07-03 12:16:59 +02:00
Wolfgang Bumiller f35197f449 replace tools::vec with proxmox::tools::vec
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-01 11:03:25 +02:00
Wolfgang Bumiller 9b2b627fe0 update remaining users of tools::io::ops
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-07-01 10:44:03 +02:00
Christian Ebner cd7dc87903 pxar: impl .pxarexclude parsing and exclude matching
.pxarexclude files allow to exclude or include parts of a subtree by matching
with a glob pattern. The globs are used according to the matches of fnmatch.
In addition '**' can be used to match multiple directories within the path.

Order of the entries matter, as later ones win over previous ones.
As the .pxarexclude files can be placed at any node of the directory hirarchy,
this implies that matching child entries win over parent entries.
The only exception to this behaviour is, when a parent entry already fully
matched the path, thereby excluding the child entries which would match
otherwise.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-24 10:26:20 +02:00
Christian Ebner e993db91cd pxar: introduce fs_feature_flags obtained from filesystem magic in Encoder
Not all filesystems support features such as xattrs,acl,... and trying to get
them is rather expensive.
By getting the supported features based on the filesystem magic and masking the
user set feature flags, unsupported features are excluded rather inexpensively
while encoding the archive.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-07 11:08:20 +02:00
Christian Ebner 1f319e766e src/pxar/encoder.rs: refactoring: use ioctl calls from src/tools/fs.rs instead of local
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-07 11:08:06 +02:00
Christian Ebner 9b77388f2a src/pxar/encoder.rs: minor refactoring
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-07 11:07:55 +02:00
Christian Ebner a4cc8eb7c5 src/pxar/encoder.rs: check if ioctl supported by filesystem
Reading the quota project id relies on a ioctl call to get fsxattr.
On FUSE filesystems, ioctl calls might not be supported and will fail with
an errno indicating no support.
For these cases, the error is ignored and the default project id is used
(indicated by returning Ok(None)).

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-07 11:07:31 +02:00
Dietmar Maurer 1ce2f7cfb9 src/pxar/encoder.rs: style fix 2019-06-05 06:27:39 +02:00
Christian Ebner e7b60a16c8 pxar: impl storing/dumping/restoring of quota project ids
Allows to store/dump/restore the quota project id associated with an inode in
order to correctly restore project quotas.
The project id is obtained/set via ioctl calls getting/setting the fsxattr
associated with the given file descriptor.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-05 06:26:02 +02:00
Christian Ebner 7312ab9eef src/pxar/format_definition.rs: add CA_FORMAT_QUOTA_PROJID and CaFormatQuotaProjID
Defines the types needed to store/restore quota project ids in pxar

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-05 06:23:06 +02:00
Dietmar Maurer 1c0472e88f avoid compiler warnings 2019-06-03 06:43:47 +02:00
Christian Ebner 9b38443314 pxar: change logic and impl all command line flags for xattrs/fcaps/acls
Allows to individually set the flags for storing/dumping/restoring of
xattrs/fcaps/acls in the cli of pxar.
Changes logic so that each of them can be threated individually.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-29 06:51:20 +02:00
Christian Ebner ab87f167f1 src/pxar/encoder.rs: Refactor file stat
Introduce helper functions to check file stats

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-28 06:23:49 +02:00
Christian Ebner 578b601159 src/pxar/encoder.rs: Don't bail if endpoint does not support xattrs.
The encoder bailed if a endpoint which did not support xattrs was encountered.
Instead of bailing, we ignore these errors and simply do not store xattrs for
such endpoints.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-28 06:22:16 +02:00
Christian Ebner 2dbba78b98 src/pxar/sequential_decoder.rs: impl support to dump/restore ACLs from pxar archives
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-24 06:27:24 +02:00
Christian Ebner 6a19448004 src/pxar/encoder.rs: impl support to store ACLs in pxar achives
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-24 06:21:33 +02:00
Christian Ebner 7cfaade7c8 src/pxar/format_definition.rs: define types and structs needed to impl ACL support in pxar
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-24 06:16:55 +02:00
Christian Ebner b344461b33 pxar: pass feature_flags to encoder/decoder instead of individual flags
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-24 06:11:36 +02:00
Christian Ebner 357e4614e2 Minor refactoring of pxars xattr encoder/decoder, mostly reformatting and renaming.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-24 06:11:36 +02:00
Wolfgang Bumiller 8ea3b1d188 tree-wide: use the new vec/io tools modules
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-05-23 09:49:10 +02:00
Christian Ebner 54b14ad741 src/pxar/decoder.rs: pass flags for xattrs and fcaps to decoder.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-23 06:40:09 +02:00
Christian Ebner 1201360def src/pxar/sequential_decoder.rs: Conditional restore xattrs and fcaps if feature_flags is set
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-23 06:39:16 +02:00
Christian Ebner 8bc8791338 src/pxar/format_definitions.rs: do not store the feature_flags in pxar archive.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-23 06:37:37 +02:00
Christian Ebner a45a123950 src/pxar/encoder: Use encoder feature_flags, do not store them within the archive.
Instead of testing and storing the feature_flags in the pxar archive, set and use
the feature flags within the encoder.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-23 06:34:36 +02:00
Christian Ebner 596182056b src/pxar/sequential_decoder.rs: impl functionality to restore xattrs/fcaps from pxar achives
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-21 06:15:30 +02:00
Christian Ebner b303057a19 src/pxar/encoder.rs: impl functionality to encode xattrs/fcaps in pxar
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-21 06:06:26 +02:00
Christian Ebner de2016d58a src/pxar/format_definitions.rs: add format definitions for xattrs and fcaps
In addition to the format definition, the traits needed for sorting of xattr
entries by name are derived.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-05-16 11:14:13 +02:00
Dietmar Maurer af572aaa4c pxar: implement hardlinks
So we are no longer compatible with catar ...
2019-03-16 11:02:12 +01:00
Dietmar Maurer 812dd935ce src/pxar/encoder.rs: detect hardlinks 2019-03-15 12:19:51 +01:00
Dietmar Maurer 896e803feb src/pxar/sequential_decoder.rs: dump_entry - fix FIFO/SOCKET handling 2019-03-15 12:15:38 +01:00
Dietmar Maurer 7dfa17c7cc src/pxar/binary_search_tree.rs: fix test 2019-03-15 11:34:31 +01:00
Dietmar Maurer 9307279faf cleanup: remove dead code 2019-03-15 10:18:28 +01:00
Dietmar Maurer 46cfe7ab7e src/pxar/decoder.rs: implement seekable decoder 2019-03-15 09:36:05 +01:00
Dietmar Maurer 0e21b87be3 renamed: src/pxar/decoder.rs -> src/pxar/sequential_decoder.rs 2019-03-15 08:36:02 +01:00
Dietmar Maurer 3dbfe5b142 simplify pxar module structure 2019-03-15 08:24:32 +01:00
Dietmar Maurer 02c93163cf src/pxar/decoder.rs: correctly call callback() 2019-03-15 08:02:04 +01:00
Dietmar Maurer f98746ba6c src/pxar/decoder.rs: improve docu 2019-03-15 07:12:11 +01:00
Dietmar Maurer 0b2d7fdc81 src/pxar/decoder.rs: avoid compiler warnings 2019-03-14 17:45:47 +01:00
Dietmar Maurer 37940aa1f9 src/bin/pxar.rs: implement dump/list 2019-03-14 17:43:11 +01:00
Dietmar Maurer 40360fde6e src/pxar/decoder.rs: implement dump_archive
use this to debug archive problems ...
2019-03-14 13:10:27 +01:00
Dietmar Maurer 8968258b66 rename catar into pxar
To avoid confusion with the casync implementation.
2019-03-14 10:54:09 +01:00