-
Notifications
You must be signed in to change notification settings - Fork 8
Adding SafePOSIX Implementation of Syscalls
There are two main paths that can be taken in implementing a new system call. In both these paths, a system call is defined in Lind_GlibC.
First, a file in Lind_GlibC/sysdeps/nacl/ named X.c should be created for a system call X. In this file, a function to implement the system call should be defined with the name __X. This definition should be followed by weak_alias (__X, X) to denote the reference. (Aditional references can also be added here)
This file's full path (sysdeps/nacl/X.c) should then be added to the override_list in make_sysd_rules.py to make sure that this function is used.
This __X function should reference a function that can call the NACL_SYSCALL function. Such functions can be implemented in either sysdeps/nacl/lind_syscalls.c or sysdeps/nacl/irt_syscalls.c (after being defined in the respective header files).
To deliver the syscall to NaCl, add the interface of the syscall here:
Lind-GlibC/sysdeps/nacl/lind_syscalls.hLind-GlibC/sysdeps/nacl/lind_syscalls.c
To pack the syscall and send it to Repy, add Remote Procedure Call (RPC) here:
native_client/src/shared/platform/lind_platform.hnative_client/src/shared/platform/lind_platform.c
To have SafePOSIX do the actual work, edit the syscall's NaCl implementation here:
native_client/src/trusted/service_runtime/nacl_syscall_common.c
This file is where RPC is accepted and syscalls are delivered to the dispatcher. Have the new syscall included here:
nacl_repy/seattlelib/lind_server.mix
To match the syscall with its Lind implementation, add a new pairing here:
nacl_repy/seattlelib/dispatcher.repy
Add the syscall's Lind implementation here:
-
nacl_repy/seattlelib/lind_fs_calls.pyOR nacl_repy/seattlelib/lind_net_calls.py
In this directory, you will also need to create a new .repy file that will act as the syscall's handler. There you do any mandatory checking and, after the syscall is implemented, pack the result back to NaCl.