[pbs-devel] [PATCH proxmox 2/2] open_file_locked: add options parameter (CreateOptions)
Fabian Grünbichler
f.gruenbichler at proxmox.com
Mon Jul 19 12:44:53 CEST 2021
breaking change, should be marked as such both in the patch as well as
with a version bump (or alternatively, be implemented as a new function)
requires a patch in proxmox-openid-rs to build
also see comments on patch #1 in proxmox-backup!
On July 16, 2021 10:28 am, Dietmar Maurer wrote:
> To be able to set file permissions and ownership.
> ---
> proxmox/src/tools/fs.rs | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/proxmox/src/tools/fs.rs b/proxmox/src/tools/fs.rs
> index 2a93b30..5c269a6 100644
> --- a/proxmox/src/tools/fs.rs
> +++ b/proxmox/src/tools/fs.rs
> @@ -1,7 +1,7 @@
> //! File related utilities such as `replace_file`.
>
> use std::ffi::CStr;
> -use std::fs::{File, OpenOptions};
> +use std::fs::File;
> use std::io::{self, BufRead, BufReader, Write};
> use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
> use std::path::{Path, PathBuf};
> @@ -584,12 +584,17 @@ pub fn open_file_locked<P: AsRef<Path>>(
> path: P,
> timeout: Duration,
> exclusive: bool,
> + options: CreateOptions,
> ) -> Result<File, Error> {
> let path = path.as_ref();
> - let mut file = match OpenOptions::new().create(true).append(true).open(path) {
> - Ok(file) => file,
> - Err(err) => bail!("Unable to open lock {:?} - {}", path, err),
> - };
> +
> + let mut file = atomic_open_or_create_file(
> + path,
> + OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_APPEND,
> + &[],
> + options,
> + )?;
> +
> match lock_file(&mut file, exclusive, Some(timeout)) {
> Ok(_) => Ok(file),
> Err(err) => bail!("Unable to acquire lock {:?} - {}", path, err),
> --
> 2.30.2
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
More information about the pbs-devel
mailing list