WASM Execution Pipeline, File Dispatch & Supporting Infrastructure #52
+83
-142
File diff suppressed because it is too large
Load Diff
+64
-14
@@ -82,10 +82,6 @@ function GetDirectoryListingFrom(Path : pchar; BaseDir : pchar) : PHashMap;
|
||||
procedure FreeDirectoryListing(map : PHashMap);
|
||||
function changeDirectoryFrom(Path : pchar; BaseDir : pchar; var NewDir : pchar) : TIsPathValid;
|
||||
function MakeAbsolutePath(Path : PChar) : pchar;
|
||||
function makeAbsolutePathFrom(Path : pchar; BaseDir : pchar) : pchar;
|
||||
function resolvePathFrom(Path : pchar; BaseDir : pchar) : TIsPathValid;
|
||||
function GetDirectoryListingFrom(Path : pchar; BaseDir : pchar) : PHashMap;
|
||||
function changeDirectoryFrom(Path : pchar; BaseDir : pchar; var NewDir : pchar) : TIsPathValid;
|
||||
|
||||
//VFS Functions
|
||||
function newVirtualDirectory(Path : pchar) : TError;
|
||||
@@ -1161,6 +1157,13 @@ var
|
||||
pvVol : PStorage_Volume;
|
||||
pvStatus : puint32;
|
||||
pvDirList: PLinkedListBase;
|
||||
pvSplitRel : PLinkedListBase;
|
||||
pvSegCount : uint32;
|
||||
pvIdx : uint32;
|
||||
pvLeafName : pchar;
|
||||
pvParentDir : pchar;
|
||||
pvTmpConcat : pchar;
|
||||
pvEntry : PDirectory_Entry;
|
||||
|
||||
begin
|
||||
tracer.push_trace('vfs.PathValid.enter');
|
||||
@@ -1179,22 +1182,69 @@ begin
|
||||
RelPath[0] := '/';
|
||||
end;
|
||||
pvVol := PStorage_Volume(Obj^.Reference);
|
||||
{ Actually verify the path exists on the volume }
|
||||
{ Verify the path exists on the volume }
|
||||
if (pvVol^.filesystem <> nil) and (pvVol^.filesystem^.readDirCallback <> nil) then begin
|
||||
{ If RelPath is just '/' we're at volume root — always valid }
|
||||
if StringEquals(RelPath, '/') then begin
|
||||
PathValid := pvDirectory;
|
||||
end else begin
|
||||
{ Ask the filesystem if this directory actually exists }
|
||||
pvStatus := puint32(kalloc(4));
|
||||
pvStatus^ := 0;
|
||||
pvDirList := pvVol^.filesystem^.readDirCallback(pvVol, RelPath, pvStatus);
|
||||
if pvStatus^ = 0 then
|
||||
PathValid := pvDirectory
|
||||
else
|
||||
{ Split RelPath into parent directory and leaf name,
|
||||
then list the parent and look for the leaf entry. }
|
||||
pvSplitRel := STRLL_FromString(RelPath, '/');
|
||||
pvSegCount := STRLL_Size(pvSplitRel);
|
||||
if pvSegCount = 0 then begin
|
||||
PathValid := pvInvalid;
|
||||
if pvDirList <> nil then LL_Free(pvDirList);
|
||||
kfree(puint32(pvStatus));
|
||||
end else begin
|
||||
pvLeafName := STRLL_Get(pvSplitRel, pvSegCount - 1);
|
||||
{ Build parent directory path from all segments except the last }
|
||||
if pvSegCount <= 1 then begin
|
||||
pvParentDir := stringNew(1);
|
||||
pvParentDir[0] := '/';
|
||||
end else begin
|
||||
pvParentDir := stringNew(0);
|
||||
for pvIdx := 0 to pvSegCount - 2 do begin
|
||||
if stringSize(pvParentDir) > 0 then begin
|
||||
pvTmpConcat := stringConcat(pvParentDir, '/');
|
||||
kfree(void(pvParentDir));
|
||||
pvParentDir := pvTmpConcat;
|
||||
end;
|
||||
pvTmpConcat := stringConcat(pvParentDir, STRLL_Get(pvSplitRel, pvIdx));
|
||||
kfree(void(pvParentDir));
|
||||
pvParentDir := pvTmpConcat;
|
||||
end;
|
||||
end;
|
||||
{ List parent directory }
|
||||
pvStatus := puint32(kalloc(4));
|
||||
pvStatus^ := 0;
|
||||
pvDirList := pvVol^.filesystem^.readDirCallback(pvVol, pvParentDir, pvStatus);
|
||||
PathValid := pvInvalid;
|
||||
if (pvDirList <> nil) and (pvStatus^ = 0) and (LL_Size(pvDirList) > 0) then begin
|
||||
for pvIdx := 0 to LL_Size(pvDirList) - 1 do begin
|
||||
pvEntry := PDirectory_Entry(LL_Get(pvDirList, pvIdx));
|
||||
if (pvEntry <> nil) and (pvEntry^.fileName <> nil) then begin
|
||||
if stringEquals(pvEntry^.fileName, pvLeafName) then begin
|
||||
case pvEntry^.entryType of
|
||||
fileEntry: PathValid := pvFile;
|
||||
directoryEntry: PathValid := pvDirectory;
|
||||
mountEntry: PathValid := pvDirectory;
|
||||
end;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{ Free entry file names and list }
|
||||
for pvIdx := 0 to LL_Size(pvDirList) - 1 do begin
|
||||
pvEntry := PDirectory_Entry(LL_Get(pvDirList, pvIdx));
|
||||
if (pvEntry <> nil) and (pvEntry^.fileName <> nil) then
|
||||
kfree(void(pvEntry^.fileName));
|
||||
end;
|
||||
LL_Free(pvDirList);
|
||||
end else if pvDirList <> nil then
|
||||
LL_Free(pvDirList);
|
||||
kfree(puint32(pvStatus));
|
||||
kfree(void(pvParentDir));
|
||||
end;
|
||||
STRLL_Free(pvSplitRel);
|
||||
end;
|
||||
end else
|
||||
PathValid := pvInvalid;
|
||||
|
||||
@@ -30,7 +30,7 @@ procedure relayout;
|
||||
implementation
|
||||
|
||||
uses
|
||||
syslog;
|
||||
syslog, lists, lmemorymanager;
|
||||
|
||||
const
|
||||
DOCK_HEIGHT = 48;
|
||||
@@ -50,8 +50,6 @@ const
|
||||
SYSINFO_W = 480;
|
||||
SYSINFO_H = 560;
|
||||
|
||||
MAX_PROGRAMS = 16;
|
||||
|
||||
{ Animation }
|
||||
ANIM_SPEED = 12; { pixels per frame to slide }
|
||||
|
||||
@@ -62,10 +60,10 @@ type
|
||||
launch : TProgLaunchProc;
|
||||
active : boolean;
|
||||
end;
|
||||
PProgEntry = ^TProgEntry;
|
||||
|
||||
var
|
||||
programs : array[0..MAX_PROGRAMS-1] of TProgEntry;
|
||||
prog_count : uint32;
|
||||
programs : PLinkedListBase;
|
||||
|
||||
{ ---- Desktop UI elements ---- }
|
||||
var
|
||||
@@ -102,12 +100,15 @@ var
|
||||
Program Registry
|
||||
============================================================ }
|
||||
procedure registerProgram(name: pchar; launcher: TProgLaunchProc);
|
||||
var
|
||||
entry : PProgEntry;
|
||||
begin
|
||||
if prog_count >= MAX_PROGRAMS then exit;
|
||||
programs[prog_count].name := name;
|
||||
programs[prog_count].launch := launcher;
|
||||
programs[prog_count].active := true;
|
||||
inc(prog_count);
|
||||
if programs = nil then
|
||||
programs := LL_New(sizeof(TProgEntry));
|
||||
entry := PProgEntry(LL_Add(programs));
|
||||
entry^.name := name;
|
||||
entry^.launch := launcher;
|
||||
entry^.active := true;
|
||||
end;
|
||||
|
||||
{ ============================================================
|
||||
@@ -438,6 +439,7 @@ var
|
||||
code : uint32;
|
||||
target : Plv_obj;
|
||||
i, pi : uint32;
|
||||
entry : PProgEntry;
|
||||
begin
|
||||
code := lv_event_get_code(e);
|
||||
if code <> LV_EVENT_CLICKED then exit;
|
||||
@@ -446,10 +448,13 @@ begin
|
||||
for i := 0 to RESULTS_MAX_VISIBLE - 1 do begin
|
||||
if result_btns[i] = target then begin
|
||||
pi := result_prog[i];
|
||||
if (pi < prog_count) and programs[pi].active then begin
|
||||
syslog.logln('Desktop', 'Launching program');
|
||||
clearAndClose;
|
||||
programs[pi].launch;
|
||||
if (programs <> nil) and (pi < LL_Size(programs)) then begin
|
||||
entry := PProgEntry(LL_Get(programs, pi));
|
||||
if (entry <> nil) and entry^.active then begin
|
||||
syslog.logln('Desktop', 'Launching program');
|
||||
clearAndClose;
|
||||
entry^.launch;
|
||||
end;
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
@@ -550,6 +555,7 @@ var
|
||||
query : pchar;
|
||||
i, vis : uint32;
|
||||
panel_h : sint32;
|
||||
fentry : PProgEntry;
|
||||
begin
|
||||
if not results_open then exit;
|
||||
if results_panel = nil then exit;
|
||||
@@ -557,15 +563,18 @@ begin
|
||||
query := lv_textarea_get_text(search_ta);
|
||||
|
||||
vis := 0;
|
||||
for i := 0 to prog_count - 1 do begin
|
||||
if vis >= RESULTS_MAX_VISIBLE then break;
|
||||
if not programs[i].active then continue;
|
||||
if programs <> nil then begin
|
||||
for i := 0 to LL_Size(programs) - 1 do begin
|
||||
if vis >= RESULTS_MAX_VISIBLE then break;
|
||||
fentry := PProgEntry(LL_Get(programs, i));
|
||||
if (fentry = nil) or (not fentry^.active) then continue;
|
||||
|
||||
if (query = nil) or (query^ = #0) or ciContains(programs[i].name, query) then begin
|
||||
lv_label_set_text(result_lbls[vis], programs[i].name);
|
||||
result_prog[vis] := i;
|
||||
lv_obj_remove_flag(result_btns[vis], LV_OBJ_FLAG_HIDDEN);
|
||||
inc(vis);
|
||||
if (query = nil) or (query^ = #0) or ciContains(fentry^.name, query) then begin
|
||||
lv_label_set_text(result_lbls[vis], fentry^.name);
|
||||
result_prog[vis] := i;
|
||||
lv_obj_remove_flag(result_btns[vis], LV_OBJ_FLAG_HIDDEN);
|
||||
inc(vis);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -591,7 +600,8 @@ end;
|
||||
============================================================ }
|
||||
procedure search_event_cb(e: Plv_event); cdecl;
|
||||
var
|
||||
code : uint32;
|
||||
code : uint32;
|
||||
rentry : PProgEntry;
|
||||
begin
|
||||
code := lv_event_get_code(e);
|
||||
|
||||
@@ -621,9 +631,12 @@ begin
|
||||
else if code = LV_EVENT_READY then begin
|
||||
{ Enter pressed (one-line textarea) — launch first result }
|
||||
if results_visible > 0 then begin
|
||||
if result_prog[0] < prog_count then begin
|
||||
clearAndClose;
|
||||
programs[result_prog[0]].launch;
|
||||
if (programs <> nil) and (result_prog[0] < LL_Size(programs)) then begin
|
||||
rentry := PProgEntry(LL_Get(programs, result_prog[0]));
|
||||
if rentry <> nil then begin
|
||||
clearAndClose;
|
||||
rentry^.launch;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@@ -704,7 +717,6 @@ begin
|
||||
tracer.push_trace('desktop.init.enter');
|
||||
|
||||
sysinfo_win_id := 0;
|
||||
prog_count := 0;
|
||||
results_open := false;
|
||||
results_panel := nil;
|
||||
anim_closing := false;
|
||||
|
||||
@@ -50,7 +50,7 @@ procedure init;
|
||||
implementation
|
||||
|
||||
uses
|
||||
vfs, lmemorymanager, strings, tracer, syslog, util;
|
||||
vfs, storagetypes, lmemorymanager, strings, tracer, syslog, util;
|
||||
|
||||
type
|
||||
TFileHandlerEntry = record
|
||||
@@ -135,7 +135,7 @@ begin
|
||||
|
||||
{ 2. Open the file and read the header bytes }
|
||||
err := eNone;
|
||||
fh := vfs.OpenFile(absPath, omReadOnly, wmRewrite, false, @err);
|
||||
fh := vfs.OpenFile(absPath, omReadOnly, wmRewrite, @err);
|
||||
if fh = 0 then exit;
|
||||
|
||||
memset(uint32(@headerBuf[0]), 0, MAX_MAGIC_LEN);
|
||||
|
||||
@@ -21,7 +21,7 @@ procedure init;
|
||||
implementation
|
||||
|
||||
uses
|
||||
vfs, lmemorymanager, strings, syslog, util,
|
||||
vfs, storagetypes, lmemorymanager, strings, syslog, util,
|
||||
processmanager, proctypes, filedispatch,
|
||||
wasmshim, wasmio, wasmcleanup,
|
||||
wasm, wasm.types.builtin, wasm.types.context, wasm.types.constants;
|
||||
@@ -175,7 +175,7 @@ begin
|
||||
end;
|
||||
|
||||
err := eNone;
|
||||
fh := vfs.OpenFile(path, omReadOnly, wmRewrite, false, @err);
|
||||
fh := vfs.OpenFile(path, omReadOnly, wmRewrite, @err);
|
||||
if fh = 0 then begin
|
||||
kfree(void(buf));
|
||||
stdio.bufWriteStrLn(stderr_buf, 'WASM: cannot open file');
|
||||
|
||||
+6
-9
@@ -25,9 +25,9 @@ interface
|
||||
uses
|
||||
tracer, stdio, processmanager,
|
||||
//progs
|
||||
base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres, testcmd, ping,
|
||||
base64_prog, md5sum, dhclient, vbeinfo, testcmd, ping, meminfo, setres,
|
||||
//drivers
|
||||
ramdrive, drivermanagement, storagemanagement,
|
||||
ramdrive, drivermanagement,
|
||||
//network
|
||||
ipv4, arp, tcp,
|
||||
//dispatch
|
||||
@@ -40,13 +40,10 @@ procedure init();
|
||||
|
||||
implementation
|
||||
|
||||
uses kernel;
|
||||
|
||||
uses
|
||||
stdio,
|
||||
kernel,
|
||||
//command provider units
|
||||
kernel, cpu, drivermanagement, processmanager,
|
||||
arp, ipv4, tcp,
|
||||
cpu,
|
||||
diskcmd, usbcore, diskutil, notepad, partcmd, volcmd;
|
||||
|
||||
procedure init();
|
||||
@@ -70,8 +67,8 @@ begin
|
||||
diskcmd.init();
|
||||
partcmd.init();
|
||||
volcmd.init();
|
||||
diskutil.init;
|
||||
notepad.init;
|
||||
diskutil.init();
|
||||
notepad.init();
|
||||
md5sum.init();
|
||||
base64_prog.init();
|
||||
dhclient.init();
|
||||
|
||||
Reference in New Issue
Block a user