From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 96433BC0D4 for ; Thu, 21 Dec 2023 12:38:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 677EC18353 for ; Thu, 21 Dec 2023 12:37:44 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 21 Dec 2023 12:37:43 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7610648A4E for ; Thu, 21 Dec 2023 12:37:43 +0100 (CET) Message-ID: <086153c2-0458-409d-a241-2a2b02bbbb34@proxmox.com> Date: Thu, 21 Dec 2023 12:37:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Wolfgang Bumiller Cc: pbs-devel@lists.proxmox.com, Dominik Csapak References: <20231214144824.100616-1-f.schauer@proxmox.com> <20231214144824.100616-3-f.schauer@proxmox.com> Content-Language: en-US From: Filip Schauer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.140 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [zip.rs] Subject: Re: [pbs-devel] [PATCH v3 proxmox 2/3] compression: Add support for symlinks in zip files X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2023 11:38:14 -0000 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 >> --- >> 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. I just thought of another way: How about inserting the content into FileType::Regular. This would eliminate the need to pass None to add_entry. Therefore, it would be impossible to pass conflicting parameters to the function, such as FileType::Regular with content = None. This change would not get rid of the hunk you mentioned, but the code seems cleaner to me this way.