The pyr8 Filesystem API provides the local containerâs filesystem as a service. By default, the pyr8 exposes the local Unix directory jsapi_fsroot as the filesystemâs root Directory capability. This can be set using the fs flag as shown below.
The pyr8 daemon will accept any directory for which the user has permission. If the root directory cannot be opened at initialization time, the server will exit with an error message.
Unlike traditional filesystems, there is no filesystem-specific permissions model. Rather, pyr8âs capabilities model is used to control access. The usual rules of capabilities apply with the following notable consequences:
The second consequence is notable, since most filesystem APIs permit parent directory traversal. However, parent traversal has been a rich source of both functional and security bugs. As a result, the feature is elided in the core API.
The filesystem is guaranteed to live as long as the pyr8 process itself, but no longer. The PyrOS deployment system may keep container filesystems and re-use them, but the filesystem does not guarantee atomic operations or consistency. Applications that require data consistency on the local filesystem should use transactions logs and must accept rollbacks under some circumstances. Applications requiring both consistency and atomicity must use a networked API.
A directory is a container class containing file objects and directory objects.
At initialization, the processâs root directory is bound to pyr8.fs. Any directory capability can be provided to other threads, granting shared access to the underlying container filesystem.
When the standard library has been loaded, the Directory delegate class does not have a cap method, and anywhere a method takes a filename it also allows a path relative to this directory.
A file is an object that exposes a read/write API to local storage. Bytes written to a file have a zero-indexed position and the object is seekable in the usual way. Local storage is not guaranteed to be implemented by physical, permanent storage: under some circumstances, the file object may be implemented by memory. No files are created at pyr8 initialization time. Files can be created with the create() and createdir() methods of a directory object.
When the standard library has been loaded, the File delegate class does not have the cap method.