-
Notifications
You must be signed in to change notification settings - Fork 10
Architecture
Detailed here, this is the set of imported libraries that we are allowing for use while creating SafePOSIX.
The dispatcher receives system call requests from Native Client. Since SafePOSIX-Rust is loaded as a shared object, these RPC calls are direct function calls.
The dispatcher function receives calls in the format:
dispatcher(cageid: i32, callnum: i32, arg1: Arg, arg2: Arg, arg3: Arg, arg4: Arg, arg5: Arg, arg6: Arg)
Each call sends the cage ID number from which it is submitted and the syscall number as integers, followed by six arguments.
These six arguments are Unions, and have a set of allowed types (or None) which correspond to the types needed for the syscall. This allows us to use one dispatcher function in Rust for a variety of system calls, without having to serialize arguments.
The dispatcher then checks if the cage exists in the cage table, and if it doesn't, initializes a new cage. It then takes the cage object corresponding to that ID number, and calls the method corresponding to the sent call number. We use match
to call the correct function based on call number.
The cage table is protected by a RW lock. All system calls access the cage table as read, except for fork, exec, and exit which will need to manipulate the table.
When the system call method returns, the dispatcher returns the return/error code to NaCl.
- Cage ID (integer)
- Current Working Directory (String)
- Parent ID (integer)
- File Descriptor Table (Locked Hashmap of integers -> Descriptor Enums)
The file descriptor table is a hash map of fd integers to our file descriptor representations. File Descriptors are implemented as an Enum that can correspond to four descriptor types (File, Directory, Socket, File). Each of these descriptor types is a struct with its corresponding fields which can be seen in cage.rs
Each cage object has methods corresponding to each system call. These calls are implemented either as filesystem related calls, system related calls, or network related calls in their respective files.
Each system call either returns a return code, or an error code (which is generated from the errno Enum).