PatchworkOS
Loading...
Searching...
No Matches

Keys for sharing file descriptors between processes. More...

Data Structures

struct  key_entry_t
 Key entry. More...
 

Functions

void key_init (void)
 Initializes the key subsystem.
 
uint64_t key_share (key_t *key, file_t *file, clock_t timeout)
 Generates a key that can be used to retrieve the file within the specified timeout.
 
file_tkey_claim (key_t *key)
 Claims a shared file using the provided key.
 

Detailed Description

Keys for sharing file descriptors between processes.

Keys are used with the share() and claim() system calls to send files between processes.

Each key is a 64-bit one-time use randomly generated token that globally identifies a shared file.

Function Documentation

◆ key_claim()

file_t * key_claim ( key_t key)

Claims a shared file using the provided key.

Parameters
keyPointer to the key identifying the shared file.
Returns
On success, the claimed file. On failure, NULL and errno is set.

Definition at line 151 of file key.c.

References CONTAINER_OF, EINVAL, ENOENT, key_entry_t::entry, errno, key_entry_t::file, file, free(), keyList, keyLock, keyMap, list_remove(), map_get(), map_key_buffer(), map_remove(), NULL, and RWLOCK_WRITE_SCOPE.

Referenced by SYSCALL_DEFINE().

◆ key_init()

void key_init ( void  )

Initializes the key subsystem.

Definition at line 60 of file key.c.

References ERR, keyList, keyLock, keyMap, list_init(), map_init(), NULL, panic(), and rwlock_init().

Referenced by vfs_init().

◆ key_share()

uint64_t key_share ( key_t key,
file_t file,
clock_t  timeout 
)

Generates a key that can be used to retrieve the file within the specified timeout.

Parameters
keyOutput pointer to store the generated key.
fileThe file to share.
timeoutThe time until the shared file expires. If CLOCKS_NEVER, it never expires.
Returns
On success, a key that can be used to claim the file. On failure, ERR and errno is set.

Definition at line 70 of file key.c.

References CLOCKS_NEVER, DEREF, EINVAL, key_entry_t::entry, ERR, errno, key_entry_t::expiry, key_entry_t::file, file, free(), key_entry_t::key, key_generate(), keyList, keyLock, keyMap, list_entry_init(), LIST_FOR_EACH, list_length(), list_prepend(), list_push(), malloc(), map_entry_init(), map_insert(), map_key_buffer(), key_entry_t::mapEntry, NULL, REF, RWLOCK_WRITE_SCOPE, and timer_uptime().

Referenced by SYSCALL_DEFINE().