mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/utils: Add AtomicFile
This type helps to perform atomic operations by writing to a temporary file and renaming it to the actual filename when the `AtomicFile::finish` function is called. If the `AtomicFile::finish` function is never called, the temporary file is automatically removed when it goes out of scope. It utilizes the `renameat2` [1] libc function and its semantics. [1] https://man7.org/linux/man-pages/man2/renameat.2.html Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
committed by
Steffen Eiden
parent
171432852b
commit
938fe2a744
@@ -36,6 +36,13 @@ pub enum Error {
|
||||
source: std::io::Error,
|
||||
},
|
||||
|
||||
#[error("Cannot rename '{src}' to '{dst}'")]
|
||||
FileAccessRename {
|
||||
src: String,
|
||||
dst: String,
|
||||
source: std::io::Error,
|
||||
},
|
||||
|
||||
#[error("Cannot encode secrets (Too many secrets)")]
|
||||
ManySecrets,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user