The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Various miscellaneous functions to manipulate files and paths. More...
#include <sys/param.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/value.h>
Go to the source code of this file.
Functions | |
static ssize_t | _fr_mkdir (int *fd_out, char *start, char *path, mode_t mode, fr_mkdir_func_t func, void *uctx) |
char const * | fr_cwd_strip (char const *filename) |
Intended to be used in logging functions to make output more readable. More... | |
int | fr_dirfd (int *dirfd, char const **filename, char const *pathname) |
From a pathname, return fd and filename needed for *at() functions. More... | |
ssize_t | fr_mkdir (int *fd_out, char const *path, ssize_t len, mode_t mode, fr_mkdir_func_t func, void *uctx) |
Create directories that are missing in the specified path. More... | |
int | fr_mkdir_chown (int fd, char const *path, void *uctx) |
Callback for the common case of chown() of the directory. More... | |
char * | fr_realpath (TALLOC_CTX *ctx, char const *path, ssize_t len) |
Convenience wrapper around realpath. More... | |
ssize_t | fr_touch (int *fd_out, char const *filename, mode_t mode, bool mkdir, mode_t dir_mode) |
Create an empty file. More... | |
int | fr_unlink (char const *filename) |
Remove a regular file from the filesystem. More... | |
Various miscellaneous functions to manipulate files and paths.
Definition in file file.c.
|
static |
char const* fr_cwd_strip | ( | char const * | filename | ) |
Intended to be used in logging functions to make output more readable.
This function is not performant and should probably not be used at runtime.
[in] | filename | to strip working directory from. |
Definition at line 384 of file file.c.
int fr_dirfd | ( | int * | dirfd, |
char const ** | filename, | ||
char const * | pathname | ||
) |
From a pathname, return fd and filename needed for *at() functions.
[in] | dirfd | points to place to store the dirfd |
[in] | filename | points to placd to store a pointer into pathname that points to the filename |
[in] | pathname | the full pathname of the file |
Definition at line 412 of file file.c.
ssize_t fr_mkdir | ( | int * | fd_out, |
char const * | path, | ||
ssize_t | len, | ||
mode_t | mode, | ||
fr_mkdir_func_t | func, | ||
void * | uctx | ||
) |
Create directories that are missing in the specified path.
[out] | fd_out | If not NULL, will contain a file descriptor for the deepest path component created. |
[in] | path | to populate with directories. |
[in] | len | Length of the path string. |
[in] | mode | for new directories. |
[in] | func | to call each time a new directory is created. |
[in] | uctx | to pass to func. |
Definition at line 219 of file file.c.
int fr_mkdir_chown | ( | int | fd, |
char const * | path, | ||
void * | uctx | ||
) |
char* fr_realpath | ( | TALLOC_CTX * | ctx, |
char const * | path, | ||
ssize_t | len | ||
) |
Convenience wrapper around realpath.
Wraps realpath, but takes a path with an explicit length, and returns the result in a talloced buffer.
On error, errno is set, and the string version of the error is available with fr_strerror().
[in] | ctx | in which to allocate the result. |
[in] | path | To convert to an absolute path. |
[in] | len | How much of 'path' to read. If < 0, then the entire path will be used. |
Definition at line 284 of file file.c.
Create an empty file.
[out] | fd_out | If not NULL, will contain a file descriptor for the file we just opened. |
[in] | filename | path to file. |
[in] | mode | Specifies the file mode bits be applied. |
[in] | mkdir | Whether we should create directories for any missing path components. |
[in] | dir_mode | Mode of any directories created. |
Definition at line 323 of file file.c.
int fr_unlink | ( | char const * | filename | ) |