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");
.{string, buffer, log} := stn;
.{string, buffer, log, acs} := stn;
.{info} := log;
.{acs} := stn;
.{BufferID} := acs
FilesystemServiceListing := struct {
// The Root to match against of the file system
root: []u8,
// Replace with a slice here soon.
// The buffer to forward fs requests to.
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 {
log.info("VFSaur starting.")
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"
a := parse_str_to_path(full_path)
if a != null {
log.info(a.root)
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
}
OSPath := struct {root: []u8, path: []u8}
parse_str_to_path := fn(full_path: []u8): ?OSPath {
path := string.split_once(full_path, '/')
if path == null return null;
root := full_path[..full_path.len - path.len]
return OSPath.(root, path)
parse_str_to_path := fn(full_path: []u8): ?Path {
path := string.split_once(full_path, ':')
if path == null {
return null
}
root := full_path[..full_path.len - path.len]
bpath := full_path[full_path.len - path.len + 1..]
return Path.(root, bpath)
}

View file

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