Skip to content

Commit

Permalink
Better notes about double locking.
Browse files Browse the repository at this point in the history
  • Loading branch information
thejpster committed Oct 12, 2024
1 parent d2039d4 commit 413d814
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/filesystem/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ where
}

/// Call a callback function for each directory entry in a directory.
///
/// <div class="warning">
///
/// Do not attempt to call any methods on the VolumeManager or any of its
/// handles from inside the callback. You will get a lock error because the
/// object is already locked in order to do the iteration.
///
/// </div>
pub fn iterate_dir<F>(&self, func: F) -> Result<(), Error<D::Error>>
where
F: FnMut(&DirEntry),
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ where
DirAlreadyExists,
/// The filesystem tried to gain a lock whilst already locked.
///
/// This is a bug in the filesystem. Please open an issue.
/// This is either a bug in the filesystem, or you tried to access the
/// filesystem API from inside a directory iterator (that isn't allowed).
LockError,
}

Expand Down
8 changes: 8 additions & 0 deletions src/volume_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ where
}

/// Call a callback function for each directory entry in a directory.
///
/// <div class="warning">
///
/// Do not attempt to call any methods on the VolumeManager or any of its
/// handles from inside the callback. You will get a lock error because the
/// object is already locked in order to do the iteration.
///
/// </div>
pub fn iterate_dir<F>(&self, directory: RawDirectory, func: F) -> Result<(), Error<D::Error>>
where
F: FnMut(&DirEntry),
Expand Down

0 comments on commit 413d814

Please sign in to comment.