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

Basic file lock implementation. More...

#include "fl.h"
#include <assert.h>
#include <fcntl.h>
#include <stddef.h>
#include <sys/file.h>
#include <unistd.h>
Include dependency graph for fl.c:

Functions

static int flopen (struct flock_s *fl)
 Opens the file at the given path and updates the file lock structure with the file descriptor. If the file is already open, the file descriptor is not updated and the function will return successfully. If the file cannot be opened, the error code is returned via the file lock structure.
 
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 implementation.

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:

◆ flopen()

static int flopen ( struct flock_s * fl)
static

Opens the file at the given path and updates the file lock structure with the file descriptor. If the file is already open, the file descriptor is not updated and the function will return successfully. If the file cannot be opened, the error code is returned via the file lock structure.

Parameters
flThe file lock structure to update.
Returns
0 if successful, otherwise a non-zero error code.
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: