GNUnet debian-0.24.3-3-g2b3c3659e
disk.c File Reference

disk IO convenience methods More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "disk.h"
#include <sys/types.h>
Include dependency graph for disk.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_DISK_PipeHandle
 Handle used to manage a pipe. More...
 
struct  GetFileSizeData
 Closure for the recursion to determine the file size of a directory. More...
 
struct  GlobClosure
 
struct  GNUNET_DISK_MapHandle
 Handle for a memory-mapping operation. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "util-disk", __VA_ARGS__)
 
#define LOG_STRERROR(kind, syscall)    GNUNET_log_from_strerror (kind, "util-disk", syscall)
 
#define LOG_STRERROR_FILE(kind, syscall, filename)    GNUNET_log_from_strerror_file (kind, "util-disk", syscall, filename)
 
#define COPY_BLK_SIZE   65536
 Block size for IO for copying files. More...
 
#define _IFMT   0170000 /* type of file */
 
#define _IFLNK   0120000 /* symbolic link */
 
#define S_ISLNK(m)   (((m)&_IFMT) == _IFLNK)
 
#define MAP_FAILED   ((void *) -1)
 

Functions

static int translate_unix_perms (enum GNUNET_DISK_AccessPermissions perm)
 Translate GNUnet-internal permission bitmap to UNIX file access permission bitmap. More...
 
static enum GNUNET_GenericReturnValue get_size_rec (void *cls, const char *fn)
 Iterate over all files in the given directory and accumulate their size. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
 Checks whether a handle is invalid. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, off_t *size)
 Get the size of an open file. More...
 
off_t GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
 Move the read/write pointer in a file. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size (const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
 Get the size of the file (or directory) of the given file (in bytes). More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t *dev, uint64_t *ino)
 Obtain some unique identifiers for the given file that can be used to identify it in the local system. More...
 
static char * mktemp_name (const char *t)
 Create the name for a temporary file or directory from a template. More...
 
void GNUNET_DISK_fix_permissions (const char *fn, int require_uid_match, int require_gid_match)
 Update POSIX permissions mask of a file on disk. More...
 
char * GNUNET_DISK_mkdtemp (const char *t)
 Create an (empty) temporary directory on disk. More...
 
char * GNUNET_DISK_file_backup (const char *fil)
 Move a file out of the way (create a backup) by renaming it to "orig.NUM~" where NUM is the smallest number that is not used yet. More...
 
char * GNUNET_DISK_mktemp (const char *t)
 Create an (empty) temporary file on disk. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test (const char *fil, int is_readable)
 Test if fil is a directory and listable. More...
 
static enum GNUNET_GenericReturnValue file_test_internal (const char *fil, int amode)
 Check if fil can be accessed using amode. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test (const char *fil)
 Check that fil corresponds to a filename (of a file that exists and that is not a directory). More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test_read (const char *fil)
 Check that fil corresponds to a filename and the file has read permissions. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create (const char *dir)
 Implementation of "mkdir -p". More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file (const char *filename)
 Create the directory structure for storing a file. More...
 
ssize_t GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
 Read the contents of a binary file into a buffer. More...
 
ssize_t GNUNET_DISK_fn_read (const char *fn, void *result, size_t len)
 Read the contents of a binary file into a buffer. More...
 
ssize_t GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
 Write a buffer to a file. More...
 
ssize_t GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
 Write a buffer to a file, blocking, if necessary. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_fn_write (const char *fn, const void *buf, size_t buf_size, enum GNUNET_DISK_AccessPermissions mode)
 Write a buffer to a file atomically. More...
 
int GNUNET_DISK_directory_scan (const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
 Scan a directory for files. More...
 
static bool glob_match (const char *pattern, const char *str)
 Check for a simple wildcard match. More...
 
static enum GNUNET_GenericReturnValue glob_cb (void *cls, const char *filename)
 Function called with a filename. More...
 
int GNUNET_DISK_glob (const char *glob_pattern, GNUNET_FileNameCallback callback, void *callback_cls)
 Find all files matching a glob pattern. More...
 
static enum GNUNET_GenericReturnValue remove_helper (void *unused, const char *fn)
 Function that removes the given directory by calling GNUNET_DISK_directory_remove(). More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove (const char *filename)
 Remove all files in a directory (rm -rf). More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_copy (const char *src, const char *dst)
 Copy a file. More...
 
void GNUNET_DISK_filename_canonicalize (char *fn)
 Removes special characters as ':' from a filename. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_change_owner (const char *filename, const char *user)
 Change owner of a file. More...
 
struct GNUNET_DISK_FileHandleGNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
 Open a file. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h)
 Close an open file. More...
 
struct GNUNET_DISK_FileHandleGNUNET_DISK_get_handle_from_int_fd (int fno)
 Get a handle from a native integer FD. More...
 
struct GNUNET_DISK_FileHandleGNUNET_DISK_get_handle_from_native (FILE *fd)
 Get a handle from a native FD. More...
 
void * GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
 Map a file into memory. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h)
 Unmap a file. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h)
 Write file changes to disk. More...
 
struct GNUNET_DISK_PipeHandleGNUNET_DISK_pipe (enum GNUNET_DISK_PipeFlags pf)
 Creates an interprocess channel. More...
 
struct GNUNET_DISK_PipeHandleGNUNET_DISK_pipe_from_fd (enum GNUNET_DISK_PipeFlags pf, int fd[2])
 Creates a pipe object from a couple of file descriptors. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd end)
 Closes one half of an interprocess channel. More...
 
struct GNUNET_DISK_FileHandleGNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd end)
 Detaches one of the ends from the pipe. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p)
 Closes an interprocess channel. More...
 
const struct GNUNET_DISK_FileHandleGNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
 Get the handle to a particular pipe end. More...
 
enum GNUNET_GenericReturnValue GNUNET_DISK_internal_file_handle_ (const struct GNUNET_DISK_FileHandle *fh, int *dst)
 Retrieve OS file handle. More...
 
static enum GNUNET_GenericReturnValue purge_cfg_dir (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Helper function for GNUNET_DISK_purge_cfg_dir. More...
 
void GNUNET_DISK_purge_cfg_dir (const struct GNUNET_OS_ProjectData *pd, const char *cfg_filename, const char *option)
 Remove the directory given under option in section [PATHS] in configuration under cfg_filename. More...
 

Detailed Description

disk IO convenience methods

Author
Christian Grothoff
Nils Durner

Definition in file disk.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "util-disk", __VA_ARGS__)

Definition at line 31 of file disk.c.

◆ LOG_STRERROR

#define LOG_STRERROR (   kind,
  syscall 
)     GNUNET_log_from_strerror (kind, "util-disk", syscall)

Definition at line 33 of file disk.c.

◆ LOG_STRERROR_FILE

#define LOG_STRERROR_FILE (   kind,
  syscall,
  filename 
)     GNUNET_log_from_strerror_file (kind, "util-disk", syscall, filename)

Definition at line 36 of file disk.c.

◆ COPY_BLK_SIZE

#define COPY_BLK_SIZE   65536

Block size for IO for copying files.

Definition at line 42 of file disk.c.

◆ _IFMT

#define _IFMT   0170000 /* type of file */

Definition at line 59 of file disk.c.

◆ _IFLNK

#define _IFLNK   0120000 /* symbolic link */

Definition at line 60 of file disk.c.

◆ S_ISLNK

#define S_ISLNK (   m)    (((m)&_IFMT) == _IFLNK)

Definition at line 61 of file disk.c.

◆ MAP_FAILED

#define MAP_FAILED   ((void *) -1)

Definition at line 1399 of file disk.c.

Function Documentation

◆ translate_unix_perms()

static int translate_unix_perms ( enum GNUNET_DISK_AccessPermissions  perm)
static

Translate GNUnet-internal permission bitmap to UNIX file access permission bitmap.

Parameters
permfile permissions, GNUnet style
Returns
file permissions, UNIX style

Definition at line 109 of file disk.c.

110{
111 int mode;
112
113 mode = 0;
115 mode |= S_IRUSR;
117 mode |= S_IWUSR;
119 mode |= S_IXUSR;
121 mode |= S_IRGRP;
123 mode |= S_IWGRP;
125 mode |= S_IXGRP;
127 mode |= S_IROTH;
129 mode |= S_IWOTH;
131 mode |= S_IXOTH;
132
133 return mode;
134}
static enum @44 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
@ GNUNET_DISK_PERM_OTHER_EXEC
Everybody can execute.
@ GNUNET_DISK_PERM_USER_EXEC
Owner can execute.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_GROUP_EXEC
Group can execute.
@ GNUNET_DISK_PERM_GROUP_WRITE
Group can write.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
@ GNUNET_DISK_PERM_OTHER_WRITE
Everybody can write.

References GNUNET_DISK_PERM_GROUP_EXEC, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_GROUP_WRITE, GNUNET_DISK_PERM_OTHER_EXEC, GNUNET_DISK_PERM_OTHER_READ, GNUNET_DISK_PERM_OTHER_WRITE, GNUNET_DISK_PERM_USER_EXEC, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, and mode.

Referenced by GNUNET_DISK_file_backup(), GNUNET_DISK_file_open(), and GNUNET_DISK_fn_write().

Here is the caller graph for this function:

◆ get_size_rec()

static enum GNUNET_GenericReturnValue get_size_rec ( void *  cls,
const char *  fn 
)
static

Iterate over all files in the given directory and accumulate their size.

Parameters
clsclosure of type struct GetFileSizeData
fncurrent filename we are looking at
Returns
GNUNET_SYSERR on serious errors, otherwise GNUNET_OK

Definition at line 146 of file disk.c.

147{
148 struct GetFileSizeData *gfsd = cls;
149
150#if defined(HAVE_STAT64) && \
151 ! (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
152 struct stat64 buf;
153
154 if (0 != lstat64 (fn, &buf))
155 {
157 return GNUNET_SYSERR;
158 }
159#else
160 struct stat buf;
161
162 if (0 != lstat (fn, &buf))
163 {
165 return GNUNET_SYSERR;
166 }
167#endif
168 if ((S_ISDIR (buf.st_mode)) && (gfsd->single_file_mode == GNUNET_YES))
169 {
170 errno = EISDIR;
171 return GNUNET_SYSERR;
172 }
173 if ((S_ISLNK (buf.st_mode)) && (gfsd->include_sym_links == GNUNET_NO))
174 {
175 char linkdst[PATH_MAX];
176 if (NULL == realpath (fn, linkdst))
177 {
179 return GNUNET_SYSERR;
180 }
181 return get_size_rec(gfsd, linkdst);
182 }
183 if ((! S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))
184 gfsd->total += buf.st_size;
185 if ((S_ISDIR (buf.st_mode)) && (0 == access (fn, X_OK)) &&
186 ((! S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)))
187 {
188 if (GNUNET_SYSERR ==
191 gfsd))
192 return GNUNET_SYSERR;
193 }
194 return GNUNET_OK;
195}
static enum GNUNET_GenericReturnValue get_size_rec(void *cls, const char *fn)
Iterate over all files in the given directory and accumulate their size.
Definition: disk.c:146
#define LOG_STRERROR_FILE(kind, syscall, filename)
Definition: disk.c:36
#define S_ISLNK(m)
Definition: disk.c:61
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition: disk.c:839
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_DEBUG
#define PATH_MAX
Assumed maximum path length.
Definition: platform.h:242
Closure for the recursion to determine the file size of a directory.
Definition: disk.c:83
uint64_t total
Set to the total file size.
Definition: disk.c:87
int include_sym_links
GNUNET_YES if symbolic links should be included.
Definition: disk.c:92
int single_file_mode
GNUNET_YES if mode is file-only (return total == -1 for directories).
Definition: disk.c:97

References get_size_rec(), GNUNET_DISK_directory_scan(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GetFileSizeData::include_sym_links, LOG_STRERROR_FILE, PATH_MAX, S_ISLNK, GetFileSizeData::single_file_mode, and GetFileSizeData::total.

Referenced by get_size_rec(), and GNUNET_DISK_file_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mktemp_name()

static char * mktemp_name ( const char *  t)
static

Create the name for a temporary file or directory from a template.

Parameters
ttemplate (without XXXXX or "/tmp/")
Returns
name ready for passing to 'mktemp' or 'mkdtemp', NULL on error

Definition at line 306 of file disk.c.

307{
308 const char *tmpdir;
309 char *tmpl;
310 char *fn;
311
312 if ((t[0] != '/') && (t[0] != '\\'))
313 {
314 /* FIXME: This uses system codepage on W32, not UTF-8 */
315 tmpdir = getenv ("TMPDIR");
316 if (NULL == tmpdir)
317 tmpdir = getenv ("TMP");
318 if (NULL == tmpdir)
319 tmpdir = getenv ("TEMP");
320 if (NULL == tmpdir)
321 tmpdir = "/tmp";
322 GNUNET_asprintf (&tmpl, "%s/%s%s", tmpdir, t, "XXXXXX");
323 }
324 else
325 {
326 GNUNET_asprintf (&tmpl, "%s%s", t, "XXXXXX");
327 }
328 fn = tmpl;
329 return fn;
330}
char * getenv()
static struct GNUNET_SCHEDULER_Task * t
Main task.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.

References getenv(), GNUNET_asprintf(), and t.

Referenced by GNUNET_DISK_mkdtemp(), and GNUNET_DISK_mktemp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_test_internal()

static enum GNUNET_GenericReturnValue file_test_internal ( const char *  fil,
int  amode 
)
static

Check if fil can be accessed using amode.

Parameters
filfile to check for
amodeaccess mode
Returns
GNUnet error code

Definition at line 494 of file disk.c.

495{
496 struct stat filestat;
497 int ret;
498 char *rdir;
499
501 if (rdir == NULL)
502 return GNUNET_SYSERR;
503
504 ret = stat (rdir, &filestat);
505 if (0 != ret)
506 {
507 if (errno != ENOENT)
508 {
510 GNUNET_free (rdir);
511 return GNUNET_SYSERR;
512 }
513 GNUNET_free (rdir);
514 return GNUNET_NO;
515 }
516 if (! S_ISREG (filestat.st_mode))
517 {
518 GNUNET_free (rdir);
519 return GNUNET_NO;
520 }
521 if (access (rdir, amode) < 0)
522 {
524 GNUNET_free (rdir);
525 return GNUNET_SYSERR;
526 }
527 GNUNET_free (rdir);
528 return GNUNET_YES;
529}
static int ret
Final status code.
Definition: gnunet-arm.c:93
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:506

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, GNUNET_YES, LOG_STRERROR_FILE, and ret.

Referenced by GNUNET_DISK_file_test(), and GNUNET_DISK_file_test_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ glob_match()

static bool glob_match ( const char *  pattern,
const char *  str 
)
static

Check for a simple wildcard match.

Only asterisks are allowed. Asterisks match everything, including slashes.

Parameters
patternpattern with wildcards
strstring to match against
Returns
true on match, false otherwise

Definition at line 928 of file disk.c.

929{
930 /* Position in the input string */
931 const char *str_pos = str;
932 /* Position in the pattern */
933 const char *pat_pos = pattern;
934 /* Backtrack position in string */
935 const char *str_bt = NULL;
936 /* Backtrack position in pattern */
937 const char *pat_bt = NULL;
938
939 for (;;)
940 {
941 if (*pat_pos == '*')
942 {
943 str_bt = str_pos;
944 pat_bt = pat_pos++;
945 }
946 else if (*pat_pos == *str_pos)
947 {
948 if ('\0' == *pat_pos)
949 return true;
950 str_pos++;
951 pat_pos++;
952 }
953 else
954 {
955 if (NULL == str_bt)
956 return false;
957 /* Backtrack to match one more
958 character as part of the asterisk. */
959 str_pos = str_bt + 1;
960 if ('\0' == *str_pos)
961 return false;
962 pat_pos = pat_bt;
963 }
964 }
965}

Referenced by glob_cb().

Here is the caller graph for this function:

◆ glob_cb()

static enum GNUNET_GenericReturnValue glob_cb ( void *  cls,
const char *  filename 
)
static

Function called with a filename.

Parameters
clsclosure
filenamecomplete filename (absolute path)
Returns
GNUNET_OK to continue to iterate, GNUNET_NO to stop iteration with no error, GNUNET_SYSERR to abort iteration with error!

Definition at line 990 of file disk.c.

992{
993 struct GlobClosure *gc = cls;
994 const char *fn;
995
996 fn = strrchr (filename, DIR_SEPARATOR);
997 fn = (NULL == fn) ? filename : (fn + 1);
998
1000 "checking glob '%s' against '%s'\n",
1001 gc->glob,
1002 fn);
1003
1004 if (glob_match (gc->glob, fn))
1005 {
1006 enum GNUNET_GenericReturnValue cbret;
1007
1009 "found glob match '%s'\n",
1010 filename);
1011 gc->nres++;
1012 cbret = gc->cb (gc->cls, filename);
1013 if (GNUNET_OK != cbret)
1014 return cbret;
1015 }
1016 return GNUNET_OK;
1017}
static bool glob_match(const char *pattern, const char *str)
Check for a simple wildcard match.
Definition: disk.c:928
#define LOG(kind,...)
Definition: disk.c:31
static char * filename
GNUNET_GenericReturnValue
Named constants for return values.
#define DIR_SEPARATOR
Definition: platform.h:166
GNUNET_FileNameCallback cb
Definition: disk.c:971
void * cls
Definition: disk.c:972
int nres
Number of files that actually matched the glob pattern.
Definition: disk.c:977
const char * glob
Definition: disk.c:970

References GlobClosure::cb, GlobClosure::cls, DIR_SEPARATOR, filename, GlobClosure::glob, glob_match(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_OK, LOG, and GlobClosure::nres.

Referenced by GNUNET_DISK_glob().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_helper()

static enum GNUNET_GenericReturnValue remove_helper ( void *  unused,
const char *  fn 
)
static

Function that removes the given directory by calling GNUNET_DISK_directory_remove().

Parameters
unusednot used
fndirectory to remove
Returns
GNUNET_OK

Definition at line 1088 of file disk.c.

1090{
1091 (void) unused;
1092 (void) GNUNET_DISK_directory_remove (fn);
1093 return GNUNET_OK;
1094}
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1098

References GNUNET_DISK_directory_remove(), and GNUNET_OK.

Referenced by GNUNET_DISK_directory_remove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DISK_internal_file_handle_()

enum GNUNET_GenericReturnValue GNUNET_DISK_internal_file_handle_ ( const struct GNUNET_DISK_FileHandle fh,
int *  dst 
)

Retrieve OS file handle.

Parameters
fhGNUnet file descriptor
dstdestination buffer
Returns
GNUNET_OK on success, GNUNET_SYSERR otherwise

Definition at line 1662 of file disk.c.

1664{
1665 if (NULL == fh)
1666 return GNUNET_SYSERR;
1667 *dst = fh->fd;
1668 return GNUNET_OK;
1669}
int fd
File handle on Unix-like systems.

References GNUNET_DISK_FileHandle::fd, GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_NETWORK_fdset_handle_set(), and start_process().

Here is the caller graph for this function:

◆ purge_cfg_dir()

static enum GNUNET_GenericReturnValue purge_cfg_dir ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Helper function for GNUNET_DISK_purge_cfg_dir.

Parameters
clsa const char * with the option to purge
cfgour configuration
Returns
GNUNET_OK on success

Definition at line 1680 of file disk.c.

1682{
1683 const char *option = cls;
1684 char *tmpname;
1685
1686 if (GNUNET_OK !=
1688 "PATHS",
1689 option,
1690 &tmpname))
1691 {
1693 "PATHS",
1694 option);
1695 return GNUNET_NO;
1696 }
1697 if (GNUNET_SYSERR ==
1699 {
1701 "remove",
1702 tmpname);
1703 GNUNET_free (tmpname);
1704 return GNUNET_OK;
1705 }
1706 GNUNET_free (tmpname);
1707 return GNUNET_OK;
1708}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_ERROR

References cfg, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_DISK_directory_remove(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_missing(), GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_DISK_purge_cfg_dir().

Here is the call graph for this function:
Here is the caller graph for this function: