Open coolyjg opened 5 months ago
AFAIK FileSystem
is not Send
so you can't share it between threads . To use it in a multi-threaded application you have to wrap it in a Mutex
. Therefore there is no risk of borrow_mut
panicking.
If I'm wrong please provide an example where it could panic.
We tried to use rust-fatfs
for our own operating system in non-std scenario.
A mutex for the whole file system could work, but every fs operation is serialized.
It seems that this implementation do not guarantee multi-thread safety? Since in
struct FileSystem
, thedisk
field is wrapped byRefCell
which would panic if two thread callborrow_mut()
(considering multi-core scenario). By the way, if fatfs do not guarantee multi-thread safety, I think it at least should not panic, but keep related data dirty.