* [pbs-devel] [PATCH proxmox] make_tmp_file: return File instead of Fd
@ 2021-07-14 10:27 Dietmar Maurer
2021-07-14 11:49 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dietmar Maurer @ 2021-07-14 10:27 UTC (permalink / raw)
To: pbs-devel
---
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<P: AsRef<Path>>(path: P) -> Result<String, Error> {
pub fn make_tmp_file<P: AsRef<Path>>(
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<P: AsRef<Path>>(
.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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pbs-devel] [PATCH proxmox] make_tmp_file: return File instead of Fd
2021-07-14 10:27 [pbs-devel] [PATCH proxmox] make_tmp_file: return File instead of Fd Dietmar Maurer
@ 2021-07-14 11:49 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-07-14 11:49 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Dietmar Maurer
On 14.07.21 12:27, Dietmar Maurer wrote:
can we please add some rationale for such changes in the commit
message?
Also, please add an "applied:" prefix if it's already applied in git.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-14 11:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 10:27 [pbs-devel] [PATCH proxmox] make_tmp_file: return File instead of Fd Dietmar Maurer
2021-07-14 11:49 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox