Skip to content

Commit eb52c59

Browse files
Support mounting file systems & migrate devices to use mounts (microsoft#995)
This PR introduces the `Composer`, which acts as a mount point for the new core file system design (see microsoft#887). It maintains a runtime list of dyn-safe `Backend` objects for each mount point, using as much walking as feasible under the mount points. To exercise the `Composer` and demonstrate how it works, I've also switched `Devices` to stop being hardcoded to `/dev` _inside_ the backend but instead be a flat list of devices that is _mounted_ at `/dev`. While this PR does not expose/use it this way yet, with this PR, finally LiteBox core now has some of the fundamental machinery needed to eventually support `mount(2)` family of syscalls in the Linux shim. Future PRs will continue migrating more backends over, eventually allowing for the old layered file system to disappear, and replaced with this mount composition + (upcoming) overlay file system to support union mounting.
1 parent c4bbe3d commit eb52c59

7 files changed

Lines changed: 906 additions & 107 deletions

File tree

litebox/src/fs/backend.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ impl<'a> WalkingDirHandle<'a> {
211211
}
212212
}
213213

214-
/// Recover the concrete walking handle stored in this erased handle for `B`.
214+
/// Recover the concrete handle stored in this erased handle.
215+
///
216+
/// Intended to be called by backend implementations as `handle.into_typed::<Self>()` on
217+
/// handles that the resolver passed back to the same backend; it may panic otherwise.
215218
pub(super) fn into_typed<B: BackendHandles + 'static>(self) -> B::WalkingDirHandle<'a> {
216219
assert_eq!(
217220
self.backend_type,
@@ -234,6 +237,10 @@ impl FileHandle {
234237
}
235238
}
236239

240+
/// Borrow the concrete handle stored in this erased handle.
241+
///
242+
/// Intended to be called by backend implementations as `handle.get_typed::<Self>()` on handles
243+
/// that the resolver passed back to the same backend; it may panic otherwise.
237244
pub(super) fn get_typed<B: BackendHandles>(&self) -> &B::FileHandle {
238245
(&*self.raw as &dyn Any)
239246
.downcast_ref::<B::FileHandle>()
@@ -248,12 +255,20 @@ impl DirHandle {
248255
}
249256
}
250257

258+
/// Borrow the concrete handle stored in this erased handle.
259+
///
260+
/// Intended to be called by backend implementations as `handle.get_typed::<Self>()` on handles
261+
/// that the resolver passed back to the same backend; it may panic otherwise.
251262
pub(super) fn get_typed<B: BackendHandles>(&self) -> &B::DirHandle {
252263
(&*self.raw as &dyn Any)
253264
.downcast_ref::<B::DirHandle>()
254265
.expect("backend directory handle type mismatch")
255266
}
256267

268+
/// Recover the concrete handle stored in this erased handle.
269+
///
270+
/// Intended to be called by backend implementations as `handle.into_typed::<Self>()` on
271+
/// handles that the resolver passed back to the same backend; it may panic otherwise.
257272
pub(super) fn into_typed<B: BackendHandles>(self) -> B::DirHandle {
258273
let raw: Box<dyn Any> = self.raw;
259274
*raw.downcast::<B::DirHandle>()

0 commit comments

Comments
 (0)