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 94A4775EEE for ; Wed, 14 Jul 2021 12:27:45 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8CD1EFC66 for ; Wed, 14 Jul 2021 12:27:45 +0200 (CEST) Received: from elsa.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1AFA6FC5D for ; Wed, 14 Jul 2021 12:27:45 +0200 (CEST) Received: by elsa.proxmox.com (Postfix, from userid 0) id 01F18AE1DB3; Wed, 14 Jul 2021 12:27:38 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Wed, 14 Jul 2021 12:27:36 +0200 Message-Id: <20210714102736.1288034-1-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.502 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox] make_tmp_file: return File instead of Fd 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: Wed, 14 Jul 2021 10:27:45 -0000 --- proxmox/src/tools/fs.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/proxmox/src/tools/fs.rs b/proxmox/src/tools/fs.rs index cd0ba35..12e96bd 100644 --- a/proxmox/src/tools/fs.rs +++ b/proxmox/src/tools/fs.rs @@ -126,14 +126,14 @@ pub fn file_read_firstline>(path: P) -> Result { pub fn make_tmp_file>( path: P, options: CreateOptions, -) -> Result<(Fd, PathBuf), Error> { +) -> Result<(File, PathBuf), Error> { let path = path.as_ref(); // use mkstemp here, because it works with different processes, threads, even tokio tasks let mut template = path.to_owned(); template.set_extension("tmp_XXXXXX"); - let (fd, tmp_path) = match unistd::mkstemp(&template) { - Ok((fd, path)) => (unsafe { Fd::from_raw_fd(fd) }, path), + let (file, tmp_path) = match unistd::mkstemp(&template) { + Ok((fd, path)) => (unsafe { File::from_raw_fd(fd) }, path), Err(err) => bail!("mkstemp {:?} failed: {}", template, err), }; @@ -143,19 +143,19 @@ pub fn make_tmp_file>( .perm .unwrap_or(stat::Mode::from_bits_truncate(0o644)); - if let Err(err) = stat::fchmod(fd.as_raw_fd(), mode) { + if let Err(err) = stat::fchmod(file.as_raw_fd(), mode) { let _ = unistd::unlink(&tmp_path); bail!("fchmod {:?} failed: {}", tmp_path, err); } if options.owner.is_some() || options.group.is_some() { - if let Err(err) = fchown(fd.as_raw_fd(), options.owner, options.group) { + if let Err(err) = fchown(file.as_raw_fd(), options.owner, options.group) { let _ = unistd::unlink(&tmp_path); bail!("fchown {:?} failed: {}", tmp_path, err); } } - Ok((fd, tmp_path)) + Ok((file, tmp_path)) } /// Atomically replace a file. -- 2.30.2