Description
SFS is a simple filesystem constisting of a tree of directory and file processes, which are differentiated by their alleged keytypes. SFS is designed to provide just enough functionality to interact with many UNIX applications built using an SFS-modified C library.
Directory traversals begin with the root directory process. The first time root is CALLed, it initializes itself as an empty directory process.

Figure 1: Typical directory structure
Directory and file processes obtain space dynamically from a space bank. SFS utilizes a process creator for file and directory creation.
Operations
- Check Alleged Key Type (OC = KT)
Returns the alleged type of the object.
| Reply | R1 | AKT_SFSF: Key is a file process. AKT_SFSD: Key is a directory process. |
- Read (OC = 0)
Read from the file. "rcv.len" indicates the number of bytes actually read.
| Request | L | File descriptor. |
| L | Bytes to read. |
| Result | RC_OK | Read successful. |
| 1 | File is not open. |
| 2 | This operation is only permitted on file processes. |
| 3 | Generic error. |
| 3 | The file descriptor's mode does not permit this operation. |
| Reply | B* | Bytes read. |
- Write (OC = 1)
Write to the file
| Request | L | File descriptor. |
| B* | Up to one page of data. |
| Result | RC_OK | Write successful. |
| 1 | File is not open. |
| 2 | This operation is only permitted on file processes. |
| 3 | Generic error. |
| 4 | File descriptor's mode does not permit this operation. |
| 5 | Out of space. |
| Reply | L | Number of bytes actually written. |
- Open (OC = 2)
Open a file for reading or writing
| Request | L | Flagsflags is one of O_RDONLY, O_WRONLY or O_RDWR which request opening the file read-only, write-only or read/write, respectively. |
| L | Mode (not currently implemented) |
| Result | RC_OK | Open successful. |
| 1 | Generic error. |
| 2 | File is already open. |
| Reply | L | File descriptor. |
- Close (OC = 3)
Close an open file.
| Request | L | File descriptor |
| Result | RC_OK | Close successful. |
| 1 | Generic error. |
| 2 | File is not open. |
- Seek (OC = 4)
reposition file read/write offset
| Request | L | File descriptor |
| L | Offset |
| L | WhenceIf whence is SEEK_SET, the offset is set to offset bytes. If whence is SEEK_CUR, the offset is set to its current location plus offset bytes. If whence is SEEK_END, the offset is set to the size of the file plus offset bytes. |
| Result | RC_OK | Seek successful. |
| 1 | Generic error. |
| 2 | Seek past EOF. |
| Reply | L | Resulting offset location. |
- Creat (OC = 5)
Create a new file or directory.
| Request | L | Flags (0=file, 1=directory) |
| Result | RC_OK | Creat successful. |
| 1 | This operation is valid only on directory processes. |
| 2 | A file by that name already exists. |
| 3 | Out of space. |
| Reply | SK0 | Start key for new file/directory. |
- Remove (OC = 6)
Remove a file or directory. Directories must be empty.
| Request | L | Flags (0=normal, 1=force) |
| Result | RC_OK | Remove successful. |
| 1 | Directory not empty. |
| 2 | Directory/file is still open and operation was not forced. |
- Readdir (OC = 7)
Read from a directory.
| Request | L | Flags (0=get start key, 1=get dir listing) |
| L | FileID |
| Result | RC_OK | Read successful. |
| 1 | Generic error. |
| 2 | Directory is not open. |
| Reply | SK0 | Start key for given FileID |
| B* | Directory listing (filename\255fileid\255filename\255fileid...) |
Mike Berry <berrym@eros-os.org>