The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
flock.h File Reference

advisory whole-file locks (flock). More...

#include "common/stdint.h"
#include "kernel/vfs/file.h"

Go to the source code of this file.

Macros

#define LOCK_SH   1
#define LOCK_EX   2
#define LOCK_NB   4
#define LOCK_UN   8

Functions

int32_t flock_apply (file_t *file, uint32_t operation)
 take, change or release a description's lock.
void flock_release (file_t *file)
 release the lock a description holds (its last descriptor closed).

Detailed Description

advisory whole-file locks (flock).

an open-file description holds a lock on its file: shared (many may hold one) or exclusive (one only). the locks are advisory: they stop other flock calls, not reads or writes. a description's lock goes when it is unlocked, or when the description's last descriptor closes.

Macro Definition Documentation

◆ LOCK_SH

#define LOCK_SH   1

◆ LOCK_EX

#define LOCK_EX   2

◆ LOCK_NB

#define LOCK_NB   4

◆ LOCK_UN

#define LOCK_UN   8

Function Documentation

◆ flock_apply()

int32_t flock_apply ( file_t * file,
uint32_t operation )

take, change or release a description's lock.

Parameters
filea filesystem file.
operationLOCK_SH or LOCK_EX (with LOCK_NB), or LOCK_UN.
Returns
0, or -EWOULDBLOCK (LOCK_NB and another holds a conflicting lock), -ERESTARTSYS (a signal while waiting), -ENOLCK (the lock table is full), -EINVAL.

◆ flock_release()

void flock_release ( file_t * file)

release the lock a description holds (its last descriptor closed).