1
0
Fork 0
forked from AbleOS/ableos
ableos/sysdata/programs/vfsaur/src/main.hb

70 lines
1.4 KiB
Plaintext

stn := @use("stn");
.{string, buffer, log, acs} := stn;
.{info} := log;
.{BufferID} := acs
FilesystemServiceListing := struct {
// The Root to match against of the file system
root: []u8,
// 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
}
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)
}