pub fn shm_set_credential(
shm: ShmHandle,
id: TaskHandle,
shm_perm: u32,
) -> StatusExpand description
Set the credentials associated to a shared memory
§Usage
Specify the credentials and declare usership for a given, owned, shared memory. a shared memory hold two instances of credentials. One for the shared memory owner and one for the samed memory user. This syscall provides a credentials configuration interface for both instances, only for the shared memory owner.
Credentials are based on a bitfield model, as defined in SHMPermission.
Setting credentials is synchronous. There is no specific capability associated
to this interface as the shared memory ownership is considered instead.
Setting shared memory credential is required before any usage of the shared memory, meaning that even the owner can’t manipulate a shared memory while the credentials have not been set at least one.
When setting credentials for another task, the shared memory is synchronously ready to be used by the other task without any other required action. The shared memory handle exchange with the other task is out of the current syscall and needs to be made through a task-specific, independent, communication channel.
a shared memory credentials can’t be set for a given target (owner or user) while this
very target has mapped the shared memory. This check is not done if the shared memory
is used without mapping (e.g. if the target uses DMA stream(s) that target this shared
memory without having it mapped). Such a behavior control is instead delegated to the integrator
through the analysis of the device tree configuration, including the shared memory declared
owner and the declared shared memories for which the dma-pool attribute is set.
This syscall returns Status::Invalid if the shared memory handle is out of the caller’s scope (if the caller is neither an owner or a user of the shared memory). This syscall returns Status::Invalid if any of the parameter is malformated or if the target task handle is not found. This syscall returns Status::Denied if the caller is a user of the shared memory, but do not own it. This syscall return Status::Busy if the target of the credential setting as mapped the shared memory. This syscall returns Status::Ok if the credentials are properly set.
§Example
match shm_set_credential(shmh, myhandle, SHMPermission::Map | SHMPermission::Write) {
Status::Ok => (),
any_err => return(any_err),
}§See also
Shared memory related syscalls:
get_shm_handle, map_shm, unmap_shm and shm_get_infos.