feat: vfs - add dynamic filesystem mounts and safe unmount lifecycle
This commit is contained in:
1 parent
b1c55073c7
commit
ca5331c9db
12 files changed
+520
-259
No files matched your search
@@ -17,6 +17,15 @@ namespace Fs::FsProbe {
|
||||
static bool g_mounted[Drivers::Storage::Gpt::MaxPartitions] = {};
|
||||
static int g_driveForPart[Drivers::Storage::Gpt::MaxPartitions] = {};
|
||||
|
||||
// A successful probe returns an owned mount. Registration transfers that
|
||||
// ownership to the VFS; if registration loses a drive-slot race, release
|
||||
// the mount here so its driver, instance, and page allocations do not leak.
|
||||
static void DiscardUnregisteredDriver(Vfs::FsDriver* driver) {
|
||||
if (driver != nullptr && driver->Unmount != nullptr) {
|
||||
driver->Unmount(driver->ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void Register(ProbeFn fn) {
|
||||
if (g_probeCount < MaxProbes && fn) {
|
||||
g_probes[g_probeCount++] = fn;
|
||||
@@ -60,6 +69,7 @@ namespace Fs::FsProbe {
|
||||
return 1;
|
||||
}
|
||||
|
||||
DiscardUnregisteredDriver(driver);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -135,6 +145,7 @@ namespace Fs::FsProbe {
|
||||
<< partIndex << " as drive " << driveNum;
|
||||
return 0;
|
||||
}
|
||||
DiscardUnregisteredDriver(driver);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user