take a reference to the dirfd in Fd::openat

Otherwise we cannot pass references to it unless the AsRawFd
implementation was made for the reference itself rather than
the type.

Note that while this changes the public API, we have no
users outside of this crate yet and no public releases,
so I'm not doing a major version bump.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-01-14 11:21:28 +01:00
parent 2a43a45763
commit 39c5d8641b
2 changed files with 3 additions and 3 deletions

View File

@ -54,7 +54,7 @@ impl Fd {
nix::fcntl::open(path, oflag, mode).map(Self)
}
pub fn openat<D, P>(dirfd: D, path: &P, oflag: OFlag, mode: Mode) -> Result<Self, nix::Error>
pub fn openat<D, P>(dirfd: &D, path: &P, oflag: OFlag, mode: Mode) -> Result<Self, nix::Error>
where
D: AsRawFd,
P: ?Sized + NixPath,

View File

@ -317,7 +317,7 @@ fn create_path_at_do(
Some(Component::ParentDir) => {
at = Fd::openat(
at,
&at,
unsafe { CStr::from_bytes_with_nul_unchecked(b"..\0") },
OFlag::O_DIRECTORY,
stat::Mode::empty(),
@ -342,7 +342,7 @@ fn create_path_at_do(
Err(e) => return Err(e.into()),
Ok(_) => true,
};
at = Fd::openat(at, path, OFlag::O_DIRECTORY, stat::Mode::empty())?;
at = Fd::openat(&at, path, OFlag::O_DIRECTORY, stat::Mode::empty())?;
if let (true, Some(opts)) = (created, opts) {
if opts.owner.is_some() || opts.group.is_some() {