From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id DEEB91FF29F for ; Thu, 18 Jul 2024 13:19:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7B863A1E9; Thu, 18 Jul 2024 13:19:39 +0200 (CEST) Date: Thu, 18 Jul 2024 13:19:05 +0200 (CEST) From: Christian Ebner To: Proxmox Backup Server development discussion , Thomas Lamprecht , Christoph Heiss Message-ID: <1626412400.1424.1721301545661@webmail.proxmox.com> In-Reply-To: References: <20240712075449.238010-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev67 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.021 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 Subject: Re: [pbs-devel] [PATCH proxmox v2] sys: file: use renameat2() from `nix` crate 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" > On 18.07.2024 12:29 CEST Thomas Lamprecht wrote: > > > Am 12/07/2024 um 09:54 schrieb Christoph Heiss: > > Saves us from converting the paths to raw C strings ourselves, thus > > simplifying it quite a bit. > > > > Since the `nix` crate does not provide link() directly, only linkat(), > > that is used instead - which behaves exactly the same as link() when > > using AT_FDCWD and an empty flag set. > > > > No functional changes. > > > > OK by me in general, but I get the following errors on build (well `cargo check`): > > > ``` > Checking proxmox-sys v0.6.0 (/root/sources/pbs/proxmox/proxmox-sys) > error[E0603]: struct `AtFlags` is private > --> proxmox-sys/src/fs/file.rs:283:30 > | > 283 | nix::unistd::AtFlags::empty(), > | ^^^^^^^ private struct > | > note: the struct `AtFlags` is defined here > --> /usr/share/cargo/registry/nix-0.26.1/src/unistd.rs:6:30 > | > 6 | use crate::fcntl::{at_rawfd, AtFlags}; > | ^^^^^^^ > help: consider importing this struct instead > | > 283 | nix::fcntl::AtFlags::empty(), > | ~~~~~~~~~~~~~~~~~~~ > help: import `AtFlags` directly > | > 283 | nix::fcntl::AtFlags(), > | ~~~~~~~~~~~~~~~~~~~ > > error[E0308]: mismatched types > --> proxmox-sys/src/fs/file.rs:283:17 > | > 278 | let result = nix::unistd::linkat( > | ------------------- arguments to this function are incorrect > ... > 283 | nix::unistd::AtFlags::empty(), > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `LinkatFlags`, found `AtFlags` > | > note: function defined here > --> /usr/share/cargo/registry/nix-0.26.1/src/unistd.rs:1252:8 > | > 1252 | pub fn linkat( > | ^^^^^^ > > Some errors have detailed explanations: E0308, E0603. > For more information about an error, try `rustc --explain E0308`. > error: could not compile `proxmox-sys` (lib) due to 2 previous errors > ``` > > Seems like you tested this with upstream nix, as the new type only works > since nix version 0.28, while we still got 0.26.1. > > We might be able to upgrade nix, but that is often quite a bit more > involved. > > Alternatively we could go with your v1 approach and apply > > ``` > diff --git a/proxmox-sys/src/fs/file.rs b/proxmox-sys/src/fs/file.rs > index b2d6ddf6..28c7f88b 100644 > --- a/proxmox-sys/src/fs/file.rs > +++ b/proxmox-sys/src/fs/file.rs > @@ -280,7 +280,7 @@ pub fn atomic_open_or_create_file>( > &temp_file_name, > None, > &path.to_path_buf(), > - nix::unistd::AtFlags::empty(), > + nix::unistd::LinkatFlags::NoSymlinkFollow, > ); > let _ = nix::unistd::unlink(&temp_file_name); > result > ``` > > On top for now. > > Oh, please always test such changes with the crate versions provided by our > Debian package provided crate registry. > Partially my fault, as I overlooked in my suggestion that linkat() does not accept `AtFlags` in version 0.26.1 just yet [0]. The suggested replacement type is however already there, but the module namespace is incorrect in the patch. Should have been [1]. [0] https://docs.rs/nix/0.26.1/nix/unistd/fn.linkat.html [1] https://docs.rs/nix/0.26.1/nix/fcntl/struct.AtFlags.html _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel