pxar: create: attempt to use O_NOATIME

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-07-31 11:46:53 +02:00
parent e51be33807
commit 30c3c5d66c
1 changed files with 24 additions and 16 deletions

View File

@ -261,10 +261,12 @@ impl<'a, 'b> Archiver<'a, 'b> {
// common flags we always want to use: // common flags we always want to use:
let oflags = oflags | OFlag::O_CLOEXEC | OFlag::O_NOCTTY; let oflags = oflags | OFlag::O_CLOEXEC | OFlag::O_NOCTTY;
match Fd::openat( let mut noatime = OFlag::O_NOATIME;
loop {
return match Fd::openat(
&unsafe { RawFdNum::from_raw_fd(parent) }, &unsafe { RawFdNum::from_raw_fd(parent) },
file_name, file_name,
oflags, oflags | noatime,
Mode::empty(), Mode::empty(),
) { ) {
Ok(fd) => Ok(Some(fd)), Ok(fd) => Ok(Some(fd)),
@ -278,9 +280,15 @@ impl<'a, 'b> Archiver<'a, 'b> {
writeln!(self.errors, "failed to open file: {:?}: access denied", file_name)?; writeln!(self.errors, "failed to open file: {:?}: access denied", file_name)?;
Ok(None) Ok(None)
} }
Err(nix::Error::Sys(Errno::EPERM)) if !noatime.is_empty() => {
// Retry without O_NOATIME:
noatime = OFlag::empty();
continue;
}
Err(other) => Err(Error::from(other)), Err(other) => Err(Error::from(other)),
} }
} }
}
fn read_pxar_excludes(&mut self, parent: RawFd) -> Result<(), Error> { fn read_pxar_excludes(&mut self, parent: RawFd) -> Result<(), Error> {
let fd = self.open_file(parent, c_str!(".pxarexclude"), OFlag::O_RDONLY, false)?; let fd = self.open_file(parent, c_str!(".pxarexclude"), OFlag::O_RDONLY, false)?;