feat: vfs - add dynamic filesystem mounts and safe unmount lifecycle

This commit is contained in:
2026-08-04 08:58:50 +02:00
parent b1c55073c7
commit ca5331c9db
12 changed files with 520 additions and 259 deletions
+27 -1
View File
@@ -150,7 +150,33 @@ void do_mount_partition() {
int global_idx = part_indices[dt.selected_part];
int driveNum = 1 + global_idx;
if (driveNum >= 16) driveNum = 15;
int mountedDrives[MAX_DRIVES];
int mountedCount = montauk::drivelist(mountedDrives, MAX_DRIVES);
bool occupied[MAX_DRIVES] = {};
for (int i = 0; i < mountedCount; i++) {
int mountedDrive = mountedDrives[i];
if (mountedDrive >= 0 && mountedDrive < MAX_DRIVES) {
occupied[mountedDrive] = true;
}
}
// Preserve the stable partition-to-drive mapping when it is available.
// Otherwise use the lowest free non-ramdisk drive in the full namespace.
if (driveNum >= MAX_DRIVES || occupied[driveNum]) {
driveNum = -1;
for (int candidate = 1; candidate < MAX_DRIVES; candidate++) {
if (!occupied[candidate]) {
driveNum = candidate;
break;
}
}
}
if (driveNum < 0) {
set_status("Mount failed (no free drive slot)");
return;
}
int r = montauk::fs_mount(global_idx, driveNum);
if (r < 0) {