pxar: fixup 'vanished-file' logic a bit
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
5afa0755ea
commit
7d0754a6d2
|
@ -248,11 +248,15 @@ impl<'a, 'b> Archiver<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// openat() wrapper which allows but logs `EACCES` and turns `ENOENT` into `None`.
|
/// openat() wrapper which allows but logs `EACCES` and turns `ENOENT` into `None`.
|
||||||
|
///
|
||||||
|
/// The `existed` flag is set when iterating through a directory to note that we know the file
|
||||||
|
/// is supposed to exist and we should warn if it doesnt'.
|
||||||
fn open_file(
|
fn open_file(
|
||||||
&mut self,
|
&mut self,
|
||||||
parent: RawFd,
|
parent: RawFd,
|
||||||
file_name: &CStr,
|
file_name: &CStr,
|
||||||
oflags: OFlag,
|
oflags: OFlag,
|
||||||
|
existed: bool,
|
||||||
) -> Result<Option<Fd>, Error> {
|
) -> Result<Option<Fd>, Error> {
|
||||||
match Fd::openat(
|
match Fd::openat(
|
||||||
&unsafe { RawFdNum::from_raw_fd(parent) },
|
&unsafe { RawFdNum::from_raw_fd(parent) },
|
||||||
|
@ -261,7 +265,12 @@ impl<'a, 'b> Archiver<'a, 'b> {
|
||||||
Mode::empty(),
|
Mode::empty(),
|
||||||
) {
|
) {
|
||||||
Ok(fd) => Ok(Some(fd)),
|
Ok(fd) => Ok(Some(fd)),
|
||||||
Err(nix::Error::Sys(Errno::ENOENT)) => Ok(None),
|
Err(nix::Error::Sys(Errno::ENOENT)) => {
|
||||||
|
if existed {
|
||||||
|
self.report_vanished_file()?;
|
||||||
|
}
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
Err(nix::Error::Sys(Errno::EACCES)) => {
|
Err(nix::Error::Sys(Errno::EACCES)) => {
|
||||||
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)
|
||||||
|
@ -275,6 +284,7 @@ impl<'a, 'b> Archiver<'a, 'b> {
|
||||||
parent,
|
parent,
|
||||||
c_str!(".pxarexclude"),
|
c_str!(".pxarexclude"),
|
||||||
OFlag::O_RDONLY | OFlag::O_CLOEXEC | OFlag::O_NOCTTY,
|
OFlag::O_RDONLY | OFlag::O_CLOEXEC | OFlag::O_NOCTTY,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let old_pattern_count = self.patterns.len();
|
let old_pattern_count = self.patterns.len();
|
||||||
|
@ -452,14 +462,12 @@ impl<'a, 'b> Archiver<'a, 'b> {
|
||||||
parent,
|
parent,
|
||||||
c_file_name,
|
c_file_name,
|
||||||
open_mode | OFlag::O_RDONLY | OFlag::O_NOFOLLOW | OFlag::O_CLOEXEC | OFlag::O_NOCTTY,
|
open_mode | OFlag::O_RDONLY | OFlag::O_NOFOLLOW | OFlag::O_CLOEXEC | OFlag::O_NOCTTY,
|
||||||
|
true,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let fd = match fd {
|
let fd = match fd {
|
||||||
Some(fd) => fd,
|
Some(fd) => fd,
|
||||||
None => {
|
None => return Ok(()),
|
||||||
self.report_vanished_file()?;
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let metadata = get_metadata(fd.as_raw_fd(), &stat, self.flags(), self.fs_magic)?;
|
let metadata = get_metadata(fd.as_raw_fd(), &stat, self.flags(), self.fs_magic)?;
|
||||||
|
|
Loading…
Reference in New Issue