fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
fl.h File Reference

Basic file lock API. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  flock_s
 File lock structure for managing a single file path. More...
 

Macros

#define flinit(fp)
 Initializes a unlocked, ready-to-use file lock structure with the given target lock file path. The file descriptor is set to -1 and is not opened until the file is locked with fllock().
 

Functions

int fllock (struct flock_s *fl)
 Locks the file at the given path. If a file descriptor cannot be obtained, or the file cannot be locked, an error code is returned.
 
int flunlock (struct flock_s *fl)
 Unlocks the file at the given path. If the file is not open, or the file cannot be unlocked, an error code is returned.
 

Detailed Description

Basic file lock API.

Macro Definition Documentation

◆ flinit

#define flinit ( fp)
Value:
((struct flock_s){.path = (fp), .fd = -1, .open = 0})
File lock structure for managing a single file path.
Definition fl.h:8

Initializes a unlocked, ready-to-use file lock structure with the given target lock file path. The file descriptor is set to -1 and is not opened until the file is locked with fllock().

Parameters
fpThe file path to use for the lock.
Returns
The initialized file lock structure.

Function Documentation

◆ fllock()

int fllock ( struct flock_s * fl)

Locks the file at the given path. If a file descriptor cannot be obtained, or the file cannot be locked, an error code is returned.

Note
The lock must be initialized with flinit() before calling fllock.
Parameters
flThe file lock structure.
Returns
0 if successful, otherwise a non-zero error code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flunlock()

int flunlock ( struct flock_s * fl)

Unlocks the file at the given path. If the file is not open, or the file cannot be unlocked, an error code is returned.

Parameters
flThe file lock structure.
Returns
0 if successful, otherwise a non-zero error code.
Here is the caller graph for this function: