[pbs-devel] [PATCH v3 proxmox 2/3] compression: Add support for symlinks in zip files
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu Dec 21 13:03:01 CET 2023
On Thu, Dec 21, 2023 at 12:37:42PM +0100, Filip Schauer wrote:
> On 20/12/2023 14:20, Wolfgang Bumiller wrote:
> > With the link of a symlink being encoded in the contents, I wonder if we
> > should just do the same in the code. Not normally what I'd go for in
> > rust, but...
> >
> > On Thu, Dec 14, 2023 at 03:48:21PM +0100, Filip Schauer wrote:
> > > Add support for symlinks to ZipEntry. A symlink is encoded by or-ing its
> > > attributes with S_IFLNK as seen in the kernel in
> > > include/uapi/linux/stat.h
> > >
> > > Signed-off-by: Filip Schauer<f.schauer at proxmox.com>
> > > ---
> > > proxmox-compression/src/zip.rs | 32 +++++++++++++++++++++++++-------
> > > 1 file changed, 25 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/proxmox-compression/src/zip.rs b/proxmox-compression/src/zip.rs
> > > index 069e8bc..a3b2346 100644
> > > --- a/proxmox-compression/src/zip.rs
> > > +++ b/proxmox-compression/src/zip.rs
> > > @@ -74,6 +74,7 @@ fn epoch_to_dos(epoch: i64) -> (u16, u16) {
> > > pub enum FileType {
> > > Directory,
> > > Regular,
> > > + Symlink(OsString),
> > ... then this enum could be #[repr(u32)] using the values from the hunk
> > below as discriminants here directly.
> > And without the OsString in there this could be all of `Clone + Copy +
> > Eq + PartialEq`, turning all the `matches!()` in this series into
> > comparisons with `==`.
>
>
> Do you want to pass the symlink target as an additional argument to
> add_entry? If so, add_entry would take an enum FileType, an Option
> content and an Option symlink_target. Depending on the FileType, at
> least one of the Options would be None. This approach does not seem very
> clean to me.
Why would it be a separate parameter? Target == Content.
More information about the pbs-devel
mailing list