Skip to content

Commit 9c1e426

Browse files
authored
Fix DirEntryInner::is_same_file at a mountpoint (#333)
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
1 parent 7cd2b94 commit 9c1e426

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cap-primitives/src/rustix/fs/dir_entry_inner.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ impl DirEntryInner {
6969

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

7576
fn file_name_bytes(&self) -> &OsStr {

0 commit comments

Comments
 (0)