fsd: the thox filesystem daemon¶
The filesystem on thox is managed by fsd.
Todo
This daemon occupies a special place as loading other binaries cannot take place without this one. How is this managed?
Todo
Metadata file structure suggested by Lyqyd:
fsd RPC bindings¶
The RPC calls provided by fsd are the following:
-
os.rpc.fs.
open
(path, mode)¶ Open a file descriptor on the given path. The mode can be one of the following:
- “r”
Open the file for reading.
- “w”
Open the file for writing. Deletes the destination file if it already existed. Copy on write is used.
In all cases, bytes will be returned; this comes from the fact that Lua strings are bytes before all.
The function returns the following:
If the request has succeeded,
true
followed by the numerical file descriptor to be used in subsequent calls.If the request has failed,
false
followed by an error message.
- Parameters
path (string) – Path of the file to open.
mode (string) – Opening mode.
- Returns
The response arguments.
- Return type
table
-
os.rpc.fs.
close
(fd)¶ Close the given file descriptor. The function returns the following:
If the request has succeeded,
true
.If the request has succeeded,
false
followed by an error message.
- Parameters
fd (number) – File descriptor to close.
- Returns
The response arguments.
- Return type
table
-
os.rpc.fs.
read
(fd, count)¶ Read
count
bytes from the file descriptor represented by its numerical identifierfd
. The function returns the bytes as a Lua string.- Parameters
fd (number) – File descriptor to use.
count (number) – Number of requested bytes.
- Returns
Up to
count
bytes.- Return type
string
-
os.rpc.fs.
write
(fd, bytes)¶ Write the given bytes to the given file descriptor.
- Parameters
fd (number) – File descriptor to use.
bytes (string) – The bytes to write.
- Returns
The number of written bytes.
- Return type
number
-
os.rpc.fs.
sync
(fd)¶ Synchronize the file’s in-core state with the storage device (what others call “flushing” for write handles).
- Parameters
fd (number) – File descriptor to use.
-
os.rpc.fs.
seek
(fd, whence, offset)¶ Seek to a position.
- Parameters
fd (number) – File descriptor to use.
whence (string) – “set”, “cur” or “end”.
offset (number) – The offset.
mode (string) – Opening mode.
- Returns
The new position.
- Return type
number
- Returns
The response arguments.
- Return type
table
-
os.rpc.fs.
close
(fd) Close the given file descriptor. The function returns the following:
If the request has succeeded,
true
.If the request has succeeded,
false
followed by an error message.
- Parameters
fd (number) – File descriptor to close.
- Returns
The response arguments.
- Return type
table
-
os.rpc.fs.
read
(fd, count) Read
count
bytes from the file descriptor represented by its numerical identifierfd
. The function returns the bytes as a Lua string.- Parameters
fd (number) – File descriptor to use.
count (number) – Number of requested bytes.
- Returns
Up to
count
bytes.- Return type
string
-
os.rpc.fs.
write
(fd, bytes) Write the given bytes to the given file descriptor.
- Parameters
fd (number) – File descriptor to use.
bytes (string) – The bytes to write.
- Returns
The number of written bytes.
- Return type
number
-
os.rpc.fs.
sync
(fd) Synchronize the file’s in-core state with the storage device (what others call “flushing” for write handles).
- Parameters
fd (number) – File descriptor to use.
-
os.rpc.fs.
seek
(fd, whence, offset) Seek to a position.
- Parameters
fd (number) – File descriptor to use.
whence (string) – “set”, “cur” or “end”.
offset (number) – The offset.
- Returns
The new position.
- Return type
number