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) {
+2
View File
@@ -32,6 +32,8 @@ static constexpr int MAP_H = 48;
static constexpr int MAP_PAD = 16;
static constexpr int MAX_PARTS = 32;
static constexpr int MAX_DISKS = 32;
// Matches Fs::Vfs::MaxDrives; used for selecting a free mount target.
static constexpr int MAX_DRIVES = 64;
static constexpr int STATUS_H = 44;
static constexpr int TB_BTN_Y = 7;