Fix USB volume discovery, automounting, and file saves

This commit is contained in:
Aaron committed 2026-11-01 20:22:07 +00:00
1 parent 53cc758e60
commit cebad0b583
8 files changed
+189 -27

No files matched your search

+13 -11
View File
@@ -1200,7 +1200,8 @@ begin
vol := findVolumeForPartition(device, part.LBA_start);
if vol <> nil then begin
freeB := uint64(vol^.freeSectors) * vol^.sectorSize;
freeStr := uiConcat(formatSizeStr(freeB), ' free');
if (vol^.lifecycleFlags and STORAGE_VOLUME_FLAG_FREE_UNKNOWN) <> 0 then freeStr := 'Free: unknown'
else freeStr := uiConcat(formatSizeStr(freeB), ' free');
lbl := lv_label_create(row);
lv_label_set_text(lbl, freeStr);
lv_obj_set_style_text_color(lbl, lv_color_make(100, 180, 130), 0);
@@ -1240,7 +1241,6 @@ var
dw : sint32;
i : uint32;
totalBytes : uint64;
usedSectors : uint64;
freeBytes : uint64;
volCnt : uint32;
devVolCnt : uint32;
@@ -1274,22 +1274,18 @@ begin
totalBytes := uint64(device^.maxSectorCount) * device^.sectorSize;
addInfoRow(detail, dw, 'Total Size', formatSizePrecise(totalBytes));
{ Compute free space from in-memory volume data (no I/O) }
usedSectors := 0;
{ Use the same cached partition geometry as Add Partition. Volumes may
still be undergoing filesystem probing after the device is published. }
devVolCnt := 0;
volCnt := driver.storage.vol.mgr.get_volume_count();
if volCnt > 0 then for i := 0 to volCnt - 1 do begin
vol := driver.storage.vol.mgr.get_volume(i);
if (vol <> nil) and (vol^.device = device) then begin
devVolCnt := devVolCnt + 1;
usedSectors := usedSectors + vol^.sectorCount;
end;
end;
if device^.maxSectorCount > usedSectors then
freeBytes := uint64(device^.maxSectorCount - usedSectors) * device^.sectorSize
else
freeBytes := 0;
addInfoRow(detail, dw, 'Free Space', formatSizePrecise(freeBytes));
freeBytes := uint64(driver.storage.vol.mgr.get_free_sector_count(device)) * device^.sectorSize;
addInfoRow(detail, dw, 'Unallocated Space', formatSizePrecise(freeBytes));
addInfoRow(detail, dw, 'Volumes', uiInt(devVolCnt));
{ Usage bar }
@@ -1352,7 +1348,8 @@ begin
{ Free space }
freeB := uint64(vol^.freeSectors) * vol^.sectorSize;
freeStr := uiConcat(formatSizeStr(freeB), ' free');
if (vol^.lifecycleFlags and STORAGE_VOLUME_FLAG_FREE_UNKNOWN) <> 0 then freeStr := 'Free: unknown'
else freeStr := uiConcat(formatSizeStr(freeB), ' free');
lbl := lv_label_create(row);
lv_label_set_text(lbl, freeStr);
lv_obj_set_style_text_color(lbl, lv_color_make(100, 180, 130), 0);
@@ -1494,6 +1491,10 @@ begin
usedBytes := totalBytes - freeBytes;
addInfoRow(detail, dw, 'Total Size', formatSizePrecise(totalBytes));
if (vol^.lifecycleFlags and STORAGE_VOLUME_FLAG_FREE_UNKNOWN) <> 0 then begin
addInfoRow(detail, dw, 'Free Space', 'Unknown');
addInfoRow(detail, dw, 'Used Space', 'Unknown');
end else begin
addInfoRow(detail, dw, 'Free Space', formatSizePrecise(freeBytes));
addInfoRow(detail, dw, 'Used Space', formatSizePrecise(usedBytes));
@@ -1502,6 +1503,7 @@ begin
addInfoRow(detail, dw, 'Usage', uiConcat(uiInt(pctUsed), '%'));
addUsageBar(detail, dw, usedBytes, totalBytes);
end;
end;
addInfoRow(detail, dw, 'Boot Drive', boolStr(vol^.isBootDrive));
+4 -2
View File
@@ -355,8 +355,10 @@ begin
proc.mgr.kill(state^.pid);
state^.pid := 0;
end;
freeState(state);
if state^.ta <> nil then lv_group_remove_obj(state^.ta);
state^.ta := nil;
driver.video.windows.destroyWindow(wid);
freeState(state);
end;
{ ============================================================
@@ -440,7 +442,7 @@ begin
written := driver.storage.vfs.WriteFile(fHandle, 0, puint8(buf), len);
driver.storage.vfs.CloseFile(fHandle);
kfree(void(buf));
if written = 0 then begin
if written <> len then begin
io.syslog.logln('NOTEPAD', 'saveFile: WriteFile returned 0');
showErrorMsgbox('Save Failed', 'File write failed. Check filesystem.');
updateStatusBar(state);
+3 -1
View File
@@ -179,7 +179,9 @@ begin
print('Size: '); printsize(vol^.sectorCount * vol^.sectorSize); println('');
print('Free: '); printsize(vol^.freeSectors * vol^.sectorSize); println('');
print('Free: ');
if (vol^.lifecycleFlags and STORAGE_VOLUME_FLAG_FREE_UNKNOWN) <> 0 then println('Unknown')
else begin printsize(vol^.freeSectors * vol^.sectorSize); println(''); end;
print('Boot Drive: ');
if vol^.isBootDrive then println('yes') else println('no');