Skip to content

Commit

Permalink
fix: fix remount bug
Browse files Browse the repository at this point in the history
  • Loading branch information
akitaSummer committed Feb 23, 2024
1 parent f62cd2c commit 0e837eb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/overlayfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ impl RealInode {
let mut more = true;
let mut offset = 0;
let bufsize = 1024;
#[cfg(target_os = "linux")]
while more {
more = false;
self.layer.readdir(
Expand All @@ -295,6 +296,29 @@ impl RealInode {
},
)?;
}
#[cfg(target_os = "macos")]
self.layer.readdir(
ctx,
self.inode,
handle,
bufsize,
offset,
&mut |d| -> Result<usize> {
more = true;
offset = d.offset;
let child_name = String::from_utf8_lossy(d.name).into_owned();

trace!("entry: {}", child_name.as_str());

if child_name.eq(CURRENT_DIR) || child_name.eq(PARENT_DIR) {
return Ok(1);
}

child_names.push(child_name);

Ok(1)
},
)?;

// Non-zero handle indicates successful 'open', we should 'release' it.
if handle > 0 {
Expand Down
3 changes: 2 additions & 1 deletion src/passthrough/sync_io_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
let data = self.get_dirdata(handle, inode, libc::O_RDONLY)?;

let (_guard, dir) = data.get_file_mut();
if dir.metadata()?.is_dir() {

if !dir.metadata()?.is_dir() {
return Ok(());
}
// Safe because this doesn't modify any memory and we check the return value.
Expand Down

0 comments on commit 0e837eb

Please sign in to comment.