#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
#include <freeradius-devel/server/exfile.h>
#include <freeradius-devel/server/trigger.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/perm.h>
#include <freeradius-devel/util/syserror.h>
#include <sys/stat.h>
#include <fcntl.h>
Go to the source code of this file.
|
static int | _exfile_free (exfile_t *ef) |
|
static void | exfile_cleanup_entry (exfile_t *ef, exfile_entry_t *entry) |
|
int | exfile_close (exfile_t *ef, int fd) |
| Close the log file. More...
|
|
static int | exfile_close_lock (exfile_t *ef, int fd) |
|
void | exfile_enable_triggers (exfile_t *ef, CONF_SECTION *conf, char const *trigger_prefix, fr_pair_list_t *trigger_args) |
| Enable triggers for an exfiles handle. More...
|
|
exfile_t * | exfile_init (TALLOC_CTX *ctx, uint32_t max_entries, fr_time_delta_t max_idle, bool locking) |
| Initialize a way for multiple threads to log to one or more files. More...
|
|
int | exfile_open (exfile_t *ef, char const *filename, mode_t permissions, off_t *offset) |
| Open a new log file, or maybe an existing one. More...
|
|
static int | exfile_open_lock (exfile_t *ef, char const *filename, mode_t permissions, off_t *offset) |
|
static int | exfile_open_mkdir (exfile_t *ef, char const *filename, mode_t permissions) |
|
static void | exfile_trigger_exec (exfile_t *ef, exfile_entry_t *entry, char const *name_suffix) |
| Send an exfile trigger. More...
|
|
◆ exfile_entry_t
Definition at line 39 of file exfile.c.
Data Fields |
int |
fd |
File descriptor associated with an entry. |
char * |
filename |
Filename. |
uint32_t |
hash |
Hash for cheap comparison. |
fr_time_t |
last_used |
Last time the entry was used. |
dev_t |
st_dev |
device inode |
ino_t |
st_ino |
inode number |
◆ exfile_s
◆ MAX_TRY_LOCK
How many times we attempt to acquire a lock.
before giving up.
Definition at line 62 of file exfile.c.
◆ _exfile_free()
static int _exfile_free |
( |
exfile_t * |
ef | ) |
|
|
static |
◆ exfile_cleanup_entry()
◆ exfile_close()
int exfile_close |
( |
exfile_t * |
ef, |
|
|
int |
fd |
|
) |
| |
Close the log file.
Really just return it to the pool.
When multithreaded, the FD is locked via a mutex. This way we're sure that no other thread is writing to the file. This function will unlock the mutex, so that other threads can write to the file.
- Parameters
-
ef | The logfile context returned from exfile_init. |
fd | the FD to close (i.e. return to the pool). |
- Returns
- 0 on success.
- -1 on failure.
Definition at line 562 of file exfile.c.
◆ exfile_close_lock()
static int exfile_close_lock |
( |
exfile_t * |
ef, |
|
|
int |
fd |
|
) |
| |
|
static |
◆ exfile_enable_triggers()
Enable triggers for an exfiles handle.
- Parameters
-
[in] | ef | to enable triggers for. |
[in] | conf | section to search for triggers in. |
[in] | trigger_prefix | prefix to prepend to all trigger names. Usually a path to the module's trigger configuration .e.g. modules.<name>.file <trigger name> is appended to form the complete path. |
[in] | trigger_args | to make available in any triggers executed by the exfile api. Exfile-File is automatically added to this list. |
Definition at line 196 of file exfile.c.
◆ exfile_init()
Initialize a way for multiple threads to log to one or more files.
- Parameters
-
ctx | The talloc context |
max_entries | Max file descriptors to cache, and manage locks for. |
max_idle | Maximum time a file descriptor can be idle before it's closed. |
locking | whether or not to lock the files. |
- Returns
- new context.
- NULL on error.
Definition at line 148 of file exfile.c.
◆ exfile_open()
Open a new log file, or maybe an existing one.
When multithreaded, the FD is locked via a mutex. This way we're sure that no other thread is writing to the file.
- Parameters
-
ef | The logfile context returned from exfile_init(). |
filename | the file to open. |
permissions | to use. |
offset | Optional pointer to store offset in when seeking the end of file. |
- Returns
- FD used to write to the file.
- -1 on failure.
Definition at line 506 of file exfile.c.
◆ exfile_open_lock()
static int exfile_open_lock |
( |
exfile_t * |
ef, |
|
|
char const * |
filename, |
|
|
mode_t |
permissions, |
|
|
off_t * |
offset |
|
) |
| |
|
static |
◆ exfile_open_mkdir()
static int exfile_open_mkdir |
( |
exfile_t * |
ef, |
|
|
char const * |
filename, |
|
|
mode_t |
permissions |
|
) |
| |
|
static |
◆ exfile_trigger_exec()
Send an exfile trigger.
- Parameters
-
[in] | ef | to send trigger for. |
[in] | entry | for the file that the event occurred on. |
[in] | name_suffix | trigger name suffix. |
Definition at line 70 of file exfile.c.