namespace: ashet.fs
Documentation
A file or directory on Ashet OS can be named with any legal UTF-8 sequence
that does not contain / and :. It is recommended to only create file names
that are actually typeable on the operating system tho.
There are some special file names:
- . is the "current directory" selector and does not add to the path.
- .. is the "parent directory" selector and navigates up in the directory hierarchy if possible.
- Any sequence of upper case ASCII letters and digits (A-Z, 0-9) that ends with : is a file system name. This name specifies
the root directory of a certain file system.
Paths are either a relative or absolute addyessing of a file system entity.
Paths are composed of a sequence of names, each name separated by /.
A file system name is only legal as the first element of a path sequence, making the path an absolute path.
There is a limit on how long a file/directory name can be, but there's no limit on how long a total path can be.
Here are some examples for valid paths:
- example.txt
- docs/wiki.txt
- SYS:/apps/editor/code
- USB0:/foo/../bar (which is equivalent to USB0:/bar)
The filesystem that is used to boot the OS from has an alias SYS: that is always a legal way to address this file system.
System Calls
syscall find_filesystem(in name: str, out id: FileSystemId)Finds a file system by name
Asynchronous Operations
async_call Sync()Flushes all open files to disk.
async_call GetFilesystemInfo(in fs_id: FileSystemId, out info: FileSystemInfo, out next: FileSystemId)Gets information about a file system. Also returns a
nextid that can be used to iterate over all filesystems. Thesystemfilesystem is guaranteed to be the first one.async_call OpenDrive(in fs_id: FileSystemId, in path: str, out dir: Directory)opens a directory on a filesystem
async_call OpenDir(in start_dir: Directory, in path: str, out dir: Directory)opens a directory relative to the given dir handle.
async_call ResetDirEnumeration(in dir: Directory)resets the directory iterator to the starting point
async_call EnumerateDir(in dir: Directory, out eof: bool, out info: FileInfo)returns the info for the current file or "eof", and advances the iterator to the next entry if possible
async_call Delete(in dir: Directory, in path: str, in recurse: bool)deletes a file or directory by the given path.
async_call MkDir(in dir: Directory, in path: str, in mkopen: bool, out new_dir: Directory)creates a new directory relative to dir. If
pathcontains subdirectories, all directories are created.async_call StatEntry(in dir: Directory, in path: str, out info: FileInfo)returns the type of the file/dir at path, also adds size and modification dates
async_call NearMove(in src_dir: Directory, in src_path: str, in dst_path: str)renames a file inside the same file system.
Note:
This is a cheap operation and does not require the copying of data.
async_call FarMove(in src_dir: Directory, in src_path: str, in dst_dir: Directory, in dst_path: str)moves a file or directory between two unrelated directories. Can also move between different file systems.
Note:
This syscall might copy the data.
async_call Copy(in src_dir: Directory, in src_path: str, in dst_dir: Directory, in dst_path: str)copies a file or directory between two unrelated directories. Can also move between different file systems.
async_call OpenFile(in dir: Directory, in path: str, in access: FileAccess, in mode: FileMode, out handle: File)opens a file from the given directory.
async_call Read(in file: File, in offset: u64, in buffer: bytebuf, out count: usize)directly reads data from a given offset into the file. no streaming API to the kernel
async_call Write(in file: File, in offset: u64, in buffer: bytestr, out count: usize)directly writes data to a given offset into the file. no streaming API to the kernel