pxar: create: move common O_ flags to open_file

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-07-31 11:42:05 +02:00
parent 70030b43d0
commit e51be33807

View File

@ -258,6 +258,9 @@ impl<'a, 'b> Archiver<'a, 'b> {
oflags: OFlag,
existed: bool,
) -> Result<Option<Fd>, Error> {
// common flags we always want to use:
let oflags = oflags | OFlag::O_CLOEXEC | OFlag::O_NOCTTY;
match Fd::openat(
&unsafe { RawFdNum::from_raw_fd(parent) },
file_name,
@ -280,12 +283,7 @@ impl<'a, 'b> Archiver<'a, 'b> {
}
fn read_pxar_excludes(&mut self, parent: RawFd) -> Result<(), Error> {
let fd = self.open_file(
parent,
c_str!(".pxarexclude"),
OFlag::O_RDONLY | OFlag::O_CLOEXEC | OFlag::O_NOCTTY,
false,
)?;
let fd = self.open_file(parent, c_str!(".pxarexclude"), OFlag::O_RDONLY, false)?;
let old_pattern_count = self.patterns.len();
@ -479,7 +477,7 @@ impl<'a, 'b> Archiver<'a, 'b> {
let fd = self.open_file(
parent,
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,
true,
)?;