main FS functions (master initialization, serialization, deserialization, shared code) More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_tree.h"
Go to the source code of this file.
Data Structures | |
struct | FileInfo |
Closure for GNUNET_FS_data_reader_file_(). More... | |
Macros | |
#define | DEFAULT_MAX_PARALLEL_REQUESTS (1024 * 10) |
How many block requests can we have outstanding in parallel at a time by default? More... | |
#define | DEFAULT_MAX_PARALLEL_DOWNLOADS 16 |
How many downloads can we have outstanding in parallel at a time by default? More... | |
Functions | |
static void | start_job (struct GNUNET_FS_QueueEntry *qe) |
Start the given job (send signal, remove from pending queue, update counters and state). More... | |
static void | stop_job (struct GNUNET_FS_QueueEntry *qe) |
Stop the given job (send signal, remove from active queue, update counters and state). More... | |
static void | process_job_queue (void *cls) |
Process the jobs in the job queue, possibly starting some and stopping others. More... | |
struct GNUNET_FS_QueueEntry * | GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_SCHEDULER_TaskCallback start, GNUNET_SCHEDULER_TaskCallback stop, void *cls, unsigned int blocks, enum GNUNET_FS_QueuePriority priority) |
Add a job to the queue. More... | |
void | GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qe) |
Dequeue a job from the queue. More... | |
struct TopLevelActivity * | GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, void *ssf_cls) |
Create a top-level activity entry. More... | |
void | GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, struct TopLevelActivity *top) |
Destroy a top-level activity entry. More... | |
size_t | GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) |
Function that provides data by reading from a file. More... | |
void * | GNUNET_FS_make_file_reader_context_ (const char *filename) |
Create the closure for the GNUNET_FS_data_reader_file_() callback. More... | |
size_t | GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) |
Function that provides data by copying from a buffer. More... | |
static char * | get_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) |
Return the full filename where we would store state information (for serialization/deserialization). More... | |
static char * | get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, const char *ext, const char *uni, const char *ent) |
Return the full filename where we would store state information (for serialization/deserialization) that is associated with a parent operation. More... | |
static struct GNUNET_BIO_ReadHandle * | get_read_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) |
Return a read handle for deserialization. More... | |
static struct GNUNET_BIO_WriteHandle * | get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) |
Return a write handle for serialization. More... | |
static struct GNUNET_BIO_WriteHandle * | get_write_handle_in_dir (struct GNUNET_FS_Handle *h, const char *ext, const char *uni, const char *ent) |
Return a write handle for serialization. More... | |
void | GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) |
Remove serialization/deserialization file from disk. More... | |
static void | remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext, const char *uni, const char *ent) |
Remove serialization/deserialization file from disk. More... | |
void | GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, const char *uni) |
Remove serialization/deserialization directory from disk. More... | |
static int | write_start_time (struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_TIME_Absolute timestamp) |
Serialize a start-time. More... | |
static int | read_start_time (struct GNUNET_BIO_ReadHandle *rh, struct GNUNET_TIME_Absolute *timestamp) |
Deserialize a start-time. More... | |
static struct GNUNET_FS_FileInformation * | deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename) |
Using the given serialization filename, try to deserialize the file-information tree associated with it. More... | |
static struct GNUNET_FS_FileInformation * | deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn, struct GNUNET_BIO_ReadHandle *rh) |
Using the given serialization filename, try to deserialize the file-information tree associated with it. More... | |
static char * | get_serialization_short_name (const char *fullname) |
Given a serialization name (full absolute path), return the basename of the file (without the path), which must only consist of the 6 random characters. More... | |
static char * | make_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext) |
Create a new random name for serialization. More... | |
static char * | make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, const char *ext, const char *uni) |
Create a new random name for serialization. More... | |
static int | copy_from_reader (struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_FS_FileInformation *fi) |
Copy all of the data from the reader to the write handle. More... | |
void | GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) |
Create a temporary file on disk to store the current state of fi in. More... | |
static struct GNUNET_FS_FileInformation * | find_file_position (struct GNUNET_FS_FileInformation *pos, const char *srch) |
Find the entry in the file information struct where the serialization filename matches the given name. More... | |
static int | fip_signal_resume (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) |
Signal the FS's progress function that we are resuming an upload. More... | |
static int | deserialize_publish_file (void *cls, const char *filename) |
Function called with a filename of serialized publishing operation to deserialize. More... | |
void | GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) |
Synchronize this publishing struct with its mirror on disk. More... | |
void | GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) |
Synchronize this unindex struct with its mirror on disk. More... | |
static int | write_download_request (struct GNUNET_BIO_WriteHandle *wh, struct DownloadRequest *dr) |
Serialize a download request. More... | |
static struct DownloadRequest * | read_download_request (struct GNUNET_BIO_ReadHandle *rh) |
Read a download request tree. More... | |
static char * | get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc, const char *uni, const char *ext) |
Compute the name of the sync file (or directory) for the given download context. More... | |
void | GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) |
Synchronize this download struct with its mirror on disk. More... | |
void | GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) |
Synchronize this search result with its mirror on disk. More... | |
void | GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) |
Synchronize this search struct with its mirror on disk. More... | |
static int | deserialize_unindex_file (void *cls, const char *filename) |
Function called with a filename of serialized unindexing operation to deserialize. More... | |
static void | deserialize_download (struct GNUNET_FS_Handle *h, struct GNUNET_BIO_ReadHandle *rh, struct GNUNET_FS_DownloadContext *parent, struct GNUNET_FS_SearchResult *search, const char *serialization) |
Deserialize a download. More... | |
static struct GNUNET_FS_SearchContext * | deserialize_search (struct GNUNET_FS_Handle *h, struct GNUNET_BIO_ReadHandle *rh, struct GNUNET_FS_SearchResult *psearch_result, const char *serialization) |
Deserialize a search. More... | |
static int | deserialize_search_result (void *cls, const char *filename) |
Function called with a filename of serialized search result to deserialize. More... | |
static void | signal_download_resume (struct GNUNET_FS_DownloadContext *dc) |
Send the 'resume' signal to the callback; also actually resume the download (put it in the queue). More... | |
static void | signal_search_resume (struct GNUNET_FS_SearchContext *sc) |
Signal resuming of a search to our clients (for the top level search and all sub-searches). More... | |
static int | signal_result_resume (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over search results signaling resume to the client for each result. More... | |
static void | free_search_context (struct GNUNET_FS_SearchContext *sc) |
Free memory allocated by the search context and its children. More... | |
static int | free_result (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over search results freeing each. More... | |
static int | deserialize_subdownload (void *cls, const char *filename) |
Function called with a filename of serialized sub-download to deserialize. More... | |
static void | free_download_context (struct GNUNET_FS_DownloadContext *dc) |
Free this download context and all of its descendants. More... | |
static int | deserialize_search_file (void *cls, const char *filename) |
Function called with a filename of serialized search operation to deserialize. More... | |
static int | deserialize_download_file (void *cls, const char *filename) |
Function called with a filename of serialized download operation to deserialize. More... | |
static void | deserialization_master (const char *master_path, GNUNET_FileNameCallback proc, struct GNUNET_FS_Handle *h) |
Deserialize information about pending operations. More... | |
struct GNUNET_FS_Handle * | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...) |
Setup a connection to the file-sharing service. More... | |
void | GNUNET_FS_stop (struct GNUNET_FS_Handle *h) |
Close our connection with the file-sharing service. More... | |
main FS functions (master initialization, serialization, deserialization, shared code)
Definition in file fs_api.c.
#define DEFAULT_MAX_PARALLEL_REQUESTS (1024 * 10) |
#define DEFAULT_MAX_PARALLEL_DOWNLOADS 16 |
|
static |
Start the given job (send signal, remove from pending queue, update counters and state).
qe | job to start |
Definition at line 51 of file fs_api.c.
References GNUNET_CONTAINER_DLL_insert_after, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TIME_absolute_get(), GNUNET_YES, GNUNET_DATASTORE_QueueEntry::h, and qe.
Referenced by process_job_queue().
|
static |
Stop the given job (send signal, remove from active queue, update counters and state).
qe | job to stop |
Definition at line 78 of file fs_api.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_insert_after, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_add(), GNUNET_DATASTORE_QueueEntry::h, and qe.
Referenced by GNUNET_FS_dequeue_(), and process_job_queue().
|
static |
Process the jobs in the job queue, possibly starting some and stopping others.
cls | the struct GNUNET_FS_Handle * |
Definition at line 107 of file fs_api.c.
References end_time, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_QUEUE_PRIORITY_NORMAL, GNUNET_FS_QUEUE_PRIORITY_PROBE, GNUNET_log, GNUNET_MIN, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, h, GNUNET_DATASTORE_QueueEntry::next, GNUNET_FS_QueueEntry::next, GNUNET_DATASTORE_QueueEntry::priority, process_job_queue(), qe, GNUNET_TIME_Relative::rel_value_us, start_job(), and stop_job().
Referenced by GNUNET_FS_dequeue_(), GNUNET_FS_queue_(), and process_job_queue().
struct GNUNET_FS_QueueEntry * GNUNET_FS_queue_ | ( | struct GNUNET_FS_Handle * | h, |
GNUNET_SCHEDULER_TaskCallback | start, | ||
GNUNET_SCHEDULER_TaskCallback | stop, | ||
void * | cls, | ||
unsigned int | blocks, | ||
enum GNUNET_FS_QueuePriority | priority | ||
) |
Add a job to the queue.
h | handle to the overall FS state |
start | function to call to begin the job |
stop | function to call to pause the job, or on dequeue (if the job was running) |
cls | closure for start and stop |
blocks | number of blocks this download has |
priority | how important is this download |
Definition at line 321 of file fs_api.c.
References GNUNET_FS_QueueEntry::blocks, GNUNET_FS_QueueEntry::cls, GNUNET_CONTAINER_DLL_insert_after, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), h, GNUNET_DATASTORE_QueueEntry::h, GNUNET_DATASTORE_QueueEntry::priority, GNUNET_FS_QueueEntry::priority, process_job_queue(), qe, start, and GNUNET_FS_QueueEntry::stop.
Referenced by GNUNET_FS_download_resume(), and GNUNET_FS_download_start_downloading_().
void GNUNET_FS_dequeue_ | ( | struct GNUNET_FS_QueueEntry * | qe | ) |
Dequeue a job from the queue.
qe | handle for the job |
Definition at line 356 of file fs_api.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, h, GNUNET_DATASTORE_QueueEntry::h, process_job_queue(), qe, and stop_job().
Referenced by check_completed(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_stop(), and process_result_with_request().
struct TopLevelActivity * GNUNET_FS_make_top | ( | struct GNUNET_FS_Handle * | h, |
SuspendSignalFunction | ssf, | ||
void * | ssf_cls | ||
) |
Create a top-level activity entry.
h | global fs handle |
ssf | suspend signal function to use |
ssf_cls | closure for ssf |
Definition at line 381 of file fs_api.c.
References GNUNET_CONTAINER_DLL_insert, GNUNET_new, h, ret, TopLevelActivity::ssf, and TopLevelActivity::ssf_cls.
Referenced by deserialize_download(), deserialize_publish_file(), deserialize_search_file(), deserialize_unindex_file(), GNUNET_FS_download_start(), GNUNET_FS_publish_start(), GNUNET_FS_search_start(), GNUNET_FS_unindex_start(), and search_result_stop().
void GNUNET_FS_end_top | ( | struct GNUNET_FS_Handle * | h, |
struct TopLevelActivity * | top | ||
) |
Destroy a top-level activity entry.
h | global fs handle |
top | top level activity entry |
Definition at line 402 of file fs_api.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, and h.
Referenced by GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_stop(), GNUNET_FS_publish_signal_suspend_(), GNUNET_FS_publish_stop(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop(), GNUNET_FS_unindex_signal_suspend_(), and GNUNET_FS_unindex_stop().
size_t GNUNET_FS_data_reader_file_ | ( | void * | cls, |
uint64_t | offset, | ||
size_t | max, | ||
void * | buf, | ||
char ** | emsg | ||
) |
Function that provides data by reading from a file.
cls | closure with the struct FileInfo * |
offset | offset to read from; it is possible that the caller might need to go backwards a bit at times; set to UINT64_MAX to tell the reader that we won't be reading for a while (used to close the file descriptor but NOT fully clean up the reader's state); in this case, a value of '0' for max should be ignored |
max | maximum number of bytes that should be copied to buf; readers are not allowed to provide less data unless there is an error; a value of "0" will be used at the end to allow the reader to clean up its internal state |
buf | where the reader should write the data |
emsg | location for the reader to store an error message |
Definition at line 447 of file fs_api.c.
References _, FileInfo::fd, FileInfo::filename, GNUNET_asprintf(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_DISK_SEEK_SET, GNUNET_free, GNUNET_SYSERR, max, and ret.
Referenced by block_reader(), deserialize_fi_node(), GNUNET_FS_file_information_create_from_file(), and GNUNET_FS_file_information_create_from_reader().
void * GNUNET_FS_make_file_reader_context_ | ( | const char * | filename | ) |
Create the closure for the GNUNET_FS_data_reader_file_() callback.
filename | file to read |
Definition at line 509 of file fs_api.c.
References filename, FileInfo::filename, GNUNET_free, GNUNET_new, and GNUNET_STRINGS_filename_expand().
Referenced by deserialize_fi_node(), and GNUNET_FS_file_information_create_from_file().
size_t GNUNET_FS_data_reader_copy_ | ( | void * | cls, |
uint64_t | offset, | ||
size_t | max, | ||
void * | buf, | ||
char ** | emsg | ||
) |
Function that provides data by copying from a buffer.
cls | closure (points to the buffer) |
offset | offset to read from; it is possible that the caller might need to go backwards a bit at times; set to UINT64_MAX to tell the reader that we won't be reading for a while (used to close the file descriptor but NOT fully clean up the reader's state); in this case, a value of '0' for max should be ignored |
max | maximum number of bytes that should be copied to buf; readers are not allowed to provide less data unless there is an error; a value of "0" will be used at the end to allow the reader to clean up its internal state |
buf | where the reader should write the data |
emsg | location for the reader to store an error message |
Definition at line 545 of file fs_api.c.
References data, GNUNET_free, GNUNET_memcpy, and max.
Referenced by deserialize_fi_node(), and GNUNET_FS_file_information_create_from_data().
|
static |
Return the full filename where we would store state information (for serialization/deserialization).
h | master context |
ext | component of the path |
ent | entity identifier (or empty string for the directory) |
Definition at line 575 of file fs_api.c.
References GNUNET_ARM_Handle::cfg, DIR_SEPARATOR_STR, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_free, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_OK, h, and ret.
Referenced by deserialization_master(), deserialize_file_information(), get_download_sync_filename(), get_read_handle(), get_write_handle(), GNUNET_FS_file_information_sync_(), GNUNET_FS_remove_sync_file_(), and make_serialization_file_name().
|
static |
Return the full filename where we would store state information (for serialization/deserialization) that is associated with a parent operation.
h | master context |
ext | component of the path |
uni | name of the parent operation |
ent | entity identifier (or empty string for the directory) |
Definition at line 615 of file fs_api.c.
References GNUNET_ARM_Handle::cfg, DIR_SEPARATOR_STR, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_free, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_OK, h, and ret.
Referenced by deserialize_search(), get_write_handle_in_dir(), GNUNET_FS_remove_sync_dir_(), make_serialization_file_name_in_dir(), and remove_sync_file_in_dir().
|
static |
Return a read handle for deserialization.
h | master context |
ext | component of the path |
ent | entity identifier (or empty string for the directory) |
Definition at line 655 of file fs_api.c.
References get_serialization_file_name(), GNUNET_BIO_read_open_file(), GNUNET_free, h, and ret.
Referenced by deserialize_file_information(), and deserialize_search_result().
|
static |
Return a write handle for serialization.
h | master context |
ext | component of the path |
ent | entity identifier (or empty string for the directory) |
Definition at line 678 of file fs_api.c.
References get_serialization_file_name(), GNUNET_BIO_write_open_file(), GNUNET_break, GNUNET_free, h, and ret.
Referenced by GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_sync_(), GNUNET_FS_search_sync_(), and GNUNET_FS_unindex_sync_().
|
static |
Return a write handle for serialization.
h | master context |
ext | component of the path |
uni | name of parent |
ent | entity identifier (or empty string for the directory) |
Definition at line 703 of file fs_api.c.
References get_serialization_file_name_in_dir(), GNUNET_BIO_write_open_file(), GNUNET_free, h, and ret.
Referenced by GNUNET_FS_search_result_sync_().
void GNUNET_FS_remove_sync_file_ | ( | struct GNUNET_FS_Handle * | h, |
const char * | ext, | ||
const char * | ent | ||
) |
Remove serialization/deserialization file from disk.
h | master context |
ext | component of the path |
ent | entity identifier |
Definition at line 728 of file fs_api.c.
References filename, get_serialization_file_name(), GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, and h.
Referenced by deserialize_search_file(), deserialize_unindex_file(), fip_signal_stop(), free_search_context(), GNUNET_FS_download_stop(), GNUNET_FS_publish_stop(), GNUNET_FS_publish_sync_(), GNUNET_FS_search_stop(), GNUNET_FS_search_sync_(), GNUNET_FS_unindex_stop(), GNUNET_FS_unindex_sync_(), and search_result_stop().
|
static |
Remove serialization/deserialization file from disk.
h | master context |
ext | component of the path |
uni | parent name |
ent | entity identifier |
Definition at line 758 of file fs_api.c.
References filename, get_serialization_file_name_in_dir(), GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, and h.
Referenced by deserialize_search_result(), and GNUNET_FS_search_result_sync_().
void GNUNET_FS_remove_sync_dir_ | ( | struct GNUNET_FS_Handle * | h, |
const char * | ext, | ||
const char * | uni | ||
) |
Remove serialization/deserialization directory from disk.
h | master context |
ext | component of the path |
uni | unique name of parent |
Definition at line 787 of file fs_api.c.
References get_serialization_file_name_in_dir(), GNUNET_DISK_directory_remove(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_YES, and h.
Referenced by free_search_context(), GNUNET_FS_download_stop(), and GNUNET_FS_search_stop().
|
static |
Serialize a start-time.
Since we use start-times to calculate the duration of some operation, we actually do not serialize the absolute time but the (relative) duration since the start time. When we then deserialize the start time, we take the current time and subtract that duration so that we get again an absolute time stamp that will result in correct performance calculations.
wh | handle for writing |
timestamp | time to serialize |
Definition at line 820 of file fs_api.c.
References GNUNET_BIO_write_int64(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_Relative::rel_value_us, and timestamp().
Referenced by GNUNET_FS_download_sync_(), GNUNET_FS_file_information_sync_(), GNUNET_FS_search_sync_(), and GNUNET_FS_unindex_sync_().
|
static |
Deserialize a start-time.
Since we use start-times to calculate the duration of some operation, we actually do not serialize the absolute time but the (relative) duration since the start time. Thus, when we then deserialize the start time, we take the current time and subtract that duration so that we get again an absolute time stamp that will result in correct performance calculations.
rh | handle for reading |
timestamp | where to write the deserialized timestamp |
Definition at line 845 of file fs_api.c.
References GNUNET_BIO_read_int64(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_subtract(), GNUNET_TIME_Relative::rel_value_us, and timestamp().
Referenced by deserialize_download(), deserialize_fi_node(), deserialize_search(), and deserialize_unindex_file().
|
static |
Using the given serialization filename, try to deserialize the file-information tree associated with it.
h | master context |
filename | name of the file (without directory) with the information |
Definition at line 1143 of file fs_api.c.
References _, deserialize_fi_node(), GNUNET_BIO_ReadHandle::emsg, filename, get_read_handle(), get_serialization_file_name(), GNUNET_BIO_read_close(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_SYNC_PATH_FILE_INFO, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, h, and ret.
Referenced by deserialize_fi_node(), and deserialize_publish_file().
|
static |
Using the given serialization filename, try to deserialize the file-information tree associated with it.
h | master context |
fn | name of the file (without directory) with the information |
rh | handle for reading |
Definition at line 882 of file fs_api.c.
References cleanup(), deserialize_file_information(), GNUNET_FS_FileInformation::dir, filename, GNUNET_BIO_read(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_int64(), GNUNET_BIO_read_string(), GNUNET_break, GNUNET_free, GNUNET_FS_data_reader_copy_(), GNUNET_FS_data_reader_file_(), GNUNET_FS_file_information_destroy(), GNUNET_FS_make_file_reader_context_(), GNUNET_FS_read_meta_data(), GNUNET_FS_uri_parse(), GNUNET_FS_uri_test_chk(), GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_sks(), GNUNET_malloc_large, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_YES, h, GNUNET_FS_FileInformation::next, read_start_time(), and ret.
Referenced by deserialize_file_information().
|
static |
Given a serialization name (full absolute path), return the basename of the file (without the path), which must only consist of the 6 random characters.
fullname | name to extract the basename from |
Definition at line 1186 of file fs_api.c.
References DIR_SEPARATOR, end, GNUNET_break, and GNUNET_strdup.
Referenced by deserialize_download_file(), deserialize_publish_file(), deserialize_search_file(), deserialize_search_result(), deserialize_subdownload(), deserialize_unindex_file(), GNUNET_FS_download_sync_(), make_serialization_file_name(), and make_serialization_file_name_in_dir().
|
static |
Create a new random name for serialization.
Also checks if persistence is enabled and returns NULL if not.
h | master context |
ext | component of the path |
Definition at line 1220 of file fs_api.c.
References get_serialization_file_name(), get_serialization_short_name(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_mktemp(), GNUNET_free, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_OK, h, and ret.
Referenced by GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_sync_(), GNUNET_FS_search_sync_(), and GNUNET_FS_unindex_sync_().
|
static |
Create a new random name for serialization.
Also checks if persistence is enabled and returns NULL if not.
h | master context |
ext | component of the path |
uni | name of parent |
Definition at line 1256 of file fs_api.c.
References get_serialization_file_name_in_dir(), get_serialization_short_name(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_mktemp(), GNUNET_free, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_OK, h, and ret.
Referenced by GNUNET_FS_search_result_sync_().
|
static |
Copy all of the data from the reader to the write handle.
wh | write handle |
fi | file with reader |
Definition at line 1292 of file fs_api.c.
References data, GNUNET_FS_FileInformation::data, GNUNET_BIO_ReadHandle::emsg, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::file_size, GNUNET_BIO_write(), GNUNET_free, GNUNET_MIN, GNUNET_OK, GNUNET_SYSERR, GNUNET_FS_FileInformation::reader, GNUNET_FS_FileInformation::reader_cls, and ret.
Referenced by GNUNET_FS_file_information_sync_().
void GNUNET_FS_file_information_sync_ | ( | struct GNUNET_FS_FileInformation * | fi | ) |
Create a temporary file on disk to store the current state of fi in.
Synchronize this file-information struct with its mirror on disk.
fi | file information to sync with disk |
Definition at line 1328 of file fs_api.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_FS_BlockOptions::anonymity_level, GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::chk_uri, cleanup(), GNUNET_FS_BlockOptions::content_priority, GNUNET_FS_FileInformation::contents_completed, GNUNET_FS_FileInformation::contents_size, copy_from_reader(), GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_data, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::do_index, GNUNET_FS_FileInformation::emsg, GNUNET_FS_FileInformation::entries, GNUNET_FS_BlockOptions::expiration_time, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::file_id, GNUNET_FS_FileInformation::file_size, GNUNET_FS_FileInformation::filename, get_serialization_file_name(), get_write_handle(), GNUNET_assert, GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int64(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_int32(), GNUNET_BIO_write_spec_int64(), GNUNET_BIO_write_spec_object(), GNUNET_BIO_write_spec_string(), GNUNET_BIO_write_string(), GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_file_information_sync_(), GNUNET_FS_SYNC_PATH_FILE_INFO, GNUNET_FS_uri_to_string(), GNUNET_FS_write_spec_meta_data(), GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_FS_FileInformation::h, GNUNET_FS_FileInformation::have_hash, GNUNET_FS_FileInformation::index_start_confirmed, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_FileInformation::is_published, GNUNET_FS_FileInformation::keywords, make_serialization_file_name(), GNUNET_FS_FileInformation::meta, GNUNET_FS_FileInformation::next, GNUNET_FS_BlockOptions::replication_level, GNUNET_FS_FileInformation::serialization, GNUNET_FS_FileInformation::sks_uri, GNUNET_FS_FileInformation::start_time, GNUNET_BIO_WriteSpec::wh, and write_start_time().
Referenced by encode_cont(), fip_signal_start(), GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_main_(), handle_index_start_failed(), handle_index_start_ok(), handle_signature_response(), hash_for_index_cb(), index_mq_error_handler(), publish_content(), and publish_kblocks_cont().
|
static |
Find the entry in the file information struct where the serialization filename matches the given name.
pos | file information to search |
srch | filename to search for |
Definition at line 1544 of file fs_api.c.
References GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::entries, find_file_position(), GNUNET_YES, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_FileInformation::next, and GNUNET_FS_FileInformation::serialization.
Referenced by deserialize_publish_file(), and find_file_position().
|
static |
Signal the FS's progress function that we are resuming an upload.
cls | closure (of type struct GNUNET_FS_PublishContext * , for the parent (!)) |
fi | the entry in the publish-structure |
length | length of the file or directory |
meta | metadata for the file or directory (can be modified) |
uri | pointer to the keywords that will be used for this entry (can be modified) |
bo | block options (can be modified) |
do_index | should we index? |
client_info | pointer to client context set upon creation (can be modified) |
Definition at line 1576 of file fs_api.c.
References GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_FileInformation::emsg, GNUNET_FS_ProgressInfo::fi, fip_signal_resume(), GNUNET_FS_file_information_inspect(), GNUNET_FS_meta_data_test_for_directory(), GNUNET_FS_publish_make_status_(), GNUNET_FS_STATUS_PUBLISH_RESUME, GNUNET_NO, GNUNET_OK, GNUNET_YES, meta, pc, GNUNET_FS_ProgressInfo::publish, GNUNET_FS_PublishContext::skip_next_fi_callback, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.
Referenced by deserialize_publish_file(), and fip_signal_resume().
|
static |
Function called with a filename of serialized publishing operation to deserialize.
cls | the struct GNUNET_FS_Handle * |
filename | complete filename (absolute path) |
Definition at line 1616 of file fs_api.c.
References _, GNUNET_FS_PublishContext::all_done, GNUNET_ARM_Handle::cfg, cleanup(), deserialize_file_information(), GNUNET_FS_PublishContext::dsh, GNUNET_FS_PublishContext::fi, GNUNET_FS_PublishContext::fi_pos, filename, find_file_position(), fip_signal_resume(), get_serialization_short_name(), GNUNET_assert, GNUNET_BIO_read(), GNUNET_BIO_read_close(), GNUNET_BIO_read_open_file(), GNUNET_BIO_read_spec_commit(), GNUNET_BIO_read_spec_end, GNUNET_BIO_read_spec_int32(), GNUNET_BIO_read_spec_string(), GNUNET_break, GNUNET_DATASTORE_connect(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_file_information_destroy(), GNUNET_FS_file_information_inspect(), GNUNET_FS_make_top(), GNUNET_FS_publish_main_(), GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY, GNUNET_FS_publish_signal_suspend_(), GNUNET_log, GNUNET_log_strerror_file, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_YES, h, GNUNET_FS_PublishContext::h, GNUNET_FS_PublishContext::nid, ns, GNUNET_FS_PublishContext::ns, GNUNET_FS_PublishContext::nuid, options, GNUNET_FS_PublishContext::options, pc, GNUNET_BIO_ReadSpec::rh, GNUNET_FS_PublishContext::serialization, GNUNET_FS_PublishContext::top, and GNUNET_FS_PublishContext::upload_task.
Referenced by GNUNET_FS_start().
void GNUNET_FS_publish_sync_ | ( | struct GNUNET_FS_PublishContext * | pc | ) |
Synchronize this publishing struct with its mirror on disk.
Note that all internal FS-operations that change publishing structs should already call "sync" internally, so this function is likely not useful for clients.
pc | the struct to sync |
Definition at line 1753 of file fs_api.c.
References GNUNET_FS_PublishContext::all_done, cleanup(), GNUNET_FS_PublishContext::fi, GNUNET_FS_PublishContext::fi_pos, get_write_handle(), GNUNET_BIO_read_spec_end, GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_int32(), GNUNET_BIO_write_spec_string(), GNUNET_break, GNUNET_free, GNUNET_FS_remove_sync_file_(), GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_FS_PublishContext::h, make_serialization_file_name(), GNUNET_FS_PublishContext::nid, GNUNET_FS_PublishContext::ns, GNUNET_FS_PublishContext::nuid, GNUNET_FS_PublishContext::options, pc, GNUNET_FS_FileInformation::serialization, GNUNET_FS_PublishContext::serialization, and GNUNET_BIO_WriteSpec::wh.
Referenced by finish_release_reserve(), GNUNET_FS_publish_main_(), GNUNET_FS_publish_start(), handle_index_start_failed(), handle_signature_response(), publish_kblocks_cont(), and publish_sblocks_cont().
void GNUNET_FS_unindex_sync_ | ( | struct GNUNET_FS_UnindexContext * | uc | ) |
Synchronize this unindex struct with its mirror on disk.
Note that all internal FS-operations that change publishing structs should already call "sync" internally, so this function is likely not useful for clients.
uc | the struct to sync |
Definition at line 1831 of file fs_api.c.
References GNUNET_FS_UnindexContext::chk, cleanup(), GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::file_id, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, get_write_handle(), GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_int32(), GNUNET_BIO_write_spec_int64(), GNUNET_BIO_write_spec_object(), GNUNET_BIO_write_spec_string(), GNUNET_BIO_write_string(), GNUNET_break, GNUNET_free, GNUNET_FS_remove_sync_file_(), GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, GNUNET_FS_uri_to_string(), GNUNET_OK, GNUNET_FS_UnindexContext::h, GNUNET_FS_UnindexContext::ksk_offset, GNUNET_FS_UnindexContext::ksk_uri, make_serialization_file_name(), GNUNET_FS_UnindexContext::serialization, GNUNET_FS_UnindexContext::start_time, GNUNET_FS_UnindexContext::state, uc, UNINDEX_STATE_ERROR, UNINDEX_STATE_FS_NOTIFY, GNUNET_BIO_WriteSpec::wh, and write_start_time().
Referenced by GNUNET_FS_unindex_do_remove_(), GNUNET_FS_unindex_do_remove_kblocks_(), GNUNET_FS_unindex_process_hash_(), GNUNET_FS_unindex_start(), handle_unindex_response(), unindex_directory_scan_cb(), unindex_extract_keywords(), unindex_finish(), and unindex_mq_error_handler().
|
static |
Serialize a download request.
wh | handle for writing the download request to disk |
dr | the the request to write to disk |
Definition at line 1908 of file fs_api.c.
References BRS_CHK_SET, DownloadRequest::children, DownloadRequest::chk, DownloadRequest::depth, GNUNET_BIO_write(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_int32(), GNUNET_BIO_write_spec_int64(), GNUNET_NO, GNUNET_OK, GNUNET_YES, DownloadRequest::num_children, DownloadRequest::offset, DownloadRequest::state, GNUNET_BIO_WriteSpec::wh, and write_download_request().
Referenced by GNUNET_FS_download_sync_(), and write_download_request().
|
static |
Read a download request tree.
rh | cadet to read from |
Definition at line 1941 of file fs_api.c.
References BRS_CHK_SET, BRS_DOWNLOAD_DOWN, BRS_DOWNLOAD_UP, BRS_ERROR, BRS_INIT, BRS_RECONSTRUCT_DOWN, BRS_RECONSTRUCT_META_UP, BRS_RECONSTRUCT_UP, DownloadRequest::children, DownloadRequest::chk, CHK_PER_INODE, cleanup(), DownloadRequest::depth, GNUNET_BIO_read(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_spec_commit(), GNUNET_BIO_read_spec_end, GNUNET_BIO_read_spec_int32(), GNUNET_BIO_read_spec_int64(), GNUNET_break, GNUNET_FS_free_download_request_(), GNUNET_malloc, GNUNET_new, GNUNET_OK, DownloadRequest::num_children, DownloadRequest::offset, DownloadRequest::parent, read_download_request(), GNUNET_BIO_ReadSpec::rh, and DownloadRequest::state.
Referenced by deserialize_download(), and read_download_request().
|
static |
Compute the name of the sync file (or directory) for the given download context.
dc | download context to compute for |
uni | unique filename to use, use "" for the directory name |
ext | extension to use, use ".dir" for our own subdirectory |
Definition at line 2016 of file fs_api.c.
References dc, DIR_SEPARATOR_STR, get_download_sync_filename(), get_serialization_file_name(), GNUNET_asprintf(), GNUNET_free, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::parent, GNUNET_FS_DownloadContext::search, and GNUNET_FS_DownloadContext::serialization.
Referenced by deserialize_download(), get_download_sync_filename(), and GNUNET_FS_download_sync_().
void GNUNET_FS_download_sync_ | ( | struct GNUNET_FS_DownloadContext * | dc | ) |
Synchronize this download struct with its mirror on disk.
Note that all internal FS-operations that change publishing structs should already call "sync" internally, so this function is likely not useful for clients.
dc | the struct to sync |
Definition at line 2049 of file fs_api.c.
References GNUNET_FS_DownloadContext::anonymity, cleanup(), GNUNET_FS_DownloadContext::completed, dc, dir, GNUNET_FS_DownloadContext::emsg, GNUNET_FS_DownloadContext::filename, get_download_sync_filename(), get_serialization_short_name(), GNUNET_assert, GNUNET_BIO_write_close(), GNUNET_BIO_write_open_file(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_int32(), GNUNET_BIO_write_spec_int64(), GNUNET_BIO_write_spec_string(), GNUNET_break, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_mktemp(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_uri_test_chk(), GNUNET_FS_uri_test_loc(), GNUNET_FS_uri_to_string(), GNUNET_FS_write_spec_meta_data(), GNUNET_log_strerror_file, GNUNET_OK, GNUNET_YES, GNUNET_FS_DownloadContext::has_finished, GNUNET_FS_DownloadContext::length, GNUNET_FS_DownloadContext::meta, GNUNET_FS_DownloadContext::offset, GNUNET_FS_DownloadContext::old_file_size, GNUNET_FS_DownloadContext::options, GNUNET_FS_DownloadContext::serialization, GNUNET_FS_DownloadContext::start_time, GNUNET_FS_DownloadContext::temp_filename, GNUNET_FS_DownloadContext::top_request, GNUNET_FS_DownloadContext::uri, GNUNET_BIO_WriteSpec::wh, write_download_request(), and write_start_time().
Referenced by check_completed(), GNUNET_FS_download_start_task_(), process_result_with_request(), search_result_stop(), and try_match_block().
void GNUNET_FS_search_result_sync_ | ( | struct GNUNET_FS_SearchResult * | sr | ) |
Synchronize this search result with its mirror on disk.
Note that all internal FS-operations that change publishing structs should already call "sync" internally, so this function is likely not useful for clients.
sr | the struct to sync |
Definition at line 2165 of file fs_api.c.
References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, cleanup(), GNUNET_FS_Uri::data, GNUNET_FS_SearchResult::download, get_write_handle_in_dir(), GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_int32(), GNUNET_BIO_write_spec_object(), GNUNET_BIO_write_spec_string(), GNUNET_break, GNUNET_free, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_URI_KSK, GNUNET_FS_uri_to_string(), GNUNET_FS_write_spec_meta_data(), GNUNET_OK, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, make_serialization_file_name_in_dir(), GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, GNUNET_FS_SearchContext::psearch_result, remove_sync_file_in_dir(), GNUNET_FS_SearchResult::sc, GNUNET_FS_SearchResult::serialization, GNUNET_FS_SearchContext::serialization, GNUNET_FS_DownloadContext::serialization, GNUNET_FS_Uri::type, GNUNET_FS_SearchResult::update_search, GNUNET_FS_SearchResult::uri, GNUNET_FS_SearchContext::uri, and GNUNET_BIO_WriteSpec::wh.
Referenced by GNUNET_FS_download_start_task_(), GNUNET_FS_download_stop(), GNUNET_FS_search_probe_progress_(), probe_failure_handler(), probe_success_handler(), process_ksk_result(), and process_sks_result().
void GNUNET_FS_search_sync_ | ( | struct GNUNET_FS_SearchContext * | sc | ) |
Synchronize this search struct with its mirror on disk.
Note that all internal FS-operations that change publishing structs should already call "sync" internally, so this function is likely not useful for clients.
sc | the struct to sync |
Definition at line 2266 of file fs_api.c.
References GNUNET_FS_SearchContext::anonymity, cleanup(), GNUNET_FS_SearchContext::emsg, get_write_handle(), GNUNET_assert, GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_string(), GNUNET_break, GNUNET_free, GNUNET_FS_remove_sync_file_(), GNUNET_FS_SYNC_PATH_CHILD_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_sks(), GNUNET_FS_uri_to_string(), GNUNET_OK, GNUNET_YES, GNUNET_FS_SearchContext::h, make_serialization_file_name(), GNUNET_FS_SearchContext::options, GNUNET_FS_SearchContext::psearch_result, sc, GNUNET_FS_SearchContext::serialization, GNUNET_FS_SearchContext::start_time, GNUNET_FS_SearchContext::task, GNUNET_FS_SearchContext::uri, and write_start_time().
Referenced by GNUNET_FS_search_continue(), GNUNET_FS_search_pause(), and search_start().
|
static |
Function called with a filename of serialized unindexing operation to deserialize.
cls | the struct GNUNET_FS_Handle * |
filename | complete filename (absolute path) |
Definition at line 2330 of file fs_api.c.
References _, GNUNET_FS_UnindexContext::chk, cleanup(), GNUNET_FS_Uri::data, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_id, GNUNET_FS_UnindexContext::file_size, filename, GNUNET_FS_UnindexContext::filename, get_serialization_short_name(), GNUNET_BIO_read(), GNUNET_BIO_read_close(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_int64(), GNUNET_BIO_read_open_file(), GNUNET_BIO_read_string(), GNUNET_break, GNUNET_CRYPTO_hash_file(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_make_top(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_STATUS_UNINDEX_RESUME, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, GNUNET_FS_unindex_do_extract_keywords_(), GNUNET_FS_unindex_do_remove_(), GNUNET_FS_unindex_do_remove_kblocks_(), GNUNET_FS_unindex_make_status_(), GNUNET_FS_unindex_process_hash_(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_uri_parse(), GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_PRIORITY_IDLE, h, GNUNET_FS_UnindexContext::h, HASHING_BLOCKSIZE, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_UnindexContext::ksk_offset, GNUNET_FS_UnindexContext::ksk_uri, read_start_time(), GNUNET_FS_UnindexContext::serialization, GNUNET_FS_UnindexContext::start_time, GNUNET_FS_UnindexContext::state, state, GNUNET_FS_ProgressInfo::status, GNUNET_FS_UnindexContext::top, uc, GNUNET_FS_ProgressInfo::unindex, UNINDEX_STATE_COMPLETE, UNINDEX_STATE_DS_REMOVE, UNINDEX_STATE_DS_REMOVE_KBLOCKS, UNINDEX_STATE_ERROR, UNINDEX_STATE_EXTRACT_KEYWORDS, UNINDEX_STATE_FS_NOTIFY, UNINDEX_STATE_HASHING, and GNUNET_FS_ProgressInfo::value.
Referenced by GNUNET_FS_start().
|
static |
Deserialize a download.
h | overall context |
rh | file to deserialize from |
parent | parent download |
search | associated search |
serialization | name under which the search was serialized |
Definition at line 2927 of file fs_api.c.
References GNUNET_FS_DownloadContext::active, GNUNET_FS_DownloadContext::anonymity, GNUNET_FS_DownloadContext::child_head, GNUNET_FS_DownloadContext::child_tail, cleanup(), GNUNET_FS_DownloadContext::completed, DBLOCK_SIZE, dc, deserialize_subdownload(), GNUNET_FS_SearchResult::download, GNUNET_FS_DownloadContext::emsg, GNUNET_FS_DownloadContext::filename, free_download_context(), get_download_sync_filename(), GNUNET_assert, GNUNET_BIO_read_int32(), GNUNET_BIO_read_spec_commit(), GNUNET_BIO_read_spec_end, GNUNET_BIO_read_spec_int64(), GNUNET_BIO_read_spec_string(), GNUNET_BIO_read_string(), GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_FS_compute_depth(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_start_task_(), GNUNET_FS_make_top(), GNUNET_FS_read_spec_meta_data(), GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_uri_loc_get_peer_identity(), GNUNET_FS_uri_parse(), GNUNET_FS_uri_test_chk(), GNUNET_FS_uri_test_loc(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_strdup, GNUNET_YES, h, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::has_finished, consensus-simulation::int, GNUNET_FS_DownloadContext::job_queue, GNUNET_FS_DownloadContext::length, GNUNET_FS_DownloadContext::meta, GNUNET_FS_DownloadContext::offset, GNUNET_FS_DownloadContext::old_file_size, options, GNUNET_FS_DownloadContext::options, GNUNET_FS_DownloadContext::parent, read_download_request(), read_start_time(), GNUNET_BIO_ReadSpec::rh, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::serialization, signal_download_resume(), GNUNET_FS_DownloadContext::start_time, status, GNUNET_FS_DownloadContext::target, GNUNET_FS_DownloadContext::task, GNUNET_FS_DownloadContext::temp_filename, GNUNET_FS_DownloadContext::top, GNUNET_FS_DownloadContext::top_request, GNUNET_FS_DownloadContext::treedepth, and GNUNET_FS_DownloadContext::uri.
Referenced by deserialize_download_file(), deserialize_search_result(), and deserialize_subdownload().
|
static |
Deserialize a search.
h | overall context |
rh | file to deserialize from |
psearch_result | parent search result |
serialization | name under which the search was serialized |
Definition at line 3064 of file fs_api.c.
References _, GNUNET_FS_SearchContext::anonymity, cleanup(), deserialize_search_result(), GNUNET_FS_SearchContext::emsg, free_search_context(), get_serialization_file_name_in_dir(), GNUNET_BIO_read(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_string(), GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_search_start_searching_(), GNUNET_FS_SYNC_PATH_CHILD_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_uri_parse(), GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_sks(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_YES, h, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchContext::master_result_map, options, GNUNET_FS_SearchContext::options, GNUNET_FS_SearchContext::psearch_result, read_start_time(), sc, GNUNET_FS_SearchContext::serialization, signal_search_resume(), GNUNET_FS_SearchContext::start_time, GNUNET_FS_SearchResult::update_search, and GNUNET_FS_SearchContext::uri.
Referenced by deserialize_search_file(), and deserialize_search_result().
|
static |
Function called with a filename of serialized search result to deserialize.
cls | the struct GNUNET_FS_SearchContext * |
filename | complete filename (absolute path) |
Definition at line 2537 of file fs_api.c.
References _, GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, cleanup(), GNUNET_FS_Uri::data, deserialize_download(), deserialize_search(), GNUNET_FS_SearchResult::download, GNUNET_FS_SearchContext::emsg, filename, get_read_handle(), get_serialization_short_name(), GNUNET_BIO_read(), GNUNET_BIO_read_close(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_open_file(), GNUNET_BIO_read_string(), GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_read_meta_data(), GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_uri_destroy(), GNUNET_FS_URI_KSK, GNUNET_FS_uri_parse(), GNUNET_log, GNUNET_malloc, GNUNET_new, GNUNET_OK, GNUNET_YES, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_Uri::keywordCount, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, GNUNET_FS_SearchContext::psearch_result, remove_sync_file_in_dir(), sc, GNUNET_FS_SearchResult::sc, GNUNET_FS_SearchResult::serialization, GNUNET_FS_SearchContext::serialization, GNUNET_FS_Uri::type, GNUNET_FS_SearchResult::uri, and GNUNET_FS_SearchContext::uri.
Referenced by deserialize_search().
|
static |
Send the 'resume' signal to the callback; also actually resume the download (put it in the queue).
Does this recursively for the top-level download and all child downloads.
dc | download to resume |
Definition at line 2701 of file fs_api.c.
References GNUNET_FS_DownloadContext::child_head, dc, GNUNET_FS_ProgressInfo::download, GNUNET_FS_DownloadContext::emsg, GNUNET_FS_download_make_status_(), GNUNET_FS_STATUS_DOWNLOAD_RESUME, GNUNET_FS_DownloadContext::meta, GNUNET_FS_DownloadContext::next, signal_download_resume(), GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.
Referenced by deserialize_download(), signal_download_resume(), and signal_result_resume().
|
static |
Signal resuming of a search to our clients (for the top level search and all sub-searches).
sc | search being resumed |
Definition at line 3040 of file fs_api.c.
References GNUNET_FS_SearchContext::client_info, GNUNET_FS_SearchContext::emsg, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_RESUME, GNUNET_NO, GNUNET_YES, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, sc, GNUNET_FS_ProgressInfo::search, signal_result_resume(), GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.
Referenced by deserialize_search(), and signal_result_resume().
|
static |
Iterator over search results signaling resume to the client for each result.
cls | closure, the struct GNUNET_FS_SearchContext * |
key | current key code |
value | value in the hash map, the struct GNUNET_FS_SearchResult * |
Definition at line 2739 of file fs_api.c.
References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchResult::download, GNUNET_FS_search_make_status_(), GNUNET_FS_search_start_probe_(), GNUNET_FS_STATUS_SEARCH_RESUME_RESULT, GNUNET_YES, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, sc, GNUNET_FS_ProgressInfo::search, signal_download_resume(), signal_search_resume(), GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::update_search, GNUNET_FS_SearchResult::uri, value, and GNUNET_FS_ProgressInfo::value.
Referenced by signal_search_resume().
|
static |
Free memory allocated by the search context and its children.
sc | search context to free |
Definition at line 2813 of file fs_api.c.
References GNUNET_FS_SearchContext::emsg, free_result(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_FS_remove_sync_dir_(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_SYNC_PATH_CHILD_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_uri_destroy(), GNUNET_FS_SearchContext::h, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::psearch_result, sc, GNUNET_FS_SearchContext::serialization, and GNUNET_FS_SearchContext::uri.
Referenced by deserialize_search(), and free_result().
|
static |
Iterator over search results freeing each.
cls | closure, the struct GNUNET_FS_SearchContext * |
key | current key code |
value | value in the hash map, the struct GNUNET_FS_SearchResult * |
Definition at line 2791 of file fs_api.c.
References free_search_context(), GNUNET_assert, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_uri_destroy(), GNUNET_YES, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::update_search, GNUNET_FS_SearchResult::uri, and value.
Referenced by free_search_context().
|
static |
Function called with a filename of serialized sub-download to deserialize.
cls | the struct GNUNET_FS_DownloadContext * (parent) |
filename | complete filename (absolute path) |
Definition at line 2852 of file fs_api.c.
References _, deserialize_download(), GNUNET_BIO_ReadHandle::emsg, GNUNET_FS_DownloadContext::emsg, filename, get_serialization_short_name(), GNUNET_BIO_read_close(), GNUNET_BIO_read_open_file(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_FS_DownloadContext::h, and GNUNET_FS_DownloadContext::parent.
Referenced by deserialize_download().
|
static |
Free this download context and all of its descendants.
(only works during deserialization since not all possible state it taken care of).
dc | context to free |
Definition at line 2893 of file fs_api.c.
References GNUNET_FS_DownloadContext::active, GNUNET_FS_DownloadContext::child_head, GNUNET_FS_DownloadContext::child_tail, dc, GNUNET_FS_DownloadContext::emsg, GNUNET_FS_DownloadContext::filename, free_download_context(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_free, GNUNET_FS_free_download_request_(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_uri_destroy(), GNUNET_FS_DownloadContext::meta, GNUNET_FS_DownloadContext::serialization, GNUNET_FS_DownloadContext::temp_filename, GNUNET_FS_DownloadContext::top_request, and GNUNET_FS_DownloadContext::uri.
Referenced by deserialize_download(), and free_download_context().
|
static |
Function called with a filename of serialized search operation to deserialize.
cls | the struct GNUNET_FS_Handle * |
filename | complete filename (absolute path) |
Definition at line 3150 of file fs_api.c.
References _, deserialize_search(), filename, get_serialization_short_name(), GNUNET_BIO_read_close(), GNUNET_BIO_read_open_file(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_make_top(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, h, sc, and GNUNET_FS_SearchContext::top.
Referenced by GNUNET_FS_start().
|
static |
Function called with a filename of serialized download operation to deserialize.
cls | the struct GNUNET_FS_Handle * |
filename | complete filename (absolute path) |
Definition at line 3202 of file fs_api.c.
References deserialize_download(), GNUNET_BIO_ReadHandle::emsg, filename, get_serialization_short_name(), GNUNET_BIO_read_close(), GNUNET_BIO_read_open_file(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, and h.
Referenced by GNUNET_FS_start().
|
static |
Deserialize information about pending operations.
master_path | which master directory should be scanned |
proc | function to call for each entry (will get h for 'cls') |
h | the struct GNUNET_FS_Handle * |
Definition at line 3244 of file fs_api.c.
References get_serialization_file_name(), GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_YES, and h.
Referenced by GNUNET_FS_start().