diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/tempfile/src/file/imp | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tempfile/src/file/imp')
-rw-r--r-- | vendor/tempfile/src/file/imp/unix.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/vendor/tempfile/src/file/imp/unix.rs b/vendor/tempfile/src/file/imp/unix.rs index fed4e02e7..79aba783e 100644 --- a/vendor/tempfile/src/file/imp/unix.rs +++ b/vendor/tempfile/src/file/imp/unix.rs @@ -14,7 +14,10 @@ use crate::util; use std::path::Path; #[cfg(not(target_os = "redox"))] -use rustix::fs::{linkat, renameat, unlinkat, AtFlags, CWD}; +use { + rustix::fs::{rename, unlink}, + std::fs::hard_link, +}; pub fn create_named(path: &Path, open_options: &mut OpenOptions) -> io::Result<File> { open_options.read(true).write(true).create_new(true); @@ -103,13 +106,13 @@ pub fn reopen(_file: &File, _path: &Path) -> io::Result<File> { #[cfg(not(target_os = "redox"))] pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> { if overwrite { - renameat(CWD, old_path, CWD, new_path)?; + rename(old_path, new_path)?; } else { // On Linux, use `renameat_with` to avoid overwriting an existing name, // if the kernel and the filesystem support it. #[cfg(any(target_os = "android", target_os = "linux"))] { - use rustix::fs::{renameat_with, RenameFlags}; + use rustix::fs::{renameat_with, RenameFlags, CWD}; use rustix::io::Errno; use std::sync::atomic::{AtomicBool, Ordering::Relaxed}; @@ -124,12 +127,13 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result< } } - // Otherwise use `linkat` to create the new filesystem name, which - // will fail if the name already exists, and then `unlinkat` to remove + // Otherwise use `hard_link` to create the new filesystem name, which + // will fail if the name already exists, and then `unlink` to remove // the old name. - linkat(CWD, old_path, CWD, new_path, AtFlags::empty())?; + hard_link(old_path, new_path)?; + // Ignore unlink errors. Can we do better? - let _ = unlinkat(CWD, old_path, AtFlags::empty()); + let _ = unlink(old_path); } Ok(()) } |