The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
flock.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* @file flock.h
5
* @brief advisory whole-file locks (flock).
6
*
7
* an open-file description holds a lock on its file: shared (many may
8
* hold one) or exclusive (one only). the locks are advisory: they stop
9
* other flock calls, not reads or writes. a description's lock goes when
10
* it is unlocked, or when the description's last descriptor closes.
11
*/
12
13
#include "
common/stdint.h
"
14
#include "
kernel/vfs/file.h
"
15
16
// flock operations (ABI, as in the libc's sys/file.h)
17
#define LOCK_SH 1
// a shared lock
18
#define LOCK_EX 2
// an exclusive lock
19
#define LOCK_NB 4
// with LOCK_SH or LOCK_EX: fail at once, do not wait
20
#define LOCK_UN 8
// release the lock
21
22
/**
23
* take, change or release a description's lock.
24
* @param file a filesystem file.
25
* @param operation LOCK_SH or LOCK_EX (with LOCK_NB), or LOCK_UN.
26
* @return 0, or -EWOULDBLOCK (LOCK_NB and another holds a conflicting
27
* lock), -ERESTARTSYS (a signal while waiting), -ENOLCK (the lock
28
* table is full), -EINVAL.
29
*/
30
int32_t
flock_apply
(
file_t
*
file
,
uint32_t
operation);
31
32
/**
33
* release the lock a description holds (its last descriptor closed).
34
*/
35
void
flock_release
(
file_t
*
file
);
stdint.h
flock_apply
int32_t flock_apply(file_t *file, uint32_t operation)
take, change or release a description's lock.
Definition
flock.c:70
flock_release
void flock_release(file_t *file)
release the lock a description holds (its last descriptor closed).
Definition
flock.c:131
file.h
file_t
struct file file_t
Definition
file.h:38
uint32_t
unsigned int uint32_t
Definition
fb.h:17
int32_t
int int32_t
Definition
stdint.h:14
file
an open-file description.
Definition
file.h:64
src
kernel
vfs
flock.h
Generated by
1.18.0