1
0
Fork 0
forked from AbleOS/ableos

VFSaur swapped to slices and parse to exclude the :

This commit is contained in:
Able 2024-12-22 16:23:31 -06:00 committed by peony
parent 75db10c339
commit e21bb03912
2 changed files with 45 additions and 15 deletions

View file

@ -1,40 +1,70 @@
stn := @use("stn"); stn := @use("stn");
.{string, buffer, log} := stn; .{string, buffer, log, acs} := stn;
.{info} := log; .{info} := log;
.{acs} := stn;
.{BufferID} := acs .{BufferID} := acs
FilesystemServiceListing := struct { FilesystemServiceListing := struct {
// The Root to match against of the file system // The Root to match against of the file system
root: []u8, root: []u8,
// Replace with a slice here soon.
// The buffer to forward fs requests to. // The buffer to forward fs requests to.
buffer_id: BufferID, buffer_id: BufferID,
new := fn(root: []u8, buffer_id: BufferID): Self {
return .(root, buffer_id)
}
}
Path := struct {
root: []u8,
path: []u8,
}
MessageTypes := enum {
Create,
Delete,
// Used to register filesystem handlers.
Mount,
}
VFSMessage := struct {
msg_type: MessageTypes,
} }
main := fn(): int { main := fn(): int {
log.info("VFSaur starting.") log.info("VFSaur starting.")
vfs_buff := buffer.create("VFS") vfs_buff := buffer.create("VFS")
bid := BufferID.(0, 0)
fsl := FilesystemServiceListing.new("acs", bid)
fsl2 := FilesystemServiceListing.new("boot", bid)
full_path := "acs:/path/to/a/file" full_path := "acs:/path/to/a/file"
a := parse_str_to_path(full_path) a := parse_str_to_path(full_path)
if a != null { if a != null {
log.info(a.root) log.info(a.root)
log.info(a.path) log.info(a.path)
} }
vfs_event := VFSMessage.(MessageTypes.Mount)
loop {
buffer.recv(VFSMessage, vfs_buff, &vfs_event)
if vfs_event.msg_type == MessageTypes.Mount {
// TODO: get info from the message itself
fsl3 := FilesystemServiceListing.new("acs", bid)
}
// TODO: sleep till vfs_buff message
}
return 0 return 0
} }
OSPath := struct {root: []u8, path: []u8} parse_str_to_path := fn(full_path: []u8): ?Path {
path := string.split_once(full_path, ':')
parse_str_to_path := fn(full_path: []u8): ?OSPath { if path == null {
path := string.split_once(full_path, '/') return null
if path == null return null; }
root := full_path[..full_path.len - path.len]
root := full_path[..full_path.len - path.len] bpath := full_path[full_path.len - path.len + 1..]
return OSPath.(root, path) return Path.(root, bpath)
} }

View file

@ -50,8 +50,8 @@ path = "boot:///ps2_driver.hbf"
# [boot.limine.ableos.modules.angels_halo] # [boot.limine.ableos.modules.angels_halo]
# path = "boot:///angels_halo.hbf" # path = "boot:///angels_halo.hbf"
[boot.limine.ableos.modules.test] # [boot.limine.ableos.modules.test]
path = "boot:///test.hbf" # path = "boot:///test.hbf"
# [boot.limine.ableos.modules.vfsaur] [boot.limine.ableos.modules.vfsaur]
# path = "boot:///vfsaur.hbf" path = "boot:///vfsaur.hbf"