public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Robert Obkircher <r.obkircher@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH v1 proxmox 1/2] proxmox-sys: avoid unnecessary conversion in replace_file
Date: Wed, 17 Jun 2026 12:49:53 +0200	[thread overview]
Message-ID: <20260617105000.232928-2-r.obkircher@proxmox.com> (raw)
In-Reply-To: <20260617105000.232928-1-r.obkircher@proxmox.com>

Since make_tmp_file already returns a File there is no need to convert
to a raw file descriptor and back.

Fixes: 26c06df4 ("make_tmp_file: return File instead of Fd")
Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
---
 proxmox-sys/src/fs/file.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/proxmox-sys/src/fs/file.rs b/proxmox-sys/src/fs/file.rs
index f0939381..533e0896 100644
--- a/proxmox-sys/src/fs/file.rs
+++ b/proxmox-sys/src/fs/file.rs
@@ -1,6 +1,6 @@
 use std::fs::File;
 use std::io::{self, BufRead, BufReader, Write};
-use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
+use std::os::unix::io::{AsRawFd, FromRawFd};
 use std::path::{Path, PathBuf};
 #[cfg(feature = "timer")]
 use std::time::Duration;
@@ -177,9 +177,7 @@ pub fn replace_file<P: AsRef<Path>>(
     options: CreateOptions,
     fsync: bool,
 ) -> Result<(), Error> {
-    let (fd, tmp_path) = make_tmp_file(&path, options)?;
-
-    let mut file = unsafe { File::from_raw_fd(fd.into_raw_fd()) };
+    let (mut file, tmp_path) = make_tmp_file(&path, options)?;
 
     if let Err(err) = file.write_all(data) {
         let _ = unistd::unlink(&tmp_path);
-- 
2.47.3





  reply	other threads:[~2026-06-17 10:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17 10:49 [PATCH v1 proxmox 0/2] improve proxmox-sys::fs::replace_file Robert Obkircher
2026-06-17 10:49 ` Robert Obkircher [this message]
2026-06-17 10:49 ` [PATCH v1 proxmox 2/2] fix #7690: proxmox-sys: close fd before rename/unlink in replace_file Robert Obkircher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260617105000.232928-2-r.obkircher@proxmox.com \
    --to=r.obkircher@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal