Skip to content

Commit

Permalink
Fix DirEntryInner::is_same_file at a mountpoint (#333)
Browse files Browse the repository at this point in the history
If a direntry comes from a mountpoint's parent, then its ino will be the
ino of the underlying directory, not the mounted file system's root
directory.  So ignore the direntry's ino, and just look at the ino in
its metadata.

Fixes #330
  • Loading branch information
asomers authored Oct 11, 2023
1 parent 7cd2b94 commit 9c1e426
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cap-primitives/src/rustix/fs/dir_entry_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ impl DirEntryInner {

#[inline]
pub(crate) fn is_same_file(&self, metadata: &Metadata) -> io::Result<bool> {
Ok(self.ino() == metadata.ino() && self.metadata()?.dev() == metadata.dev())
let self_md = self.metadata()?;
Ok(self_md.ino() == metadata.ino() && self_md.dev() == metadata.dev())
}

fn file_name_bytes(&self) -> &OsStr {
Expand Down

0 comments on commit 9c1e426

Please sign in to comment.