|  | The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
    | 
Various miscellaneous functions to manipulate files and paths. More...
#include <freeradius-devel/util/talloc.h>#include <stdbool.h> Include dependency graph for file.h:
 Include dependency graph for file.h:Go to the source code of this file.
| Data Structures | |
| struct | fr_globdir_iter_t | 
| union | fr_globdir_iter_t.__unnamed136__ | 
| struct | fr_mkdir_chown_t | 
| Typedefs | |
| typedef int(* | fr_mkdir_func_t) (int fd, char const *path, void *uctx) | 
| Callback for allowing additional operations on newly created directories. | |
| Enumerations | |
| enum | fr_globdir_type_t { FR_GLOBDIR_INVALID = 0 , FR_GLOBDIR_FILE } | 
| Functions | |
| char const * | fr_cwd_strip (char const *filename) | 
| Intended to be used in logging functions to make output more readable. | |
| int | fr_dirfd (int *dirfd, char const **filename, char const *pathname) | 
| From a pathname, return fd and filename needed for *at() functions. | |
| int | fr_globdir_iter_free (fr_globdir_iter_t *iter) | 
| int | fr_globdir_iter_init (char const **filename, char const *dir, char const *pattern, fr_globdir_iter_t *iter) | 
| Initialize an iterator over filenames. | |
| int | fr_globdir_iter_next (char const **filename, fr_globdir_iter_t *iter) | 
| Get the next filename. | |
| 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. | |
| int | fr_mkdir_chown (int fd, char const *path, void *uctx) | 
| Callback for the common case of chown() of the directory. | |
| char * | fr_realpath (TALLOC_CTX *ctx, char const *path, ssize_t len) | 
| Convenience wrapper around realpath. | |
| ssize_t | fr_touch (int *fd_out, char const *filename, mode_t mode, bool mkdir, mode_t dir_mode) | 
| Create an empty file. | |
| int | fr_unlink (char const *filename) | 
| Remove a regular file from the filesystem. | |
Various miscellaneous functions to manipulate files and paths.
Definition in file file.h.
| struct fr_globdir_iter_t | 
| Data Fields | ||
|---|---|---|
| union fr_globdir_iter_t.__unnamed136__ | __unnamed__ | |
| char * | filename | |
| char * | path | |
| fr_globdir_type_t | type | |
| typedef int(* fr_mkdir_func_t) (int fd, char const *path, void *uctx) | 
Callback for allowing additional operations on newly created directories.
| [in] | fd | Of newly created directory. | 
| [in] | path | Either relative or full to the new directory. Should only be used for debug messages or functions that don't have an 'at' variant. | 
| [in] | uctx | User data to pass to callback. | 
| enum fr_globdir_type_t | 
| 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.
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int fr_globdir_iter_free | ( | fr_globdir_iter_t * | iter | ) | 
| int fr_globdir_iter_init | ( | char const ** | filename, | 
| char const * | dir, | ||
| char const * | pattern, | ||
| fr_globdir_iter_t * | iter | ||
| ) | 
Initialize an iterator over filenames.
| [out] | filename | the relative filename which should be opened | 
| [in] | dir | the directory to read | 
| [in] | pattern | the filename or pattern to read. Cannot be an absolute path. | 
| [in,out] | iter | the iteration structure. | 
Definition at line 694 of file file.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int fr_globdir_iter_next | ( | char const ** | filename, | 
| fr_globdir_iter_t * | iter | ||
| ) | 
Get the next filename.
fr_globdir_iter_init() do { ... use filename } while (fr_globdir_iter_next() == 1); fr_globdir_iter_free()
Definition at line 852 of file file.c.
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function: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.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int fr_unlink | ( | char const * | filename | ) | 
 1.9.8
 1.9.8