Disk IO APIs. More...
Data Structures | |
struct | GNUNET_DISK_FileHandle |
Handle used to access files (and pipes). More... | |
Functions | |
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_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... | |
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... | |
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... | |
char * | GNUNET_DISK_mktemp (const char *t) |
Create an (empty) temporary file on disk. More... | |
char * | GNUNET_DISK_mkdtemp (const char *t) |
Create an (empty) temporary directory on disk. More... | |
struct GNUNET_DISK_FileHandle * | GNUNET_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_handle_size (struct GNUNET_DISK_FileHandle *fh, off_t *size) |
Get the size of an open file. More... | |
struct GNUNET_DISK_PipeHandle * | GNUNET_DISK_pipe (enum GNUNET_DISK_PipeFlags pf) |
Creates an interprocess channel. More... | |
struct GNUNET_DISK_PipeHandle * | GNUNET_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 (struct GNUNET_DISK_PipeHandle *p) |
Closes an interprocess channel. 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_FileHandle * | GNUNET_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_file_close (struct GNUNET_DISK_FileHandle *h) |
Close an open file. More... | |
const struct GNUNET_DISK_FileHandle * | GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n) |
Get the handle to a particular pipe end. 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... | |
struct GNUNET_DISK_FileHandle * | GNUNET_DISK_get_handle_from_int_fd (int fno) |
Get a handle from a native integer FD. More... | |
struct GNUNET_DISK_FileHandle * | GNUNET_DISK_get_handle_from_native (FILE *fd) |
Get a handle from a native FD. 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... | |
enum GNUNET_GenericReturnValue | GNUNET_DISK_file_copy (const char *src, const char *dst) |
Copy a file. More... | |
int | GNUNET_DISK_directory_scan (const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls) |
Scan a directory for files. More... | |
int | GNUNET_DISK_glob (const char *glob_pattern, GNUNET_FileNameCallback callback, void *callback_cls) |
Find all files matching a glob pattern. More... | |
enum GNUNET_GenericReturnValue | GNUNET_DISK_directory_create_for_file (const char *filename) |
Create the directory structure for storing a file. More... | |
enum GNUNET_GenericReturnValue | GNUNET_DISK_directory_test (const char *fil, int is_readable) |
Test if fil is a directory and listable. More... | |
enum GNUNET_GenericReturnValue | GNUNET_DISK_directory_remove (const char *filename) |
Remove all files in a directory (rm -rf). 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... | |
enum GNUNET_GenericReturnValue | GNUNET_DISK_directory_create (const char *dir) |
Implementation of "mkdir -p". 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... | |
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... | |
Disk IO APIs.
enum GNUNET_FILE_Type |
Type of a handle.
Enumerator | |
---|---|
GNUNET_DISK_HANLDE_TYPE_EVENT | Handle represents an event. |
GNUNET_DISK_HANLDE_TYPE_FILE | Handle represents a file. |
GNUNET_DISK_HANLDE_TYPE_PIPE | Handle represents a pipe. |
Definition at line 50 of file gnunet_disk_lib.h.
Specifies how a file should be opened.
Definition at line 101 of file gnunet_disk_lib.h.
enum GNUNET_DISK_MapType |
Specifies what type of memory map is desired.
Enumerator | |
---|---|
GNUNET_DISK_MAP_TYPE_READ | Read-only memory map. |
GNUNET_DISK_MAP_TYPE_WRITE | Write-able memory map. |
GNUNET_DISK_MAP_TYPE_READWRITE | Read-write memory map. |
Definition at line 142 of file gnunet_disk_lib.h.
File access permissions, UNIX-style.
Definition at line 164 of file gnunet_disk_lib.h.
enum GNUNET_DISK_Seek |
Constants for specifying how to seek.
Do not change values or order, some of the code depends on the specific numeric values!
Definition at line 222 of file gnunet_disk_lib.h.
enum GNUNET_DISK_PipeEnd |
Enumeration identifying the two ends of a pipe.
Enumerator | |
---|---|
GNUNET_DISK_PIPE_END_READ | The reading-end of a pipe. |
GNUNET_DISK_PIPE_END_WRITE | The writing-end of a pipe. |
Definition at line 244 of file gnunet_disk_lib.h.
Flags for GNUNET_DISK_pipe().
Definition at line 419 of file gnunet_disk_lib.h.
enum GNUNET_GenericReturnValue GNUNET_DISK_handle_invalid | ( | const struct GNUNET_DISK_FileHandle * | h | ) |
Checks whether a handle is invalid.
h | handle to check |
Definition at line 186 of file disk.c.
References GNUNET_NO, GNUNET_YES, and h.
Referenced by decrementBit(), file_hash_finish(), incrementBit(), maint_child_death(), and shutdown_pipe_cb().
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).
fil | filename to check |
Definition at line 506 of file disk.c.
References file_test_internal().
Referenced by callback_scan_for_operations(), create_download_context(), create_unique_cfgs(), database_connect(), database_setup(), ego_callback(), get_path_from_PATH(), get_topo_string_from_file(), GNUNET_CONTAINER_bloomfilter_load(), GNUNET_DISK_file_open(), GNUNET_FS_download_start_task_(), GNUNET_HOSTLIST_client_start(), GNUNET_PROGRAM_conf_and_options(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_TRANSPORT_TESTING_start_peer(), hosts_directory_scan_callback(), load_hostlist_file(), load_list_messages(), load_list_tunnels(), load_member(), load_member_session(), load_member_session_history(), load_member_session_next(), load_message_store(), load_peer_store(), load_search_strings(), main(), PABC_load_public_parameters(), print_key(), read_file(), read_index_list(), read_update_information_graph(), restore_valid_peers(), run(), and start_peer_run().
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test_read | ( | const char * | fil | ) |
Check that fil corresponds to a filename and the file has read permissions.
fil | filename to check |
Definition at line 513 of file disk.c.
References file_test_internal().
Referenced by GNUNET_CONFIGURATION_default_filename(), GNUNET_PQ_exec_sql(), and handle_inline().
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.
fil | name of the file to back up |
Definition at line 360 of file disk.c.
References GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_snprintf(), and translate_unix_perms().
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.
h | handle of an open file |
offset | position to move to |
whence | specification to which position the offset parameter relates to |
Definition at line 206 of file disk.c.
References GNUNET_SYSERR, h, and t.
Referenced by decrementBit(), delete_store_message(), fh_reader(), get_store_message(), GNUNET_FS_data_reader_file_(), GNUNET_FS_handle_on_demand_block(), incrementBit(), iterate_save_messages(), load_list_messages(), load_list_tunnels(), load_member_session_history(), load_peer_store(), process_result_with_request(), read_file(), save_list_messages(), save_list_tunnels(), save_member_session_history(), save_message_store(), save_peer_store(), try_top_down_reconstruction(), and unindex_reader().
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).
filename | name of the file or directory |
size | set to the size of the file (or, in the case of directories, the sum of all sizes of files in the directory) |
include_symbolic_links | should symbolic links be included? |
single_file_mode | GNUNET_YES to only get size of one file and return GNUNET_SYSERR for directories. |
Definition at line 222 of file disk.c.
References filename, get_size_rec(), GNUNET_assert, GetFileSizeData::include_sym_links, ret, GetFileSizeData::single_file_mode, size, and GetFileSizeData::total.
Referenced by create_download_context(), database_setup(), get_topo_string_from_file(), GNUNET_CONFIGURATION_parse(), GNUNET_CRYPTO_hash_file(), GNUNET_DISK_file_copy(), GNUNET_FS_file_information_create_from_file(), GNUNET_FS_unindex_start(), load(), load_file(), load_search_strings(), preprocess_file(), print_key(), and run().
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.
This function is used between GNUnet processes to quickly check if two files with the same absolute path are actually identical. The two processes represent the same peer but may communicate over the network (and the file may be on an NFS volume). This function may not be supported on all operating systems.
filename | name of the file |
dev | set to the device ID |
ino | set to the inode ID |
Definition at line 241 of file disk.c.
References filename, GNUNET_OK, and GNUNET_SYSERR.
Referenced by handle_client_index_start(), and hash_for_index_cb().
char * GNUNET_DISK_mktemp | ( | const char * | t | ) |
Create an (empty) temporary file on disk.
If the given name is not an absolute path, the current 'TMPDIR' will be prepended. In any case, 6 random characters will be appended to the name to create a unique filename.
t | component to use for the name; does NOT contain "XXXXXX" or "/tmp/". |
Definition at line 404 of file disk.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, LOG_STRERROR_FILE, mktemp_name(), and t.
Referenced by create_download_context(), GNUNET_DATACACHE_create(), GNUNET_FS_download_sync_(), libgnunet_plugin_datacache_sqlite_init(), make_serialization_file_name(), and make_serialization_file_name_in_dir().
char * GNUNET_DISK_mkdtemp | ( | const char * | t | ) |
Create an (empty) temporary directory on disk.
If the given name is not an absolute path, the current 'TMPDIR' will be prepended. In any case, 6 random characters will be appended to the name to create a unique name.
t | component to use for the name; does NOT contain "XXXXXX" or "/tmp/". |
Definition at line 340 of file disk.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_free, LOG_STRERROR_FILE, mktemp_name(), and t.
Referenced by create_response(), and GNUNET_TESTBED_system_create_with_portrange().
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open | ( | const char * | fn, |
enum GNUNET_DISK_OpenFlags | flags, | ||
enum GNUNET_DISK_AccessPermissions | perm | ||
) |
Open a file.
Note that the access permissions will only be used if a new file is created and if the underlying operating system supports the given permissions.
fn | file name to be opened |
flags | opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags |
perm | permissions for the newly created file, use GNUNET_DISK_PERM_NONE if a file could not be created by this call (because of flags) |
Definition at line 1215 of file disk.c.
References GNUNET_DISK_FileHandle::fd, GNUNET_break, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_APPEND, GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_FAILIFEXISTS, GNUNET_DISK_OPEN_READ, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_OPEN_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_STRINGS_filename_expand(), LOG_STRERROR_FILE, mode, O_LARGEFILE, ret, and translate_unix_perms().
Referenced by database_setup(), database_shutdown(), full_recursive_download(), get_file_handle(), GNUNET_BIO_read_open_file(), GNUNET_BIO_write_open_file(), GNUNET_CONFIGURATION_write(), GNUNET_CONTAINER_bloomfilter_load(), GNUNET_CRYPTO_hash_file(), GNUNET_DISK_file_copy(), GNUNET_DISK_fn_read(), GNUNET_FS_data_reader_file_(), GNUNET_FS_download_start_task_(), GNUNET_FS_handle_on_demand_block(), GNUNET_FS_unindex_do_remove_(), GNUNET_TIME_absolute_get_monotonic(), load_etc_hosts(), load_list_messages(), load_list_tunnels(), load_member_session_history(), load_message_store(), load_message_store_entries(), load_message_store_links(), load_peer_store(), lookup_dns_servers(), open_static_resource(), print_key(), process_result_with_request(), read_file(), read_from_log(), REGEX_TEST_read_from_file(), restore_valid_peers(), run(), save_list_messages(), save_list_tunnels(), save_member_session_history(), save_message_store(), save_peer_store(), start_dump(), start_insert(), store_valid_peers(), to_file_raw(), try_match_block(), write_benchmark_data(), and write_file().
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size | ( | struct GNUNET_DISK_FileHandle * | fh, |
off_t * | size | ||
) |
Get the size of an open file.
fh | open file handle |
size | where to write size of the file |
Definition at line 193 of file disk.c.
References GNUNET_DISK_FileHandle::fd, GNUNET_OK, GNUNET_SYSERR, and size.
Referenced by GNUNET_CONTAINER_bloomfilter_load(), GNUNET_TIME_absolute_get_monotonic(), load_etc_hosts(), lookup_dns_servers(), open_static_resource(), REGEX_TEST_read_from_file(), and restore_valid_peers().
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe | ( | enum GNUNET_DISK_PipeFlags | pf | ) |
Creates an interprocess channel.
pf | how to configure the pipe |
Definition at line 1425 of file disk.c.
References GNUNET_DISK_PipeHandle::fd, GNUNET_DISK_pipe_from_fd(), GNUNET_ERROR_TYPE_ERROR, and LOG_STRERROR.
Referenced by child_management_start(), GNUNET_ARM_request_service_start(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_OS_command_run(), GNUNET_SCHEDULER_driver_init(), main(), restart_nat_server(), run(), start_helper(), and start_process().
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe_from_fd | ( | enum GNUNET_DISK_PipeFlags | pf, |
int | fd[2] | ||
) |
Creates a pipe object from a couple of file descriptors.
Useful for wrapping existing pipe FDs.
pf | how to configure the pipe |
fd | an array of two fd values. One of them may be -1 for read-only or write-only pipes |
Definition at line 1446 of file disk.c.
References GNUNET_DISK_PipeHandle::fd, GNUNET_break, GNUNET_DISK_PF_BLOCKING_READ, GNUNET_DISK_PF_BLOCKING_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_new, LOG_STRERROR, p, and ret.
Referenced by GNUNET_DISK_pipe().
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close | ( | struct GNUNET_DISK_PipeHandle * | p | ) |
Closes an interprocess channel.
p | pipe |
Definition at line 1572 of file disk.c.
References GNUNET_DISK_pipe_close_end(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_PIPE_END_WRITE, GNUNET_free, GNUNET_OK, p, and ret.
Referenced by child_management_done(), GN_stop_gnunet_nat_server_(), GNUNET_ARM_request_service_start(), GNUNET_HELPER_kill(), GNUNET_HELPER_wait(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_NAT_mini_get_external_ipv4_cancel_(), GNUNET_OS_command_run(), GNUNET_OS_command_stop(), GNUNET_SCHEDULER_driver_done(), main(), nat_server_read(), restart_nat_server(), shutdown_task(), and start_process().
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.
p | pipe to close end of |
end | which end of the pipe to close |
Definition at line 1519 of file disk.c.
References end, GNUNET_DISK_file_close(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_PIPE_END_WRITE, GNUNET_OK, p, and ret.
Referenced by GNUNET_DISK_pipe_close(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_OS_command_run(), restart_nat_server(), and start_helper().
struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_detach_end | ( | struct GNUNET_DISK_PipeHandle * | p, |
enum GNUNET_DISK_PipeEnd | end | ||
) |
Detaches one of the ends from the pipe.
Detached end is a fully-functional FileHandle, it will not be affected by anything you do with the pipe afterwards. Each end of a pipe can only be detched from it once (i.e. it is not duplicated).
p | pipe to detach an end from |
end | which end of the pipe to detach |
Definition at line 1545 of file disk.c.
References end, GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_PIPE_END_WRITE, p, and ret.
Referenced by GNUNET_ARM_request_service_start(), and start_process().
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close | ( | struct GNUNET_DISK_FileHandle * | h | ) |
Close an open file.
h | file handle |
Definition at line 1289 of file disk.c.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_OK, GNUNET_SYSERR, h, LOG_STRERROR, and ret.
Referenced by check_completed(), clear_message_store(), close_files_iter(), database_setup(), database_shutdown(), do_shutdown(), file_hash_finish(), full_recursive_download(), get_cb(), GNUNET_ARM_operation_cancel(), GNUNET_ARM_request_service_start(), GNUNET_BIO_flush(), GNUNET_BIO_read_close(), GNUNET_BIO_write_close(), GNUNET_CONFIGURATION_write(), GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_bloomfilter_load(), GNUNET_CRYPTO_hash_file_cancel(), GNUNET_DISK_file_copy(), GNUNET_DISK_fn_read(), GNUNET_DISK_pipe_close_end(), GNUNET_FS_data_reader_file_(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_start_task_(), GNUNET_FS_handle_on_demand_block(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_stop(), GNUNET_OS_process_destroy(), GNUNET_TIME_absolute_get_monotonic(), load_etc_hosts(), load_list_messages(), load_list_tunnels(), load_member_session_history(), load_message_store(), load_message_store_entries(), load_message_store_links(), load_peer_store(), lookup_dns_servers(), notify_starting(), open_static_resource(), parent_control_handler(), print_key(), process_result_with_request(), read_file(), reconstruct_cont(), REGEX_TEST_read_from_file(), restore_valid_peers(), run(), save_list_messages(), save_list_tunnels(), save_member_session_history(), save_message_store(), save_peer_store(), shutdown_pch(), shutdown_task(), start_process(), store_valid_peers(), to_file_raw(), try_match_block(), unindex_finish(), write_benchmark_data(), and write_file().
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle | ( | const struct GNUNET_DISK_PipeHandle * | p, |
enum GNUNET_DISK_PipeEnd | n | ||
) |
Get the handle to a particular pipe end.
p | pipe |
n | end to access |
Definition at line 1602 of file disk.c.
References GNUNET_break, GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_PIPE_END_WRITE, and p.
Referenced by GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_OS_command_run(), GNUNET_SCHEDULER_driver_init(), GNUNET_wait_child(), initiate_put_from_pipe_trigger(), maint_child_death(), restart_nat_server(), run(), shutdown_pipe_cb(), sighandler_child_death(), sighandler_shutdown(), sign_worker(), start_helper(), start_process(), and work().
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.
If both arguments are GNUNET_NO, the file is made world-read-write-executable (777). Does nothing on W32.
fn | name of the file to update |
require_uid_match | GNUNET_YES means 700 |
require_gid_match | GNUNET_YES means 770 unless require_uid_match is set |
Definition at line 321 of file disk.c.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror_file, GNUNET_YES, and mode.
Referenced by create_listen_socket().
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_int_fd | ( | int | fno | ) |
Get a handle from a native integer FD.
fno | native integer file descriptor |
Definition at line 1311 of file disk.c.
References GNUNET_DISK_FileHandle::fd, and GNUNET_new.
Referenced by extract_handles(), GNUNET_DISK_get_handle_from_native(), GNUNET_OS_install_parent_control_handler(), main(), start_dump(), and start_insert().
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_native | ( | FILE * | fd | ) |
Get a handle from a native FD.
fd | native file descriptor |
Definition at line 1327 of file disk.c.
References GNUNET_DISK_FileHandle::fd, and GNUNET_DISK_get_handle_from_int_fd().
Referenced by run().
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.
h | handle to an open file |
result | the buffer to write the result to |
len | the maximum number of bytes to read |
Definition at line 646 of file disk.c.
References GNUNET_SYSERR, h, and result.
Referenced by cmd_read(), database_setup(), decrementBit(), fh_reader(), file_hash_task(), get_store_message(), GNUNET_CONTAINER_bloomfilter_load(), GNUNET_DISK_file_copy(), GNUNET_DISK_fn_read(), GNUNET_FS_data_reader_file_(), GNUNET_FS_handle_on_demand_block(), helper_read(), incrementBit(), initiate_put_from_pipe_trigger(), load_list_messages(), load_list_tunnels(), load_member_session_history(), load_peer_store(), maint_child_death(), nat_server_read(), parent_control_handler(), print_key(), put_cb(), read_external_ipv4(), read_file(), read_from_file(), read_task(), REGEX_TEST_read_from_file(), restore_valid_peers(), run(), shutdown_pipe_cb(), start_insert(), try_top_down_reconstruction(), and unindex_reader().
ssize_t GNUNET_DISK_fn_read | ( | const char * | fn, |
void * | result, | ||
size_t | len | ||
) |
Read the contents of a binary file into a buffer.
fn | file name |
result | the buffer to write the result to |
len | the maximum number of bytes to read |
Definition at line 660 of file disk.c.
References GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_OK, GNUNET_SYSERR, result, and ret.
Referenced by ego_callback(), get_topo_string_from_file(), GNUNET_CONFIGURATION_parse(), hosts_directory_scan_callback(), load_file(), load_search_strings(), and run().
ssize_t GNUNET_DISK_file_write | ( | const struct GNUNET_DISK_FileHandle * | h, |
const void * | buffer, | ||
size_t | n | ||
) |
Write a buffer to a file.
h | handle to open file |
buffer | the data to write |
n | number of bytes to write |
Definition at line 682 of file disk.c.
References GNUNET_SYSERR, and h.
Referenced by database_shutdown(), decrementBit(), delete_store_message(), do_shutdown(), get_cb(), GNUNET_BIO_flush(), GNUNET_CONFIGURATION_write(), GNUNET_DISK_file_copy(), GNUNET_OS_process_kill(), GNUNET_TIME_absolute_get_monotonic(), helper_write(), incrementBit(), iterate_save_member_session_history_hentries(), iterate_save_messages(), iterate_save_peers(), process_result_with_request(), publicize_rm(), regex_found_handler(), save_list_messages(), save_list_tunnels(), sighandler_child_death(), sighandler_shutdown(), sign_worker(), start_dump(), stats_iterator(), store_and_free_entries(), store_peer_presistently_iterator(), to_file_raw(), try_match_block(), write_file(), and write_task().
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.
h | handle to open file |
buffer | the data to write |
n | number of bytes to write |
Definition at line 698 of file disk.c.
References GNUNET_SYSERR, h, and ret.
Referenced by write_benchmark_data().
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.
The directory is created if necessary. Fail if filename already exists or if not exactly buf with buf_size bytes could be written to filename.
fn | file name |
buf | the data to write |
buf_size | number of bytes to write from buf |
mode | file permissions |
Definition at line 722 of file disk.c.
References GNUNET_DISK_FileHandle::fd, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_create_for_file(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, mode, and translate_unix_perms().
Referenced by calculate_pow(), clean_task(), GNUNET_CRYPTO_ecdsa_key_from_file(), GNUNET_CRYPTO_eddsa_key_from_file(), handle_create_message(), run(), shutdown_task(), sync_pow(), and write_proof().
enum GNUNET_GenericReturnValue GNUNET_DISK_file_copy | ( | const char * | src, |
const char * | dst | ||
) |
Copy a file.
src | file to copy |
dst | destination file name |
Definition at line 1104 of file disk.c.
References COPY_BLK_SIZE, FAIL, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_size(), GNUNET_DISK_file_write(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_FAILIFEXISTS, GNUNET_DISK_OPEN_READ, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_GROUP_WRITE, GNUNET_DISK_PERM_NONE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and size.
int GNUNET_DISK_directory_scan | ( | const char * | dir_name, |
GNUNET_FileNameCallback | callback, | ||
void * | callback_cls | ||
) |
Scan a directory for files.
dir_name | the name of the directory |
callback | the method to call for each file |
callback_cls | closure for callback |
Definition at line 811 of file disk.c.
References dir_name, DIR_SEPARATOR, DIR_SEPARATOR_STR, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_snprintf(), GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, LOG_STRERROR_FILE, name, and ret.
Referenced by deserialization_master(), deserialize_download(), deserialize_search(), determine_id(), discover_testbed_nodes(), get_size_rec(), GNUNET_CONFIGURATION_load_from(), GNUNET_DISK_directory_remove(), GNUNET_DISK_glob(), GNUNET_PLUGIN_load_all(), iter_testbed_path(), load_member(), load_member_store(), load_operation_store(), preprocess_file(), run(), and scan().
int GNUNET_DISK_glob | ( | const char * | glob_pattern, |
GNUNET_FileNameCallback | callback, | ||
void * | callback_cls | ||
) |
Find all files matching a glob pattern.
Currently, the glob_pattern only supports asterisks in the last path component.
glob_pattern | the glob pattern to search for |
callback | the method to call for each file |
callback_cls | closure for callback |
Definition at line 988 of file disk.c.
References DIR_SEPARATOR, GlobClosure::glob, glob_cb(), GNUNET_break, GNUNET_DISK_directory_scan(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_strdup, LOG, GlobClosure::nres, and ret.
Referenced by handle_inline().
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file | ( | const char * | filename | ) |
Create the directory structure for storing a file.
filename | name of a file in the directory |
Definition at line 606 of file disk.c.
References DIR_SEPARATOR, filename, GNUNET_DISK_directory_create(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, and res.
Referenced by database_connect(), database_setup(), get_server_addresses(), GNUNET_CONFIGURATION_write(), GNUNET_DISK_file_open(), GNUNET_DISK_fn_write(), GNUNET_FS_download_sync_(), make_serialization_file_name(), make_serialization_file_name_in_dir(), run(), save(), save_hostlist_file(), setup_log_file(), store_valid_peers(), and trigger_recursive_download().
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test | ( | const char * | fil, |
int | is_readable | ||
) |
Test if fil is a directory and listable.
Optionally, also check if the directory is readable. Will not print an error message if the directory does not exist. Will log errors if GNUNET_SYSERR is returned (i.e., a file exists with the same name).
fil | filename to test |
is_readable | GNUNET_YES to additionally check if fil is readable; GNUNET_NO to disable this check |
stat
ed Definition at line 427 of file disk.c.
References GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, LOG, LOG_STRERROR_FILE, and ret.
Referenced by callback_scan_for_members(), callback_scan_for_sessions(), create_service(), deserialization_master(), deserialize_download(), deserialize_search(), GNUNET_CONFIGURATION_load(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_remove(), GNUNET_FS_remove_sync_dir_(), GNUNET_OS_installation_get_path(), iterate_load_next_member_sessions(), iterate_load_next_session(), iterate_save_members(), iterate_save_session(), load_member(), load_member_store(), load_operation_store(), load_srv_room(), PABC_load_public_parameters(), remove_srv_room(), run(), save_member(), save_member_store(), save_operation_store(), and save_srv_room().
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove | ( | const char * | filename | ) |
Remove all files in a directory (rm -rf).
Call with caution.
filename | the file to remove |
Definition at line 1065 of file disk.c.
References filename, GNUNET_break, GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, LOG_STRERROR_FILE, and remove_helper().
Referenced by calculate_pow(), clean_task(), create_response(), delete_files(), GNUNET_CONFIGURATION_write(), GNUNET_FS_remove_sync_dir_(), GNUNET_TESTBED_system_destroy(), purge_cfg_dir(), remove_helper(), remove_room_member_session(), remove_srv_room(), and write_proof().
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.
pd | project data to use to determine paths |
cfg_filename | configuration file to parse |
option | option with the dir name to purge |
Definition at line 1669 of file disk.c.
References cfg_filename, GNUNET_break, GNUNET_CONFIGURATION_parse_and_run(), GNUNET_OK, and purge_cfg_dir().
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create | ( | const char * | dir | ) |
Implementation of "mkdir -p".
dir | the directory to create |
Definition at line 520 of file disk.c.
References dir, DIR_SEPARATOR, GNUNET_break, GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, GNUNET_YES, LOG_STRERROR_FILE, and ret.
Referenced by create_service(), ensure_folder_exist(), GNUNET_DISK_directory_create_for_file(), init_pabc_dir(), iterate_save_members(), iterate_save_session(), jwks_endpoint(), run(), save_member(), save_member_store(), save_operation_store(), save_srv_room(), token_endpoint(), and write_benchmark_data().
void GNUNET_DISK_filename_canonicalize | ( | char * | fn | ) |
Removes special characters as ':' from a filename.
fn | the filename to canonicalize |
Definition at line 1169 of file disk.c.
Referenced by progress_cb().
enum GNUNET_GenericReturnValue GNUNET_DISK_file_change_owner | ( | const char * | filename, |
const char * | user | ||
) |
Change owner of a file.
filename | file to change |
user | new owner of the file |
Definition at line 1191 of file disk.c.
References _, filename, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, GNUNET_SYSERR, LOG, and LOG_STRERROR_FILE.
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.
h | open file handle |
m | handle to the new mapping (will be set) |
access | access specification, GNUNET_DISK_MAP_TYPE_xxx |
len | size of the mapping |
Definition at line 1361 of file disk.c.
References GNUNET_assert, GNUNET_DISK_MAP_TYPE_READ, GNUNET_DISK_MAP_TYPE_WRITE, GNUNET_free, GNUNET_new, h, m, and MAP_FAILED.
Referenced by database_setup(), full_recursive_download(), GNUNET_TIME_absolute_get_monotonic(), load_etc_hosts(), lookup_dns_servers(), and run().
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap | ( | struct GNUNET_DISK_MapHandle * | h | ) |
Unmap a file.
h | mapping handle |
Definition at line 1392 of file disk.c.
References GNUNET_free, GNUNET_OK, GNUNET_SYSERR, h, and ret.
Referenced by database_setup(), full_recursive_download(), GNUNET_TIME_absolute_get_monotonic(), load_etc_hosts(), lookup_dns_servers(), and run().
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync | ( | const struct GNUNET_DISK_FileHandle * | h | ) |
Write file changes to disk.
h | handle to an open file |
Definition at line 1408 of file disk.c.
References GNUNET_OK, GNUNET_SYSERR, and h.
Referenced by delete_store_message(), publicize_rm(), save_list_messages(), save_list_tunnels(), save_member_session_history(), save_message_store(), and save_peer_store().