diff --git a/src/fs.rs b/src/fs.rs index 9405382c..b7762de7 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -62,6 +62,19 @@ pub struct Allocation { state: ll::lfs_t, } +/// # Safety +/// +/// All operations are done on `&mut Allocation, and the reference is held +/// during the entire lifetime of the filesystem, so once the reference is +/// available again, the filesystem is closed +unsafe impl Sync for Allocation {} +/// # Safety +/// +/// All operations are done on `&mut Allocation, and the reference is held +/// during the entire lifetime of the filesystem, so once the reference is +/// available again, the filesystem is closed +unsafe impl Send for Allocation {} + #[derive(Default, Clone, Debug)] #[non_exhaustive] pub struct Config { @@ -1574,4 +1587,21 @@ mod tests { }) .unwrap(); } + + #[allow(unreachable_code)] + fn _filesystem_is_sync() { + fn assert_is_sync(_: &T) -> R { + todo!() + } + fn assert_is_send(_: &T) -> R { + todo!() + } + + assert_is_sync::, ()>(todo!()); + assert_is_send::<&mut Allocation, ()>(todo!()); + assert_is_send::>, ()>(todo!()); + + let mut test_storage = TestStorage::new(); + Filesystem::mount_and_then(&mut test_storage, |fs| assert_is_send(fs)).unwrap() + } }