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 BC09A9BF5 for ; Fri, 4 Aug 2023 14:32:25 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A3915EC5C for ; Fri, 4 Aug 2023 14:32:25 +0200 (CEST) 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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 4 Aug 2023 14:32:25 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E3F2340C5A for ; Fri, 4 Aug 2023 14:32:24 +0200 (CEST) Date: Fri, 4 Aug 2023 14:32:24 +0200 From: Wolfgang Bumiller To: Christian Ebner Cc: pbs-devel@lists.proxmox.com Message-ID: <662lildxtfvakyp7ccgbxedlrfcuaeoomgacsgv3d42y6i6euy@nlmv53yln2he> References: <20230801103412.182490-1-c.ebner@proxmox.com> <20230801103412.182490-2-c.ebner@proxmox.com> <7jplu7x73x2ebk4owsu2dpibgykjqgccbzdmc4w4loerpiks5k@wlihalt5h7c7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7jplu7x73x2ebk4owsu2dpibgykjqgccbzdmc4w4loerpiks5k@wlihalt5h7c7> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.114 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 - Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 1/2] fix: #4761: unlink existing entries for hard/symlinks when overwrite 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: Fri, 04 Aug 2023 12:32:25 -0000 On Fri, Aug 04, 2023 at 02:20:40PM +0200, Wolfgang Bumiller wrote: > On Tue, Aug 01, 2023 at 12:34:11PM +0200, Christian Ebner wrote: > > Creating symlinks or hardlinks might fail if a directory entry with the > > same name is already present on the filesystem during restore. > > > > When the overwrite flag is given, on failure unlink the existing entry > > (except directories) and retry hard/symlink creation. > > > > Signed-off-by: Christian Ebner > > --- > > changes since v1: > > * rebased to current master > > > > pbs-client/src/pxar/extract.rs | 39 +++++++++++++++++++++++++++++++--- > > 1 file changed, 36 insertions(+), 3 deletions(-) > > > > diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs > > index 4dbaf52d..c1e7b417 100644 > > --- a/pbs-client/src/pxar/extract.rs > > +++ b/pbs-client/src/pxar/extract.rs > > @@ -547,7 +547,21 @@ impl Extractor { > > link: &OsStr, > > ) -> Result<(), Error> { > > let parent = self.parent_fd()?; > > - nix::unistd::symlinkat(link, Some(parent), file_name)?; > > + > > + match nix::unistd::symlinkat(link, Some(parent), file_name) { > > + Ok(()) => {} > > + Err(nix::errno::Errno::EEXIST) => { > > + if !self.overwrite { > > + return Err(nix::errno::Errno::EEXIST.into()); > > + } > > The above could be shortened to a pattern gaurd: > > Err(nix::errno::Errno::EEXIST) if self.overwrite => { > > then we don't need the extra `return Err()` since we just run into the > final `Err(err)` case. As a side note, you could have used Err(err @ nix::errno::Errno::EEXIST) and then returned `Err(err.into())` ;-)