ssize_t NaClSyscallRestrict(int op, size_t desc_count, int *desc);
- NACL_RESTRICT_ENABLE: Enable blocking operation restriction enforcement. The desc_count and desc parameters are ignored.
- NACL_RESTRICT_DISABLE: Disable blocking operation enforcement. The desc_count and desc parameters are ignored.
- NACL_RESTRICT_SET: Sets the list of permitted descriptors to the provided list.
- NACL_RESTRICT_GET: The current list of permitted descriptors is written to desc, up to desc_count, and the number of written descriptors is returned (min of actual current list and desc_count, so only when returned value is less than desc_count can the caller be sure that the entire list of permitted descriptors have been retrieved).
- NACL_RESTRICT_ADD: Adds the provided descriptors to the current list of descriptors for which the invoking thread is permitted to make potentially blocking system calls. Returns the size of the permitted descriptor list for the thread after the add operation.
- NACL_RESTRICT_REMOVE: Removes the provided descriptors from list of permitted descriptors. Returns the size of the permitted descriptor list for the thread after the remove operation.
Threads are created with blocking operation restrictions disabled, and an empty list of permitted descriptors. The permitted descriptor list are not references to descriptors: if a permitted descriptor is closed and another duped into the same open descriptor table slot, operations on the new descriptor would also be permitted. It is the responsibility of the application program to properly maintain the list of permitted descriptors.
When potentially blocking/slow system calls are made on a descriptor not on the permitted list while blocking operation restriction is enabled, the system call returns -1 with errno set to EWOULDBLOCK. This occurs even if the system call would have returned immediately (e.g., data is available, lock not held) were blocking operation restriction not in force.
open, read, write, fstat, imc_accept, imc_connect, imc_sendmsg, imc_recvmsg, pthread_mutex_lock, pthread_cond_wait, pthread_sem_wait