GNUnet  0.19.2
fs_api.h File Reference

shared definitions for the FS library More...

#include "gnunet_constants.h"
#include "gnunet_datastore_service.h"
#include "gnunet_dht_service.h"
#include "gnunet_fs_service.h"
#include "gnunet_block_lib.h"
#include "block_fs.h"
#include "fs.h"
Include dependency graph for fs_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FileIdentifier
 complete information needed to download a file. More...
 
struct  Location
 Information about a file and its location (peer claiming to share the file). More...
 
struct  GNUNET_FS_Uri
 A Universal Resource Identifier (URI), opaque. More...
 
struct  GNUNET_FS_FileInformation
 Information for a file or directory that is about to be published. More...
 
struct  GNUNET_FS_QueueEntry
 Entry in the job queue. More...
 
struct  GNUNET_FS_SearchResult
 Information we store for each search result. More...
 
struct  TopLevelActivity
 We track all of the top-level activities of FS so that we can signal 'suspend' on shutdown. More...
 
struct  GNUNET_FS_Handle
 Master context for most FS operations. More...
 
struct  GNUNET_FS_PublishContext
 Handle for controlling a publication process. More...
 
struct  GNUNET_FS_UnindexContext
 Handle for controlling an unindexing operation. More...
 
struct  SearchRequestEntry
 Information we keep for each keyword in a keyword search. More...
 
struct  GNUNET_FS_SearchContext
 Handle for controlling a search. More...
 
struct  DownloadRequest
 Information about an active download request. More...
 
struct  GNUNET_FS_DownloadContext
 Context for controlling a download. More...
 

Macros

#define CHK_PER_INODE   256
 Pick a multiple of 2 here to achieve 8-byte alignment! We also probably want DBlocks to have (roughly) the same size as IBlocks. More...
 
#define MAX_INLINE_SIZE   65536
 Maximum size for a file to be considered for inlining in a directory. More...
 
#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH   "search"
 Name of the directory with top-level searches. More...
 
#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH   "search-child"
 Name of the directory with sub-searches (namespace-updates). More...
 
#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD   "download"
 Name of the directory with master downloads (not associated with search or part of another download). More...
 
#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD   "download-child"
 Name of the directory with downloads that are part of another download or a search. More...
 
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH   "publish"
 Name of the directory with publishing operations. More...
 
#define GNUNET_FS_SYNC_PATH_FILE_INFO   "publish-file"
 Name of the directory with files that are being published. More...
 
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX   "unindex"
 Name of the directory with unindex operations. More...
 

Typedefs

typedef void(* SuspendSignalFunction) (void *cls)
 Function signature of the functions that can be called to trigger suspend signals and clean-up for top-level activities. More...
 

Enumerations

enum  GNUNET_FS_UriType { GNUNET_FS_URI_CHK , GNUNET_FS_URI_SKS , GNUNET_FS_URI_KSK , GNUNET_FS_URI_LOC }
 Types of URIs. More...
 
enum  GNUNET_FS_QueuePriority { GNUNET_FS_QUEUE_PRIORITY_PROBE , GNUNET_FS_QUEUE_PRIORITY_NORMAL }
 Priorities for the queue. More...
 
enum  UnindexState {
  UNINDEX_STATE_HASHING = 0 , UNINDEX_STATE_DS_REMOVE = 1 , UNINDEX_STATE_EXTRACT_KEYWORDS = 2 , UNINDEX_STATE_DS_REMOVE_KBLOCKS = 3 ,
  UNINDEX_STATE_FS_NOTIFY = 4 , UNINDEX_STATE_COMPLETE = 5 , UNINDEX_STATE_ERROR = 6
}
 Phases of unindex processing (state machine). More...
 
enum  BlockRequestState {
  BRS_INIT = 0 , BRS_RECONSTRUCT_DOWN = 1 , BRS_RECONSTRUCT_META_UP = 2 , BRS_RECONSTRUCT_UP = 3 ,
  BRS_CHK_SET = 4 , BRS_DOWNLOAD_DOWN = 5 , BRS_DOWNLOAD_UP = 6 , BRS_ERROR = 7
}
 FSM for possible states a block can go through. More...
 

Functions

struct GNUNET_FS_QueueEntryGNUNET_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...
 
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...
 
void * GNUNET_FS_search_probe_progress_ (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 Notification of FS that a search probe has made progress. More...
 
void GNUNET_FS_publish_main_ (void *cls)
 Main function that performs the upload. More...
 
void GNUNET_FS_unindex_process_hash_ (void *cls, const struct GNUNET_HashCode *file_id)
 Function called once the hash of the file that is being unindexed has been computed. More...
 
void GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc)
 Extract the keywords for KBlock removal. More...
 
void GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc)
 If necessary, connect to the datastore and remove the KBlocks. More...
 
void * GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_PublishContext *pc, const struct GNUNET_FS_FileInformation *p, uint64_t offset)
 Fill in all of the generic fields for a publish event and call the callback. More...
 
void GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_DownloadContext *dc)
 Fill in all of the generic fields for a download event and call the callback. More...
 
void GNUNET_FS_download_start_task_ (void *cls)
 Task that creates the initial (top-level) download request for the file. More...
 
void GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_UnindexContext *uc, uint64_t offset)
 Fill in all of the generic fields for an unindex event and call the callback. More...
 
void * GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
 Fill in all of the generic fields for a search event and call the callback. More...
 
void GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
 Connect to the datastore and remove the blocks. More...
 
int GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
 Build the request and actually initiate the search using the GNUnet FS service. More...
 
void GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc)
 Start the downloading process (by entering the queue). More...
 
void GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr)
 Start download probes for the given search result. 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...
 
void GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, const char *uni)
 Remove serialization/deserialization directory from disk. More...
 
void GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f)
 Synchronize this file-information struct with its mirror on disk. 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...
 
void GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc)
 Synchronize this search 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_download_sync_ (struct GNUNET_FS_DownloadContext *dc)
 Synchronize this download struct with its mirror on disk. More...
 
void GNUNET_FS_publish_signal_suspend_ (void *cls)
 Create SUSPEND event for the given publish operation and then clean up our state (without stop signal). More...
 
void GNUNET_FS_search_signal_suspend_ (void *cls)
 Create SUSPEND event for the given search operation and then clean up our state (without stop signal). More...
 
void GNUNET_FS_download_signal_suspend_ (void *cls)
 Create SUSPEND event for the given download operation and then clean up our state (without stop signal). More...
 
void GNUNET_FS_unindex_signal_suspend_ (void *cls)
 Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal). More...
 
struct TopLevelActivityGNUNET_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...
 
void GNUNET_FS_free_download_request_ (struct DownloadRequest *dr)
 (recursively) free download request structure More...
 
void GNUNET_FS_stop_probe_ping_task_ (struct GNUNET_FS_SearchResult *sr)
 Stop the ping task for this search result. More...
 

Detailed Description

shared definitions for the FS library

Author
Igor Wronsky, Christian Grothoff

Definition in file fs_api.h.

Macro Definition Documentation

◆ CHK_PER_INODE

#define CHK_PER_INODE   256

Pick a multiple of 2 here to achieve 8-byte alignment! We also probably want DBlocks to have (roughly) the same size as IBlocks.

With SHA-512, the optimal value is 32768 byte / 128 byte = 256 (128 byte = 2 * 512 bits). DO NOT CHANGE!

Definition at line 44 of file fs_api.h.

◆ MAX_INLINE_SIZE

#define MAX_INLINE_SIZE   65536

Maximum size for a file to be considered for inlining in a directory.

Definition at line 50 of file fs_api.h.

◆ GNUNET_FS_SYNC_PATH_MASTER_SEARCH

#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH   "search"

Name of the directory with top-level searches.

Definition at line 55 of file fs_api.h.

◆ GNUNET_FS_SYNC_PATH_CHILD_SEARCH

#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH   "search-child"

Name of the directory with sub-searches (namespace-updates).

Definition at line 60 of file fs_api.h.

◆ GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD

#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD   "download"

Name of the directory with master downloads (not associated with search or part of another download).

Definition at line 66 of file fs_api.h.

◆ GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD

#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD   "download-child"

Name of the directory with downloads that are part of another download or a search.

Definition at line 72 of file fs_api.h.

◆ GNUNET_FS_SYNC_PATH_MASTER_PUBLISH

#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH   "publish"

Name of the directory with publishing operations.

Definition at line 77 of file fs_api.h.

◆ GNUNET_FS_SYNC_PATH_FILE_INFO

#define GNUNET_FS_SYNC_PATH_FILE_INFO   "publish-file"

Name of the directory with files that are being published.

Definition at line 82 of file fs_api.h.

◆ GNUNET_FS_SYNC_PATH_MASTER_UNINDEX

#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX   "unindex"

Name of the directory with unindex operations.

Definition at line 87 of file fs_api.h.

Typedef Documentation

◆ SuspendSignalFunction

typedef void(* SuspendSignalFunction) (void *cls)

Function signature of the functions that can be called to trigger suspend signals and clean-up for top-level activities.

Parameters
clsclosure

Definition at line 1011 of file fs_api.h.

Enumeration Type Documentation

◆ GNUNET_FS_UriType

Types of URIs.

Enumerator
GNUNET_FS_URI_CHK 

Content-hash-key (simple file).

GNUNET_FS_URI_SKS 

Signed key space (file in namespace).

GNUNET_FS_URI_KSK 

Keyword search key (query with keywords).

GNUNET_FS_URI_LOC 

Location (chk with identity of hosting peer).

Definition at line 139 of file fs_api.h.

140 {
145 
150 
155 
160 };
@ GNUNET_FS_URI_LOC
Location (chk with identity of hosting peer).
Definition: fs_api.h:159
@ GNUNET_FS_URI_CHK
Content-hash-key (simple file).
Definition: fs_api.h:144
@ GNUNET_FS_URI_SKS
Signed key space (file in namespace).
Definition: fs_api.h:149
@ GNUNET_FS_URI_KSK
Keyword search key (query with keywords).
Definition: fs_api.h:154

◆ GNUNET_FS_QueuePriority

Priorities for the queue.

Enumerator
GNUNET_FS_QUEUE_PRIORITY_PROBE 

This is a probe (low priority).

GNUNET_FS_QUEUE_PRIORITY_NORMAL 

Default priority.

Definition at line 403 of file fs_api.h.

404 {
409 
414 };
@ GNUNET_FS_QUEUE_PRIORITY_NORMAL
Default priority.
Definition: fs_api.h:413
@ GNUNET_FS_QUEUE_PRIORITY_PROBE
This is a probe (low priority).
Definition: fs_api.h:408

◆ UnindexState

Phases of unindex processing (state machine).

Enumerator
UNINDEX_STATE_HASHING 

We're currently hashing the file.

UNINDEX_STATE_DS_REMOVE 

We're telling the datastore to delete the respective DBlocks and IBlocks.

UNINDEX_STATE_EXTRACT_KEYWORDS 

Find out which keywords apply.

UNINDEX_STATE_DS_REMOVE_KBLOCKS 

We're telling the datastore to remove KBlocks.

UNINDEX_STATE_FS_NOTIFY 

We're notifying the FS service about the unindexing.

UNINDEX_STATE_COMPLETE 

We're done.

UNINDEX_STATE_ERROR 

We've encountered a fatal error.

Definition at line 1306 of file fs_api.h.

1307 {
1312 
1318 
1323 
1328 
1334 
1339 
1344 };
@ UNINDEX_STATE_EXTRACT_KEYWORDS
Find out which keywords apply.
Definition: fs_api.h:1322
@ UNINDEX_STATE_COMPLETE
We're done.
Definition: fs_api.h:1338
@ UNINDEX_STATE_DS_REMOVE
We're telling the datastore to delete the respective DBlocks and IBlocks.
Definition: fs_api.h:1317
@ UNINDEX_STATE_HASHING
We're currently hashing the file.
Definition: fs_api.h:1311
@ UNINDEX_STATE_ERROR
We've encountered a fatal error.
Definition: fs_api.h:1343
@ UNINDEX_STATE_FS_NOTIFY
We're notifying the FS service about the unindexing.
Definition: fs_api.h:1333
@ UNINDEX_STATE_DS_REMOVE_KBLOCKS
We're telling the datastore to remove KBlocks.
Definition: fs_api.h:1327

◆ BlockRequestState

FSM for possible states a block can go through.

The typical order of progression is linear through the states, alternatives are documented in the comments.

Enumerator
BRS_INIT 

Initial state, block has only been allocated (since it is relevant to the overall download request).

BRS_RECONSTRUCT_DOWN 

We've checked the block on the path down the tree, and the content on disk did match the desired CHK, but not all the way down, so at the bottom some blocks will still need to be reconstructed).

BRS_RECONSTRUCT_META_UP 

We've calculated the CHK bottom-up based on the meta data.

This may work, but if it did we have to write the meta data to disk at the end (and we still need to check against the CHK set on top).

BRS_RECONSTRUCT_UP 

We've calculated the CHK bottom-up based on what we have on disk, which may not be what the desired CHK is.

If the reconstructed CHKs match whatever comes from above, we're done with the respective subtree.

BRS_CHK_SET 

We've determined the real, desired CHK for this block (full tree reconstruction failed), request is now pending.

If the CHK that bubbled up through reconstruction did match the top-level request, the state machine for the subtree would have moved to BRS_DOWNLOAD_UP.

BRS_DOWNLOAD_DOWN 

We've successfully downloaded this block, but the children still need to be either downloaded or verified (download request propagates down).

If the download fails, the state machine for this block may move to BRS_DOWNLOAD_ERROR instead.

BRS_DOWNLOAD_UP 

This block and all of its children have been downloaded successfully (full completion propagates up).

BRS_ERROR 

We got a block back that matched the query but did not hash to the key (malicious publisher or hash collision); this block can never be downloaded (error propagates up).

Definition at line 1607 of file fs_api.h.

1608 {
1613  BRS_INIT = 0,
1614 
1622 
1630 
1637  BRS_RECONSTRUCT_UP = 3,
1638 
1646  BRS_CHK_SET = 4,
1647 
1655  BRS_DOWNLOAD_DOWN = 5,
1656 
1661  BRS_DOWNLOAD_UP = 6,
1662 
1668  BRS_ERROR = 7
1669 };
@ BRS_DOWNLOAD_UP
This block and all of its children have been downloaded successfully (full completion propagates up).
Definition: fs_api.h:1661
@ BRS_RECONSTRUCT_META_UP
We've calculated the CHK bottom-up based on the meta data.
Definition: fs_api.h:1629
@ BRS_CHK_SET
We've determined the real, desired CHK for this block (full tree reconstruction failed),...
Definition: fs_api.h:1646
@ BRS_ERROR
We got a block back that matched the query but did not hash to the key (malicious publisher or hash c...
Definition: fs_api.h:1668
@ BRS_RECONSTRUCT_DOWN
We've checked the block on the path down the tree, and the content on disk did match the desired CHK,...
Definition: fs_api.h:1621
@ BRS_INIT
Initial state, block has only been allocated (since it is relevant to the overall download request).
Definition: fs_api.h:1613
@ BRS_DOWNLOAD_DOWN
We've successfully downloaded this block, but the children still need to be either downloaded or veri...
Definition: fs_api.h:1655
@ BRS_RECONSTRUCT_UP
We've calculated the CHK bottom-up based on what we have on disk, which may not be what the desired C...
Definition: fs_api.h:1637

Function Documentation

◆ GNUNET_FS_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.

Parameters
hhandle to the overall FS state
startfunction to call to begin the job
stopfunction to call to pause the job, or on dequeue (if the job was running)
clsclosure for start and stop
blocksnumber of blocks this download has
priorityhow important is this download
Returns
queue handle

Definition at line 321 of file fs_api.c.

327 {
328  struct GNUNET_FS_QueueEntry *qe;
329 
331  qe->h = h;
332  qe->start = start;
333  qe->stop = stop;
334  qe->cls = cls;
335  qe->queue_time = GNUNET_TIME_absolute_get ();
336  qe->blocks = blocks;
337  qe->priority = priority;
338  GNUNET_CONTAINER_DLL_insert_after (h->pending_head,
339  h->pending_tail,
340  h->pending_tail,
341  qe);
342  if (NULL != h->queue_job)
343  GNUNET_SCHEDULER_cancel (h->queue_job);
345  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing job %p\n", qe);
346  return qe;
347 }
static void process_job_queue(void *cls)
Process the jobs in the job queue, possibly starting some and stopping others.
Definition: fs_api.c:107
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1268
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:944
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
unsigned int priority
Priority in the queue.
struct GNUNET_DATASTORE_Handle * h
Handle to the master context.
Entry in the job queue.
Definition: fs_api.h:421
GNUNET_SCHEDULER_TaskCallback stop
Function to call when the job needs to stop (or is done / dequeued).
Definition: fs_api.h:440
void * cls
Closure for start and stop.
Definition: fs_api.h:445
enum GNUNET_FS_QueuePriority priority
How important is this download?
Definition: fs_api.h:481
unsigned int blocks
How many blocks do the active downloads have?
Definition: fs_api.h:476

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_().

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

◆ GNUNET_FS_dequeue_()

void GNUNET_FS_dequeue_ ( struct GNUNET_FS_QueueEntry qe)

Dequeue a job from the queue.

Parameters
qehandle for the job

Definition at line 356 of file fs_api.c.

357 {
358  struct GNUNET_FS_Handle *h;
359 
360  h = qe->h;
361  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dequeueing job %p\n", qe);
362  if (GNUNET_YES == qe->active)
363  stop_job (qe);
364  GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, qe);
365  GNUNET_free (qe);
366  if (NULL != h->queue_job)
367  GNUNET_SCHEDULER_cancel (h->queue_job);
369 }
static void stop_job(struct GNUNET_FS_QueueEntry *qe)
Stop the given job (send signal, remove from active queue, update counters and state).
Definition: fs_api.c:78
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_YES
#define GNUNET_free(ptr)
Wrapper around free.
Master context for most FS operations.
Definition: fs_api.h:1070

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_(), and process_result_with_request().

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

◆ GNUNET_FS_data_reader_file_()

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.

Parameters
clsclosure (points to the file information)
offsetoffset to read from; it is possible that the caller might need to go backwards a bit at times
maxmaximum 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
bufwhere the reader should write the data
emsglocation for the reader to store an error message
Returns
number of bytes written, usually "max", 0 on error
Parameters
clsclosure with the struct FileInfo *
offsetoffset 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
maxmaximum 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
bufwhere the reader should write the data
emsglocation for the reader to store an error message
Returns
number of bytes written, usually max, 0 on error

Definition at line 447 of file fs_api.c.

452 {
453  struct FileInfo *fi = cls;
454  ssize_t ret;
455 
456  if (UINT64_MAX == offset)
457  {
458  if (NULL != fi->fd)
459  {
461  fi->fd = NULL;
462  }
463  return 0;
464  }
465  if (0 == max)
466  {
467  if (NULL != fi->fd)
469  GNUNET_free (fi->filename);
470  GNUNET_free (fi);
471  return 0;
472  }
473  if (NULL == fi->fd)
474  {
475  fi->fd = GNUNET_DISK_file_open (fi->filename,
478  if (NULL == fi->fd)
479  {
480  GNUNET_asprintf (emsg,
481  _ ("Could not open file `%s': %s"),
482  fi->filename,
483  strerror (errno));
484  return 0;
485  }
486  }
487  if ((GNUNET_SYSERR ==
489  (-1 == (ret = GNUNET_DISK_file_read (fi->fd, buf, max))))
490  {
491  GNUNET_asprintf (emsg,
492  _ ("Could not read file `%s': %s"),
493  fi->filename,
494  strerror (errno));
495  return 0;
496  }
497  if (ret != max)
498  {
499  GNUNET_asprintf (emsg,
500  _ ("Short read reading from file `%s'!"),
501  fi->filename);
502  return 0;
503  }
504  return max;
505 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char buf[2048]
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1234
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.
Definition: disk.c:205
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1305
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.
Definition: disk.c:621
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_SEEK_SET
Seek an absolute position (from the start of the file).
@ GNUNET_SYSERR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define max(x, y)
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
Closure for GNUNET_FS_data_reader_file_().
Definition: fs_api.c:413
struct GNUNET_DISK_FileHandle * fd
File descriptor, NULL if it has not yet been opened.
Definition: fs_api.c:422
char * filename
Name of the file to read.
Definition: fs_api.c:417

References _, buf, 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().

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

◆ GNUNET_FS_make_file_reader_context_()

void* GNUNET_FS_make_file_reader_context_ ( const char *  filename)

Create the closure for the GNUNET_FS_data_reader_file_() callback.

Parameters
filenamefile to read
Returns
closure to use, NULL on error

Definition at line 509 of file fs_api.c.

510 {
511  struct FileInfo *fi;
512 
513  fi = GNUNET_new (struct FileInfo);
515  if (NULL == fi->filename)
516  {
517  GNUNET_free (fi);
518  return NULL;
519  }
520  return fi;
521 }
static char * filename
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:494

References FileInfo::filename, filename, GNUNET_free, GNUNET_new, and GNUNET_STRINGS_filename_expand().

Referenced by deserialize_fi_node(), and GNUNET_FS_file_information_create_from_file().

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

◆ GNUNET_FS_data_reader_copy_()

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.

Parameters
clsclosure (points to the buffer)
offsetoffset to read from; it is possible that the caller might need to go backwards a bit at times
maxmaximum 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
bufwhere the reader should write the data
emsglocation for the reader to store an error message
Returns
number of bytes written, usually max, 0 on error
Parameters
clsclosure (points to the buffer)
offsetoffset 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
maxmaximum 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
bufwhere the reader should write the data
emsglocation for the reader to store an error message
Returns
number of bytes written, usually max, 0 on error

Definition at line 545 of file fs_api.c.

550 {
551  char *data = cls;
552 
553  if (UINT64_MAX == offset)
554  return 0;
555  if (0 == max)
556  {
557  GNUNET_free (data);
558  return 0;
559  }
560  GNUNET_memcpy (buf, &data[offset], max);
561  return max;
562 }
uint32_t data
The data value.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.

References buf, data, GNUNET_free, GNUNET_memcpy, and max.

Referenced by deserialize_fi_node(), and GNUNET_FS_file_information_create_from_data().

Here is the caller graph for this function:

◆ GNUNET_FS_search_probe_progress_()

void* GNUNET_FS_search_probe_progress_ ( void *  cls,
const struct GNUNET_FS_ProgressInfo info 
)

Notification of FS that a search probe has made progress.

This function is used INSTEAD of the client's event handler for downloads where the GNUNET_FS_DOWNLOAD_IS_PROBE flag is set.

Parameters
clsclosure, always NULL (!), actual closure is in the client-context of the info struct
infodetails about the event, specifying the event type and various bits about the event
Returns
client-context (for the next progress call for this operation; should be set to NULL for SUSPEND and STOPPED events). The value returned will be passed to future callbacks in the respective field in the struct GNUNET_FS_ProgressInfo.

Definition at line 281 of file fs_search.c.

283 {
284  struct GNUNET_FS_SearchResult *sr = info->value.download.cctx;
285  struct GNUNET_TIME_Relative dur;
286 
287  switch (info->status)
288  {
290  /* ignore */
291  break;
293  /* probes should never be resumed */
294  GNUNET_assert (0);
295  break;
297  /* probes should never be suspended */
298  GNUNET_break (0);
299  break;
301  /* ignore */
302  break;
304  if (NULL != sr->probe_cancel_task)
305  {
307  sr->probe_cancel_task = NULL;
308  }
309  sr->probe_cancel_task =
311  &probe_failure_handler, sr);
312  break;
314  if (NULL != sr->probe_cancel_task)
315  {
317  sr->probe_cancel_task = NULL;
318  }
319  sr->probe_cancel_task =
321  break;
323  if (NULL != sr->probe_cancel_task)
324  {
326  sr->probe_cancel_task = NULL;
327  }
328  sr = NULL;
329  break;
331  if (NULL == sr->probe_cancel_task)
332  {
334  sr->probe_cancel_task =
336  &probe_failure_handler, sr);
337  }
338  break;
340  if (NULL != sr->probe_cancel_task)
341  {
343  sr->probe_cancel_task = NULL;
344  }
348  if (0 == sr->remaining_probe_time.rel_value_us)
349  sr->probe_cancel_task =
352  break;
353 
354  default:
355  GNUNET_break (0);
356  return NULL;
357  }
358  return sr;
359 }
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2149
static void probe_success_handler(void *cls)
Handle the case where we have gotten a response for our probe.
Definition: fs_search.c:246
static void probe_failure_handler(void *cls)
Handle the case where we have failed to receive a response for our probe.
Definition: fs_search.c:222
#define info
@ GNUNET_FS_STATUS_DOWNLOAD_INACTIVE
Notification that this download is no longer actively being pursued (back in the queue).
@ GNUNET_FS_STATUS_DOWNLOAD_ERROR
Notification that this download encountered an error.
@ GNUNET_FS_STATUS_DOWNLOAD_COMPLETED
Notification that this download completed.
@ GNUNET_FS_STATUS_DOWNLOAD_RESUME
Notification that this download is being resumed.
@ GNUNET_FS_STATUS_DOWNLOAD_SUSPEND
Notification that this download was suspended.
@ GNUNET_FS_STATUS_DOWNLOAD_START
Notification that we have started this download.
@ GNUNET_FS_STATUS_DOWNLOAD_PROGRESS
Notification about progress with this download.
@ GNUNET_FS_STATUS_DOWNLOAD_ACTIVE
Notification that this download is now actively being pursued (as opposed to waiting in the queue).
@ GNUNET_FS_STATUS_DOWNLOAD_STOPPED
Notification that this download was stopped (final event with respect to this action).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1241
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:436
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition: time.c:603
Information we store for each search result.
Definition: fs_api.h:499
struct GNUNET_TIME_Absolute probe_active_time
When did the current probe become active?
Definition: fs_api.h:579
struct GNUNET_TIME_Relative remaining_probe_time
How much longer should we run the current probe before giving up?
Definition: fs_api.h:584
struct GNUNET_SCHEDULER_Task * probe_cancel_task
ID of the task that will clean up the probe_ctx should it not complete on time (and that will need to...
Definition: fs_api.h:574
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.

References GNUNET_assert, GNUNET_break, GNUNET_FS_search_result_sync_(), GNUNET_FS_STATUS_DOWNLOAD_ACTIVE, GNUNET_FS_STATUS_DOWNLOAD_COMPLETED, GNUNET_FS_STATUS_DOWNLOAD_ERROR, GNUNET_FS_STATUS_DOWNLOAD_INACTIVE, GNUNET_FS_STATUS_DOWNLOAD_PROGRESS, GNUNET_FS_STATUS_DOWNLOAD_RESUME, GNUNET_FS_STATUS_DOWNLOAD_START, GNUNET_FS_STATUS_DOWNLOAD_STOPPED, GNUNET_FS_STATUS_DOWNLOAD_SUSPEND, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_subtract(), info, GNUNET_FS_SearchResult::probe_active_time, GNUNET_FS_SearchResult::probe_cancel_task, probe_failure_handler(), probe_success_handler(), GNUNET_TIME_Relative::rel_value_us, and GNUNET_FS_SearchResult::remaining_probe_time.

Referenced by GNUNET_FS_download_make_status_().

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

◆ GNUNET_FS_publish_main_()

void GNUNET_FS_publish_main_ ( void *  cls)

Main function that performs the upload.

Parameters
clsstruct GNUNET_FS_PublishContext identifies the upload
clsstruct GNUNET_FS_PublishContext * identifies the upload

Definition at line 1063 of file fs_publish.c.

1064 {
1065  struct GNUNET_FS_PublishContext *pc = cls;
1066  struct GNUNET_FS_ProgressInfo pi;
1067  struct GNUNET_FS_FileInformation *p;
1068  char *fn;
1069 
1070  pc->upload_task = NULL;
1071  p = pc->fi_pos;
1072  if (NULL == p)
1073  {
1075  "Publishing complete, now publishing SKS and KSK blocks.\n");
1076  /* upload of entire hierarchy complete,
1077  * publish namespace entries */
1079  publish_sblock (pc);
1080  return;
1081  }
1082  /* find starting position */
1083  while ((GNUNET_YES == p->is_directory) &&
1084  (NULL != p->data.dir.entries) &&
1085  (NULL == p->emsg) &&
1086  (NULL == p->data.dir.entries->chk_uri))
1087  {
1088  p = p->data.dir.entries;
1089  pc->fi_pos = p;
1091  }
1092  /* abort on error */
1093  if (NULL != p->emsg)
1094  {
1096  "Error uploading: %s\n",
1097  p->emsg);
1098  /* error with current file, abort all
1099  * related files as well! */
1100  while (NULL != p->dir)
1101  {
1102  fn = GNUNET_FS_meta_data_get_by_type (p->meta,
1104  p = p->dir;
1105  if (fn != NULL)
1106  {
1107  GNUNET_asprintf (&p->emsg,
1108  _ ("Recursive upload failed at `%s': %s"),
1109  fn,
1110  p->emsg);
1111  GNUNET_free (fn);
1112  }
1113  else
1114  {
1115  GNUNET_asprintf (&p->emsg,
1116  _ ("Recursive upload failed: %s"),
1117  p->emsg);
1118  }
1120  pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
1121  pi.value.publish.specifics.error.message = p->emsg;
1122  p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
1123  }
1124  pc->all_done = GNUNET_YES;
1126  return;
1127  }
1128  /* handle completion */
1129  if (NULL != p->chk_uri)
1130  {
1132  "File upload complete, now publishing KSK blocks.\n");
1134 
1135  if ((0 == p->bo.anonymity_level) &&
1136  (GNUNET_YES !=
1137  GNUNET_FS_uri_test_loc (p->chk_uri)))
1138  {
1139  /* zero anonymity, box CHK URI in LOC URI */
1140  create_loc_uri (pc);
1141  }
1142  else
1143  {
1144  publish_kblocks (pc);
1145  }
1146  return;
1147  }
1148  if ((GNUNET_YES != p->is_directory) && (p->data.file.do_index))
1149  {
1150  if (NULL == p->filename)
1151  {
1152  p->data.file.do_index = GNUNET_NO;
1154  _ (
1155  "Can not index file `%s': %s. Will try to insert instead.\n"),
1156  "<no-name>",
1157  _ ("needs to be an actual file"));
1159  publish_content (pc);
1160  return;
1161  }
1162  if (p->data.file.have_hash)
1163  {
1164  hash_for_index_cb (pc, &p->data.file.file_id);
1165  }
1166  else
1167  {
1168  p->start_time = GNUNET_TIME_absolute_get ();
1169  pc->fhc =
1172  }
1173  return;
1174  }
1175  publish_content (pc);
1176 }
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:48
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.
Definition: fs_api.c:1328
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1747
static void publish_content(struct GNUNET_FS_PublishContext *pc)
We are uploading a file or directory; load (if necessary) the next block into memory,...
Definition: fs_publish.c:616
static void create_loc_uri(struct GNUNET_FS_PublishContext *pc)
We're publishing without anonymity.
Definition: fs_publish.c:1017
static void publish_sblock(struct GNUNET_FS_PublishContext *pc)
We are almost done publishing the structure, add SBlocks (if needed).
Definition: fs_publish.c:286
static void publish_kblocks(struct GNUNET_FS_PublishContext *pc)
We've computed the CHK/LOC URI, now publish the KSKs (if applicable).
Definition: fs_publish.c:934
static void hash_for_index_cb(void *cls, const struct GNUNET_HashCode *res)
Function called once the hash computation over an indexed file has completed.
Definition: fs_publish.c:806
void * GNUNET_FS_publish_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_PublishContext *pc, const struct GNUNET_FS_FileInformation *p, uint64_t offset)
Fill in all of the generic fields for a publish event and call the callback.
Definition: fs_publish.c:48
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
int GNUNET_FS_uri_test_loc(const struct GNUNET_FS_Uri *uri)
Is this a location URI?
Definition: fs_uri.c:1384
@ GNUNET_FS_STATUS_PUBLISH_ERROR
Notification that an error was encountered sharing a file structure.
struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
Compute the hash of an entire file.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_WARNING
char * GNUNET_FS_meta_data_get_by_type(const struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
Definition: meta_data.c:442
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
Information for a file or directory that is about to be published.
Definition: fs_api.h:228
Argument given to the progress callback with information about what is going on.
Handle for controlling a publication process.
Definition: fs_api.h:1180
struct GNUNET_CRYPTO_FileHashContext * fhc
Non-null if we are currently hashing a file.
Definition: fs_api.h:1231
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1226
int all_done
Set to GNUNET_YES if all processing has completed.
Definition: fs_api.h:1292
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1259

References _, GNUNET_FS_PublishContext::all_done, create_loc_uri(), EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, GNUNET_FS_PublishContext::fhc, GNUNET_FS_PublishContext::fi_pos, GNUNET_asprintf(), GNUNET_CRYPTO_hash_file(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_file_information_sync_(), GNUNET_FS_meta_data_get_by_type(), GNUNET_FS_publish_make_status_(), GNUNET_FS_publish_sync_(), GNUNET_FS_STATUS_PUBLISH_ERROR, GNUNET_FS_uri_test_loc(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, hash_for_index_cb(), HASHING_BLOCKSIZE, p, pc, pi, publish_content(), publish_kblocks(), publish_sblock(), and GNUNET_FS_PublishContext::upload_task.

Referenced by block_proc(), deserialize_publish_file(), ds_put_cont(), encode_cont(), finish_reserve(), GNUNET_FS_publish_start(), and publish_kblocks_cont().

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

◆ GNUNET_FS_unindex_process_hash_()

void GNUNET_FS_unindex_process_hash_ ( void *  cls,
const struct GNUNET_HashCode file_id 
)

Function called once the hash of the file that is being unindexed has been computed.

Parameters
clsclosure, unindex context
file_idcomputed hash, NULL on error

Definition at line 695 of file fs_unindex.c.

697 {
698  struct GNUNET_FS_UnindexContext *uc = cls;
699 
700  uc->fhc = NULL;
702  {
704  return;
705  }
706  if (file_id == NULL)
707  {
709  uc->emsg = GNUNET_strdup (_ ("Failed to compute hash of file."));
712  return;
713  }
714  uc->file_id = *file_id;
718 }
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1823
void GNUNET_FS_unindex_do_remove_(struct GNUNET_FS_UnindexContext *uc)
Connect to the datastore and remove the blocks.
Definition: fs_unindex.c:650
static void signal_unindex_error(struct GNUNET_FS_UnindexContext *uc)
We've encountered an error during unindexing.
Definition: fs_unindex.c:139
static struct GNUNET_FS_UnindexContext * uc
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:838
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle for controlling an unindexing operation.
Definition: fs_api.h:1351
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1464
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1439
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1444
struct GNUNET_HashCode file_id
Hash of the file's contents (once computed).
Definition: fs_api.h:1459

References _, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_id, GNUNET_FS_unindex_do_remove_(), GNUNET_FS_unindex_stop(), GNUNET_FS_unindex_sync_(), GNUNET_strdup, signal_unindex_error(), GNUNET_FS_UnindexContext::state, uc, UNINDEX_STATE_DS_REMOVE, UNINDEX_STATE_ERROR, and UNINDEX_STATE_HASHING.

Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_start().

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

◆ GNUNET_FS_unindex_do_extract_keywords_()

void GNUNET_FS_unindex_do_extract_keywords_ ( struct GNUNET_FS_UnindexContext uc)

Extract the keywords for KBlock removal.

Parameters
uccontext for the unindex operation.

Extract the keywords for KBlock removal.

Parameters
uccontext for the unindex operation.

Definition at line 407 of file fs_unindex.c.

408 {
409  char *ex;
410 
411  if (GNUNET_OK !=
412  GNUNET_CONFIGURATION_get_value_string (uc->h->cfg, "FS", "EXTRACTORS",
413  &ex))
414  ex = NULL;
416  GNUNET_NO, ex,
418  uc);
419  GNUNET_free (ex);
420 }
static void unindex_directory_scan_cb(void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason)
Function called by the directory scanner as we extract keywords that we will need to remove UBlocks.
Definition: fs_unindex.c:355
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
struct GNUNET_FS_DirScanner * GNUNET_FS_directory_scan_start(const char *filename, int disable_extractor, const char *ex, GNUNET_FS_DirScannerProgressCallback cb, void *cb_cls)
Start a directory scanner thread.
@ GNUNET_OK
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1074
struct GNUNET_FS_DirScanner * dscan
Directory scanner to find keywords (KBlock removal).
Definition: fs_api.h:1371
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1386
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1361

References GNUNET_FS_Handle::cfg, GNUNET_FS_UnindexContext::dscan, GNUNET_FS_UnindexContext::filename, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_FS_directory_scan_start(), GNUNET_NO, GNUNET_OK, GNUNET_FS_UnindexContext::h, uc, and unindex_directory_scan_cb().

Referenced by deserialize_unindex_file(), and unindex_extract_keywords().

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

◆ GNUNET_FS_unindex_do_remove_kblocks_()

void GNUNET_FS_unindex_do_remove_kblocks_ ( struct GNUNET_FS_UnindexContext uc)

If necessary, connect to the datastore and remove the KBlocks.

Parameters
uccontext for the unindex operation.

Definition at line 581 of file fs_unindex.c.

582 {
583  const char *keyword;
584  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
585  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
586  struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
587 
588  if (NULL == uc->dsh)
590  if (NULL == uc->dsh)
591  {
593  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
596  return;
597  }
598  if ((NULL == uc->ksk_uri) ||
599  (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount))
600  {
601  unindex_finish (uc);
602  return;
603  }
606  &anon_pub);
607  keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
609  keyword,
610  "fs-ublock",
611  &dpub);
612  GNUNET_CRYPTO_hash (&dpub,
613  sizeof(dpub),
614  &uc->uquery);
616  0 /* next_uid */,
617  false /* random */,
618  &uc->uquery,
620  0 /* priority */,
621  1 /* queue size */,
623  uc);
624 }
@ GNUNET_BLOCK_TYPE_FS_UBLOCK
Type of a block representing any type of search result (universal).
static void unindex_finish(struct GNUNET_FS_UnindexContext *uc)
Function called when we are done with removing UBlocks.
Definition: fs_unindex.c:290
static void process_kblock_for_unindex(void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
Function called from datastore with result from us looking for a UBlock.
Definition: fs_unindex.c:477
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:481
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:186
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_key(struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
Get a result for a particular key from the datastore.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_DATASTORE_QueueEntry * dqe
Handle to datastore 'get_key' operation issued for obtaining KBlocks.
Definition: fs_api.h:1424
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase.
Definition: fs_api.h:1403
uint32_t ksk_offset
Current offset in KSK removal.
Definition: fs_api.h:1381
struct GNUNET_HashCode uquery
Current query of 'get_key' operation.
Definition: fs_api.h:1434
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1376
struct GNUNET_FS_Uri::@13::@14 ksk
union GNUNET_FS_Uri::@13 data

References _, GNUNET_FS_Handle::cfg, GNUNET_FS_Uri::data, GNUNET_FS_UnindexContext::dqe, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_DATASTORE_connect(), GNUNET_DATASTORE_get_key(), GNUNET_FS_unindex_sync_(), GNUNET_strdup, GNUNET_FS_UnindexContext::h, GNUNET_FS_Uri::ksk, GNUNET_FS_UnindexContext::ksk_offset, GNUNET_FS_UnindexContext::ksk_uri, process_kblock_for_unindex(), signal_unindex_error(), GNUNET_FS_UnindexContext::state, uc, unindex_finish(), UNINDEX_STATE_ERROR, and GNUNET_FS_UnindexContext::uquery.

Referenced by continue_after_remove(), deserialize_unindex_file(), process_kblock_for_unindex(), and unindex_directory_scan_cb().

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

◆ GNUNET_FS_publish_make_status_()

void* GNUNET_FS_publish_make_status_ ( struct GNUNET_FS_ProgressInfo pi,
struct GNUNET_FS_PublishContext pc,
const struct GNUNET_FS_FileInformation p,
uint64_t  offset 
)

Fill in all of the generic fields for a publish event and call the callback.

Parameters
pistructure to fill in
pcoverall publishing context
pfile information for the file being published
offsetwhere in the file are we so far
Returns
value returned from callback

Definition at line 48 of file fs_publish.c.

52 {
53  pi->value.publish.pc = pc;
54  pi->value.publish.fi = p;
55  pi->value.publish.cctx = p->client_info;
56  pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info;
57  pi->value.publish.filename = p->filename;
58  pi->value.publish.size =
59  (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size :
60  p->data.file.file_size;
61  pi->value.publish.eta =
62  GNUNET_TIME_calculate_eta (p->start_time, offset,
63  pi->value.publish.size);
64  pi->value.publish.completed = offset;
65  pi->value.publish.duration =
67  pi->value.publish.anonymity = p->bo.anonymity_level;
68  pi->fsh = pc->h;
69  return pc->h->upcb (pc->h->upcb_cls, pi);
70 }
struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta(struct GNUNET_TIME_Absolute start, uint64_t finished, uint64_t total)
Calculate the estimate time of arrival/completion for an operation.
Definition: time.c:564
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1089
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1084
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1184

References GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_calculate_eta(), GNUNET_YES, GNUNET_FS_PublishContext::h, p, pc, pi, GNUNET_FS_Handle::upcb, and GNUNET_FS_Handle::upcb_cls.

Referenced by ds_put_cont(), encode_cont(), fip_signal_resume(), fip_signal_start(), fip_signal_stop(), GNUNET_FS_publish_main_(), GNUNET_FS_publish_stop(), progress_proc(), signal_publish_completion(), signal_publish_error(), and suspend_operation().

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

◆ GNUNET_FS_download_make_status_()

void GNUNET_FS_download_make_status_ ( struct GNUNET_FS_ProgressInfo pi,
struct GNUNET_FS_DownloadContext dc 
)

Fill in all of the generic fields for a download event and call the callback.

Parameters
pistructure to fill in
dcoverall download context

Definition at line 104 of file fs_download.c.

106 {
107  pi->value.download.dc = dc;
108  pi->value.download.cctx = dc->client_info;
109  pi->value.download.pctx =
110  (NULL == dc->parent) ? NULL : dc->parent->client_info;
111  pi->value.download.sctx =
112  (NULL == dc->search) ? NULL : dc->search->client_info;
113  pi->value.download.uri = dc->uri;
114  pi->value.download.filename = dc->filename;
115  pi->value.download.size = dc->length;
116  /* FIXME: Fix duration calculation to account for pauses */
117  pi->value.download.duration =
119  pi->value.download.completed = dc->completed;
120  pi->value.download.anonymity = dc->anonymity;
121  pi->value.download.eta =
123  pi->value.download.is_active = (NULL == dc->mq) ? GNUNET_NO : GNUNET_YES;
124  pi->fsh = dc->h;
125  if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
126  dc->client_info = dc->h->upcb (dc->h->upcb_cls, pi);
127  else
129 }
void * GNUNET_FS_search_probe_progress_(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Notification of FS that a search probe has made progress.
Definition: fs_search.c:281
static struct GNUNET_FS_DownloadContext * dc
@ GNUNET_FS_DOWNLOAD_IS_PROBE
Internal option used to flag this download as a 'probe' for a search result.
char * filename
Where are we writing the data (name of the file, can be NULL!).
Definition: fs_api.h:1822
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
Definition: fs_api.h:1800
void * client_info
Context kept for the client.
Definition: fs_api.h:1795
uint64_t completed
How many bytes have we already received within the specified range (DBlocks only).
Definition: fs_api.h:1890
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none.
Definition: fs_api.h:1770
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file!
Definition: fs_api.h:1884
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1758
uint32_t anonymity
Desired level of anonymity.
Definition: fs_api.h:1913
struct GNUNET_FS_DownloadContext * parent
Parent download (used when downloading files in directories).
Definition: fs_api.h:1764
enum GNUNET_FS_DownloadOptions options
Options for the download.
Definition: fs_api.h:1923
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1748
struct GNUNET_TIME_Absolute start_time
Time download was started.
Definition: fs_api.h:1903
void * client_info
Client info for this search result.
Definition: fs_api.h:534

References GNUNET_FS_DownloadContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_DownloadContext::client_info, GNUNET_FS_DownloadContext::completed, dc, GNUNET_FS_DownloadContext::filename, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_search_probe_progress_(), GNUNET_NO, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_calculate_eta(), GNUNET_YES, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::length, GNUNET_FS_DownloadContext::mq, GNUNET_FS_DownloadContext::options, GNUNET_FS_DownloadContext::parent, pi, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::start_time, GNUNET_FS_Handle::upcb, GNUNET_FS_Handle::upcb_cls, and GNUNET_FS_DownloadContext::uri.

Referenced by activate_fs_download(), check_completed(), deactivate_fs_download(), GNUNET_FS_download_resume(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_start_task_(), process_result_with_request(), reconstruct_cb(), search_result_stop(), signal_download_resume(), and try_match_block().

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

◆ GNUNET_FS_download_start_task_()

void GNUNET_FS_download_start_task_ ( void *  cls)

Task that creates the initial (top-level) download request for the file.

Parameters
clsthe 'struct GNUNET_FS_DownloadContext'

Definition at line 1800 of file fs_download.c.

1801 {
1802  struct GNUNET_FS_DownloadContext *dc = cls;
1803  struct GNUNET_FS_ProgressInfo pi;
1804  struct GNUNET_DISK_FileHandle *fh;
1805 
1806  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start task running...\n");
1807  dc->task = NULL;
1808  if (0 == dc->length)
1809  {
1810  /* no bytes required! */
1811  if (NULL != dc->filename)
1812  {
1816  | ((0 ==
1819  : 0),
1825  }
1828  pi.value.download.specifics.start.meta = dc->meta;
1830  check_completed (dc);
1831  return;
1832  }
1833  if (NULL != dc->emsg)
1834  return;
1835  if (NULL == dc->top_request)
1836  {
1838  0,
1839  dc->treedepth - 1,
1840  0,
1841  dc->offset,
1842  dc->length);
1845  ? dc->uri->data.chk.chk
1846  : dc->uri->data.loc.fi.chk;
1847  /* signal start */
1849  if (NULL != dc->search)
1852  pi.value.download.specifics.start.meta = dc->meta;
1854  }
1856  /* attempt reconstruction from disk */
1861  if (dc->top_request->state == BRS_CHK_SET)
1862  {
1863  if (NULL != dc->rfh)
1864  {
1865  /* first, try top-down */
1867  "Trying top-down reconstruction for `%s'\n",
1868  dc->filename);
1870  switch (dc->top_request->state)
1871  {
1872  case BRS_CHK_SET:
1873  break; /* normal */
1874 
1875  case BRS_DOWNLOAD_DOWN:
1876  break; /* normal, some blocks already down */
1877 
1878  case BRS_DOWNLOAD_UP:
1879  /* already done entirely, party! */
1880  if (NULL != dc->rfh)
1881  {
1882  /* avoid hanging on to file handle longer than
1883  * necessary */
1885  dc->rfh = NULL;
1886  }
1887  return;
1888 
1889  case BRS_ERROR:
1890  GNUNET_asprintf (&dc->emsg, _ ("Invalid URI"));
1893  pi.value.download.specifics.error.message = dc->emsg;
1895  return;
1896 
1897  default:
1898  GNUNET_assert (0);
1899  break;
1900  }
1901  }
1902  }
1903  /* attempt reconstruction from meta data */
1905  (NULL != dc->meta))
1906  {
1907  GNUNET_log (
1909  "Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
1910  (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
1911  (unsigned int) GNUNET_FS_meta_data_get_serialized_size (dc->meta));
1914  {
1915  if (NULL != dc->rfh)
1916  {
1917  /* avoid hanging on to file handle longer than
1918  * necessary */
1920  dc->rfh = NULL;
1921  }
1922  return; /* finished, status update was already done for us */
1923  }
1924  }
1925  if (NULL != dc->rfh)
1926  {
1927  /* finally, actually run bottom-up */
1929  "Trying bottom-up reconstruction of file `%s'\n",
1930  dc->filename);
1931  dc->te =
1934  dc,
1935  &fh_reader,
1936  &reconstruct_cb,
1937  NULL,
1938  &reconstruct_cont);
1940  }
1941  else
1942  {
1943  /* simple, top-level download */
1946  }
1948  check_completed (dc);
1949 }
void GNUNET_FS_download_sync_(struct GNUNET_FS_DownloadContext *dc)
Synchronize this download struct with its mirror on disk.
Definition: fs_api.c:2036
#define MAX_INLINE_SIZE
Maximum size for a file to be considered for inlining in a directory.
Definition: fs_api.h:50
static void reconstruct_cb(void *cls, const struct ContentHashKey *chk, uint64_t offset, unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size)
Function called asking for the current (encoded) block to be processed.
Definition: fs_download.c:1616
static void check_completed(struct GNUNET_FS_DownloadContext *dc)
Check if all child-downloads have completed (or trigger them if necessary) and once we're completely ...
Definition: fs_download.c:376
static size_t fh_reader(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the ...
Definition: fs_download.c:1768
static void try_top_down_reconstruction(struct GNUNET_FS_DownloadContext *dc, struct DownloadRequest *dr)
Try top-down reconstruction.
Definition: fs_download.c:663
static int match_full_data(void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len)
Type of a function that libextractor calls for each meta data item found.
Definition: fs_download.c:602
void GNUNET_FS_download_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_DownloadContext *dc)
Fill in all of the generic fields for a download event and call the callback.
Definition: fs_download.c:104
static void reconstruct_cont(void *cls)
Continuation after a possible attempt to reconstruct the current IBlock from the existing file.
Definition: fs_download.c:1561
static struct DownloadRequest * create_download_request(struct DownloadRequest *parent, unsigned int chk_idx, unsigned int depth, uint64_t dr_offset, uint64_t file_start_offset, uint64_t desired_length)
(recursively) Create a download request structure.
Definition: fs_download.c:1485
void GNUNET_FS_download_start_downloading_(struct GNUNET_FS_DownloadContext *dc)
Start the downloading process (by entering the queue).
Definition: fs_download.c:2184
static void get_next_block(void *cls)
Task requesting the next block from the tree encoder.
Definition: fs_download.c:1589
static void schedule_block_download(struct GNUNET_FS_DownloadContext *dc, struct DownloadRequest *dr)
Schedule the download of the specified block in the tree.
Definition: fs_download.c:778
struct GNUNET_FS_TreeEncoder * GNUNET_FS_tree_encoder_create(struct GNUNET_FS_Handle *h, uint64_t size, void *cls, GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_TaskCallback cont)
Initialize a tree encoder.
Definition: fs_tree.c:258
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
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).
Definition: disk.c:481
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
Definition: fs_uri.c:1360
int GNUNET_FS_meta_data_iterate(const struct GNUNET_FS_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
Definition: meta_data.c:422
ssize_t GNUNET_FS_meta_data_get_serialized_size(const struct GNUNET_FS_MetaData *md)
Get the size of the full meta-data in serialized form.
Definition: meta_data.c:862
enum BlockRequestState state
State in the FSM.
Definition: fs_api.h:1718
struct ContentHashKey chk
CHK for the request for this block (set during reconstruction to what we have on disk,...
Definition: fs_api.h:1691
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:104
Handle used to access files (and pipes).
Context for controlling a download.
Definition: fs_api.h:1744
unsigned int treedepth
The depth of the file-tree.
Definition: fs_api.h:1918
struct GNUNET_DISK_FileHandle * rfh
File handle for reading data from an existing file (to pass to tree encoder).
Definition: fs_api.h:1845
struct GNUNET_FS_MetaData * meta
Known meta-data for the file (can be NULL).
Definition: fs_api.h:1805
int issue_requests
Are we ready to issue requests (reconstructions are finished)?
Definition: fs_api.h:1935
uint64_t offset
What is the first offset that we're interested in?
Definition: fs_api.h:1878
char * emsg
Error message, NULL if we're doing OK.
Definition: fs_api.h:1810
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the download is being stopped ...
Definition: fs_api.h:1872
struct GNUNET_FS_TreeEncoder * te
Tree encoder used for the reconstruction.
Definition: fs_api.h:1839
struct DownloadRequest * top_request
Top-level download request.
Definition: fs_api.h:1856
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:171
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content.
Definition: fs_api.h:218
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:212
struct FileIdentifier fi
Information about the shared file.
Definition: fs_api.h:117

References _, BRS_CHK_SET, BRS_DOWNLOAD_DOWN, BRS_DOWNLOAD_UP, BRS_ERROR, check_completed(), GNUNET_FS_Uri::chk, FileIdentifier::chk, DownloadRequest::chk, create_download_request(), GNUNET_FS_Uri::data, dc, GNUNET_FS_DownloadContext::emsg, fh, fh_reader(), Location::fi, GNUNET_FS_DownloadContext::filename, get_next_block(), GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READ, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_NONE, GNUNET_DISK_PERM_OTHER_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_download_make_status_(), GNUNET_FS_download_start_downloading_(), GNUNET_FS_download_sync_(), GNUNET_FS_meta_data_get_serialized_size(), GNUNET_FS_meta_data_iterate(), GNUNET_FS_search_result_sync_(), GNUNET_FS_STATUS_DOWNLOAD_ERROR, GNUNET_FS_STATUS_DOWNLOAD_START, GNUNET_FS_tree_encoder_create(), GNUNET_FS_URI_CHK, GNUNET_FS_uri_chk_get_file_size(), GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_YES, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::issue_requests, GNUNET_FS_DownloadContext::length, GNUNET_FS_Uri::loc, match_full_data(), MAX_INLINE_SIZE, GNUNET_FS_DownloadContext::meta, GNUNET_FS_DownloadContext::offset, pi, reconstruct_cb(), reconstruct_cont(), GNUNET_FS_DownloadContext::rfh, schedule_block_download(), GNUNET_FS_DownloadContext::search, DownloadRequest::state, GNUNET_FS_DownloadContext::task, GNUNET_FS_DownloadContext::te, GNUNET_FS_DownloadContext::top_request, GNUNET_FS_DownloadContext::treedepth, try_top_down_reconstruction(), GNUNET_FS_Uri::type, and GNUNET_FS_DownloadContext::uri.

Referenced by create_download_context(), and deserialize_download().

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

◆ GNUNET_FS_unindex_make_status_()

void GNUNET_FS_unindex_make_status_ ( struct GNUNET_FS_ProgressInfo pi,
struct GNUNET_FS_UnindexContext uc,
uint64_t  offset 
)

Fill in all of the generic fields for an unindex event and call the callback.

Parameters
pistructure to fill in
ucoverall unindex context
offsetwhere we are in the file (for progress)

Definition at line 85 of file fs_unindex.c.

88 {
89  pi->value.unindex.uc = uc;
90  pi->value.unindex.cctx = uc->client_info;
91  pi->value.unindex.filename = uc->filename;
92  pi->value.unindex.size = uc->file_size;
93  pi->value.unindex.eta =
95  pi->value.unindex.duration =
97  pi->value.unindex.completed = offset;
98  pi->fsh = uc->h;
99  uc->client_info = uc->h->upcb (uc->h->upcb_cls, pi);
100 }
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1408
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1454
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1449

References GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_calculate_eta(), GNUNET_FS_UnindexContext::h, pi, GNUNET_FS_UnindexContext::start_time, uc, GNUNET_FS_Handle::upcb, and GNUNET_FS_Handle::upcb_cls.

Referenced by deserialize_unindex_file(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_start(), GNUNET_FS_unindex_stop(), handle_unindex_response(), signal_unindex_error(), and unindex_progress().

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

◆ GNUNET_FS_search_make_status_()

void* GNUNET_FS_search_make_status_ ( struct GNUNET_FS_ProgressInfo pi,
struct GNUNET_FS_Handle h,
struct GNUNET_FS_SearchContext sc 
)

Fill in all of the generic fields for a search event and call the callback.

Parameters
pistructure to fill in
hfile-sharing handle
scoverall search context
Returns
value returned by the callback

Definition at line 49 of file fs_search.c.

52 {
53  void *ret;
54 
55  pi->value.search.sc = sc;
56  pi->value.search.cctx = (NULL != sc) ? sc->client_info : NULL;
57  pi->value.search.pctx =
58  ((NULL == sc) || (NULL == sc->psearch_result))
59  ? NULL
61  pi->value.search.query = (NULL != sc) ? sc->uri : NULL;
62  pi->value.search.duration = (NULL != sc)
64  sc->start_time)
66  pi->value.search.anonymity = (NULL != sc) ? sc->anonymity : 0;
67  pi->fsh = h;
68  ret = h->upcb (h->upcb_cls, pi);
69  return ret;
70 }
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
void * client_info
Pointer we keep for the client.
Definition: fs_api.h:1541
struct GNUNET_FS_SearchResult * psearch_result
For update-searches, link to the search result that triggered the update search; otherwise NULL.
Definition: fs_api.h:1531
uint32_t anonymity
Anonymity level for the search.
Definition: fs_api.h:1588
struct GNUNET_FS_Uri * uri
List of keywords that we're looking for.
Definition: fs_api.h:1525
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1570

References GNUNET_FS_SearchContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchContext::client_info, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_ZERO, h, pi, GNUNET_FS_SearchContext::psearch_result, ret, sc, GNUNET_FS_SearchContext::start_time, and GNUNET_FS_SearchContext::uri.

Referenced by GNUNET_FS_search_continue(), GNUNET_FS_search_pause(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop(), notify_client_chk_result(), notify_client_chk_update(), search_result_stop(), search_result_suspend(), search_start(), signal_probe_result(), signal_result_resume(), and signal_search_resume().

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

◆ GNUNET_FS_unindex_do_remove_()

void GNUNET_FS_unindex_do_remove_ ( struct GNUNET_FS_UnindexContext uc)

Connect to the datastore and remove the blocks.

Parameters
uccontext for the unindex operation.

Definition at line 650 of file fs_unindex.c.

651 {
652  if (NULL == uc->dsh)
654  if (NULL == uc->dsh)
655  {
657  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
660  return;
661  }
662  uc->fh =
665  if (NULL == uc->fh)
666  {
668  uc->dsh = NULL;
670  uc->emsg = GNUNET_strdup (_ ("Failed to open file for unindexing."));
673  return;
674  }
675  uc->tc =
677  uc->file_size,
678  uc,
684 }
void GNUNET_FS_tree_encoder_next(struct GNUNET_FS_TreeEncoder *te)
Encrypt the next block of the file (and call proc and progress accordingly; or of course "cont" if we...
Definition: fs_tree.c:320
static void unindex_progress(void *cls, uint64_t offset, const void *pt_block, size_t pt_size, unsigned int depth)
Function called with information about our progress in computing the tree encoding.
Definition: fs_unindex.c:114
static size_t unindex_reader(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the ...
Definition: fs_unindex.c:52
static void unindex_process(void *cls, const struct ContentHashKey *chk, uint64_t offset, unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size)
Function called asking for the current (encoded) block to be processed.
Definition: fs_unindex.c:194
static void unindex_extract_keywords(void *cls)
Function called when the tree encoder has processed all blocks.
Definition: fs_unindex.c:634
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct GNUNET_FS_TreeEncoder * tc
Merkle-ish tree encoder context.
Definition: fs_api.h:1413
struct GNUNET_DISK_FileHandle * fh
Handle used to read the file.
Definition: fs_api.h:1418

References _, GNUNET_FS_Handle::cfg, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fh, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_DATASTORE_connect(), GNUNET_DATASTORE_disconnect(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_FS_tree_encoder_create(), GNUNET_FS_tree_encoder_next(), GNUNET_FS_unindex_sync_(), GNUNET_NO, GNUNET_strdup, GNUNET_FS_UnindexContext::h, signal_unindex_error(), GNUNET_FS_UnindexContext::state, GNUNET_FS_UnindexContext::tc, uc, unindex_extract_keywords(), unindex_process(), unindex_progress(), unindex_reader(), and UNINDEX_STATE_ERROR.

Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_process_hash_().

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

◆ GNUNET_FS_search_start_searching_()

int GNUNET_FS_search_start_searching_ ( struct GNUNET_FS_SearchContext sc)

Build the request and actually initiate the search using the GNUnet FS service.

Parameters
scsearch context
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 1402 of file fs_search.c.

1403 {
1404  unsigned int i;
1405  const char *keyword;
1406  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
1407  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
1408  struct SearchRequestEntry *sre;
1409 
1410  GNUNET_assert (NULL == sc->mq);
1411  if (GNUNET_FS_uri_test_ksk (sc->uri))
1412  {
1413  GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
1415  GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub);
1416  sc->requests
1417  = GNUNET_new_array (sc->uri->data.ksk.keywordCount,
1418  struct SearchRequestEntry);
1419 
1420  for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1421  {
1422  keyword = &sc->uri->data.ksk.keywords[i][1];
1423  sre = &sc->requests[i];
1424  sre->keyword = GNUNET_strdup (keyword);
1426  keyword,
1427  "fs-ublock",
1428  &sre->dpub);
1429  GNUNET_CRYPTO_hash (&sre->dpub,
1430  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
1431  &sre->uquery);
1432  sre->mandatory = (sc->uri->data.ksk.keywords[i][0] == '+');
1433  if (sre->mandatory)
1434  sc->mandatory_count++;
1436  }
1439  sc);
1440  }
1441  GNUNET_assert (NULL == sc->task);
1442  do_reconnect (sc);
1443  if (NULL == sc->mq)
1444  {
1446  sc->task = NULL;
1447  return GNUNET_SYSERR;
1448  }
1449  return GNUNET_OK;
1450 }
static int update_sre_result_maps(void *cls, const struct GNUNET_HashCode *key, void *value)
Update the 'results' map for the individual keywords with the results from the 'global' result set.
Definition: fs_search.c:1381
static void do_reconnect(void *cls)
Reconnect to the FS service and transmit our queries NOW.
Definition: fs_search.c:1272
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1324
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search.
Definition: fs_api.h:1559
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1565
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the search is being stopped (i...
Definition: fs_api.h:1583
uint32_t mandatory_count
Number of mandatory keywords in this query.
Definition: fs_api.h:1593
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1536
Information we keep for each keyword in a keyword search.
Definition: fs_api.h:1472
int mandatory
Is this keyword a mandatory keyword (started with '+')?
Definition: fs_api.h:1503
struct GNUNET_CONTAINER_MultiHashMap * results
Map that contains a "struct GNUNET_FS_SearchResult" for each result that was found under this keyword...
Definition: fs_api.h:1497
struct GNUNET_CRYPTO_EcdsaPublicKey dpub
Derived public key, hashes to 'uquery'.
Definition: fs_api.h:1481
char * keyword
The original keyword, used to derive the key (for decrypting the UBlock).
Definition: fs_api.h:1487
struct GNUNET_HashCode uquery
Hash of the public key, also known as the query.
Definition: fs_api.h:1476

References GNUNET_FS_Uri::data, do_reconnect(), SearchRequestEntry::dpub, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_FS_uri_test_ksk(), GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_strdup, GNUNET_SYSERR, SearchRequestEntry::keyword, GNUNET_FS_Uri::ksk, SearchRequestEntry::mandatory, GNUNET_FS_SearchContext::mandatory_count, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, GNUNET_FS_SearchContext::task, update_sre_result_maps(), SearchRequestEntry::uquery, and GNUNET_FS_SearchContext::uri.

Referenced by deserialize_search(), and search_start().

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

◆ GNUNET_FS_download_start_downloading_()

void GNUNET_FS_download_start_downloading_ ( struct GNUNET_FS_DownloadContext dc)

Start the downloading process (by entering the queue).

Parameters
dcour download context

Definition at line 2184 of file fs_download.c.

2185 {
2186  if (dc->completed == dc->length)
2187  return;
2188  if (NULL != dc->mq)
2189  return; /* already running */
2190  GNUNET_assert (NULL == dc->job_queue);
2191  GNUNET_assert (NULL == dc->task);
2192  GNUNET_assert (NULL != dc->active);
2193  dc->job_queue =
2194  GNUNET_FS_queue_ (dc->h,
2197  dc,
2198  (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE,
2203  "Download %p put into queue as job %p\n",
2204  dc,
2205  dc->job_queue);
2206 }
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:41
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.
Definition: fs_api.c:321
static void activate_fs_download(void *cls)
We're allowed to ask the FS service for our blocks.
Definition: fs_download.c:1428
static void deactivate_fs_download(void *cls)
We must stop to ask the FS service for our blocks.
Definition: fs_download.c:1449
struct GNUNET_FS_QueueEntry * job_queue
Our entry in the job queue.
Definition: fs_api.h:1834
struct GNUNET_CONTAINER_MultiHashMap * active
Map of active requests (those waiting for a response).
Definition: fs_api.h:1851

References activate_fs_download(), GNUNET_FS_DownloadContext::active, GNUNET_FS_DownloadContext::completed, DBLOCK_SIZE, dc, deactivate_fs_download(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_queue_(), GNUNET_FS_QUEUE_PRIORITY_NORMAL, GNUNET_FS_QUEUE_PRIORITY_PROBE, GNUNET_log, GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::job_queue, GNUNET_FS_DownloadContext::length, GNUNET_FS_DownloadContext::mq, GNUNET_FS_DownloadContext::options, and GNUNET_FS_DownloadContext::task.

Referenced by GNUNET_FS_download_start_task_().

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

◆ GNUNET_FS_search_start_probe_()

void GNUNET_FS_search_start_probe_ ( struct GNUNET_FS_SearchResult sr)

Start download probes for the given search result.

Parameters
srthe search result

Definition at line 431 of file fs_search.c.

432 {
433  uint64_t off;
434  uint64_t len;
435 
436  if (NULL != sr->probe_ctx)
437  return;
438  if (NULL != sr->download)
439  return;
440  if (0 == (sr->h->flags & GNUNET_FS_FLAGS_DO_PROBES))
441  return;
443  return;
444  if ( (GNUNET_FS_URI_CHK != sr->uri->type) &&
445  (GNUNET_FS_URI_LOC != sr->uri->type) )
446  return;
448  if (0 == len)
449  return;
450  if ((len <= DBLOCK_SIZE) && (sr->availability_success > 0))
451  return;
452  off = len / DBLOCK_SIZE;
453  if (off > 0)
455  off *= DBLOCK_SIZE;
456  if (len - off < DBLOCK_SIZE)
457  len = len - off;
458  else
459  len = DBLOCK_SIZE;
461  "Starting probe #%u (at offset %llu) for search result %p\n",
462  sr->availability_trials + 1,
463  (unsigned long long) off,
464  sr);
467  2 * (1
468  + sr->availability_trials));
469  sr->probe_ctx =
470  GNUNET_FS_download_start (sr->h, sr->uri, sr->meta, NULL, NULL, off,
471  len, sr->anonymity,
473  | GNUNET_FS_DOWNLOAD_IS_PROBE, sr, NULL);
475 }
#define AVAILABILITY_TRIALS_MAX
Number of availability trials we perform per search result.
Definition: fs_search.c:37
static void start_probe_ping_task(struct GNUNET_FS_SearchResult *sr)
Start the ping task for this search result.
Definition: fs_search.c:390
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx, struct GNUNET_FS_DownloadContext *parent)
Download parts of a file.
Definition: fs_download.c:2100
@ GNUNET_FS_FLAGS_DO_PROBES
Should we automatically trigger probes for search results to determine availability?...
@ GNUNET_FS_DOWNLOAD_NO_TEMPORARIES
Do not append temporary data to the target file (for the IBlocks).
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
Definition: time.c:531
enum GNUNET_FS_Flags flags
General flags.
Definition: fs_api.h:1162
struct GNUNET_TIME_Relative avg_block_latency
Average time we take for a single request to be satisfied.
Definition: fs_api.h:1147
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:546
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results' availability (NULL if we are not currently probin...
Definition: fs_api.h:540
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:613
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:524
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:503
uint32_t anonymity
Anonymity level to use for probes using this search result.
Definition: fs_api.h:589
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Definition: fs_api.h:607
struct GNUNET_FS_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:529

References GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, AVAILABILITY_TRIALS_MAX, GNUNET_FS_Handle::avg_block_latency, DBLOCK_SIZE, GNUNET_FS_SearchResult::download, GNUNET_FS_Handle::flags, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_DOWNLOAD_NO_TEMPORARIES, GNUNET_FS_download_start(), GNUNET_FS_FLAGS_DO_PROBES, GNUNET_FS_URI_CHK, GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_URI_LOC, GNUNET_log, GNUNET_TIME_relative_saturating_multiply(), GNUNET_FS_SearchResult::h, len, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_SearchResult::remaining_probe_time, start_probe_ping_task(), GNUNET_FS_Uri::type, and GNUNET_FS_SearchResult::uri.

Referenced by GNUNET_FS_probe(), process_ksk_result(), process_sks_result(), search_result_resume_probes(), signal_probe_result(), and signal_result_resume().

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

◆ GNUNET_FS_remove_sync_file_()

void GNUNET_FS_remove_sync_file_ ( struct GNUNET_FS_Handle h,
const char *  ext,
const char *  ent 
)

Remove serialization/deserialization file from disk.

Parameters
hmaster context
extcomponent of the path
ententity identifier

Definition at line 728 of file fs_api.c.

731 {
732  char *filename;
733 
734  if ((NULL == ent) || (0 == strlen (ent)))
735  {
736  GNUNET_break (0);
737  return;
738  }
739  filename = get_serialization_file_name (h, ext, ent);
740  if (NULL != filename)
741  {
742  if ((0 != unlink (filename)) && (ENOENT != errno))
745  }
746 }
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).
Definition: fs_api.c:575
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...

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_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().

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

◆ GNUNET_FS_remove_sync_dir_()

void GNUNET_FS_remove_sync_dir_ ( struct GNUNET_FS_Handle h,
const char *  ext,
const char *  uni 
)

Remove serialization/deserialization directory from disk.

Parameters
hmaster context
extcomponent of the path
uniunique name of parent

Definition at line 787 of file fs_api.c.

790 {
791  char *dn;
792 
793  if (NULL == uni)
794  return;
795  dn = get_serialization_file_name_in_dir (h, ext, uni, "");
796  if (NULL == dn)
797  return;
801  GNUNET_free (dn);
802 }
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) t...
Definition: fs_api.c:615
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1084
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition: disk.c:403

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(), and GNUNET_FS_search_stop().

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

◆ GNUNET_FS_file_information_sync_()

void GNUNET_FS_file_information_sync_ ( struct GNUNET_FS_FileInformation fi)

Synchronize this file-information struct with its mirror on disk.

Note that all internal FS-operations that change file information data should already call "sync" internally, so this function is likely not useful for clients.

Parameters
fithe struct to sync

Synchronize this file-information struct with its mirror on disk.

Parameters
fifile information to sync with disk

Definition at line 1328 of file fs_api.c.

1329 {
1330  char *fn;
1331  struct GNUNET_BIO_WriteHandle *wh;
1332  char b;
1333  char *ksks;
1334  char *chks;
1335  char *skss;
1336 
1337  if (NULL == fi->serialization)
1338  fi->serialization =
1340  if (NULL == fi->serialization)
1341  return;
1342  wh =
1344  if (NULL == wh)
1345  {
1346  GNUNET_free (fi->serialization);
1347  fi->serialization = NULL;
1348  return;
1349  }
1350  if (GNUNET_YES == fi->is_directory)
1351  b = 4;
1352  else if (GNUNET_YES == fi->data.file.index_start_confirmed)
1353  b = 3;
1354  else if (GNUNET_YES == fi->data.file.have_hash)
1355  b = 2;
1356  else if (GNUNET_YES == fi->data.file.do_index)
1357  b = 1;
1358  else
1359  b = 0;
1360  if (NULL != fi->keywords)
1361  ksks = GNUNET_FS_uri_to_string (fi->keywords);
1362  else
1363  ksks = NULL;
1364  if (NULL != fi->chk_uri)
1365  chks = GNUNET_FS_uri_to_string (fi->chk_uri);
1366  else
1367  chks = NULL;
1368  if (NULL != fi->sks_uri)
1369  skss = GNUNET_FS_uri_to_string (fi->sks_uri);
1370  else
1371  skss = NULL;
1372  struct GNUNET_BIO_WriteSpec ws1[] = {
1373  GNUNET_BIO_write_spec_object ("b", &b, sizeof (b)),
1374  GNUNET_FS_write_spec_meta_data ("meta", fi->meta),
1375  GNUNET_BIO_write_spec_string ("ksks", ksks),
1376  GNUNET_BIO_write_spec_string ("chks", chks),
1377  GNUNET_BIO_write_spec_string ("skss", skss),
1379  };
1380  struct GNUNET_BIO_WriteSpec ws2[] = {
1381  GNUNET_BIO_write_spec_string ("emsg", fi->emsg),
1382  GNUNET_BIO_write_spec_string ("filename", fi->filename),
1384  "expiration time",
1385  (int64_t *) &fi->bo.expiration_time.abs_value_us),
1387  "anonymity level",
1388  (int32_t *) &fi->bo.anonymity_level),
1390  "content priority",
1391  (int32_t *) &fi->bo.content_priority),
1393  "replication level",
1394  (int32_t *) &fi->bo.replication_level),
1396  };
1397  if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws1)) ||
1398  (GNUNET_OK != write_start_time (wh, fi->start_time)) ||
1400  {
1401  GNUNET_break (0);
1402  goto cleanup;
1403  }
1404  GNUNET_free (chks);
1405  chks = NULL;
1406  GNUNET_free (ksks);
1407  ksks = NULL;
1408  GNUNET_free (skss);
1409  skss = NULL;
1410 
1411  switch (b)
1412  {
1413  case 0: /* file-insert */
1414  if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, "file size",
1415  fi->data.file.file_size))
1416  {
1417  GNUNET_break (0);
1418  goto cleanup;
1419  }
1420  if ((GNUNET_NO == fi->is_published) && (NULL == fi->filename))
1421  if (GNUNET_OK != copy_from_reader (wh, fi))
1422  {
1423  GNUNET_break (0);
1424  goto cleanup;
1425  }
1426  break;
1427 
1428  case 1: /* file-index, no hash */
1429  if (NULL == fi->filename)
1430  {
1431  GNUNET_break (0);
1432  goto cleanup;
1433  }
1434  if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, "file size",
1435  fi->data.file.file_size))
1436  {
1437  GNUNET_break (0);
1438  goto cleanup;
1439  }
1440  break;
1441 
1442  case 2: /* file-index-with-hash */
1443  case 3: /* file-index-with-hash-confirmed */
1444  if (NULL == fi->filename)
1445  {
1446  GNUNET_break (0);
1447  goto cleanup;
1448  }
1449  if ((GNUNET_OK != GNUNET_BIO_write_int64 (wh, "file size",
1450  fi->data.file.file_size)) ||
1452  "file id",
1453  &fi->data.file.file_id,
1454  sizeof(struct GNUNET_HashCode))))
1455  {
1456  GNUNET_break (0);
1457  goto cleanup;
1458  }
1459  break;
1460 
1461  case 4: /* directory */
1462  if ((NULL != fi->data.dir.entries) &&
1463  (NULL == fi->data.dir.entries->serialization))
1465  struct GNUNET_BIO_WriteSpec ws[] = {
1466  GNUNET_BIO_write_spec_int32 ("dir size",
1467  (int32_t *) &fi->data.dir.dir_size),
1469  "contents completed",
1470  (int64_t *) &fi->data.dir.contents_completed),
1471  GNUNET_BIO_write_spec_int64 ("contents size",
1472  (int64_t *) &fi->data.dir.contents_size),
1473  GNUNET_BIO_write_spec_object ("dir data",
1474  fi->data.dir.dir_data,
1475  (uint32_t) fi->data.dir.dir_size),
1476  GNUNET_BIO_write_spec_string ("dir entries",
1477  (fi->data.dir.entries == NULL)
1478  ? NULL
1479  : fi->data.dir.entries->serialization),
1481  };
1482  if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws)))
1483  {
1484  GNUNET_break (0);
1485  goto cleanup;
1486  }
1487  break;
1488 
1489  default:
1490  GNUNET_assert (0);
1491  goto cleanup;
1492  }
1493  if ((NULL != fi->next) && (NULL == fi->next->serialization))
1496  "serialization",
1497  (fi->next != NULL)
1498  ? fi->next->serialization
1499  : NULL))
1500  {
1501  GNUNET_break (0);
1502  goto cleanup;
1503  }
1504  if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
1505  {
1506  wh = NULL;
1507  GNUNET_break (0);
1508  goto cleanup;
1509  }
1510  return; /* done! */
1511 cleanup:
1512  if (NULL != wh)
1513  (void) GNUNET_BIO_write_close (wh, NULL);
1514  GNUNET_free (chks);
1515  GNUNET_free (ksks);
1516  GNUNET_free (skss);
1517  fn = get_serialization_file_name (fi->h,
1519  fi->serialization);
1520  if (NULL != fn)
1521  {
1522  if (0 != unlink (fn))
1524  GNUNET_free (fn);
1525  }
1526  GNUNET_free (fi->serialization);
1527  fi->serialization = NULL;
1528 }
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.
Definition: fs_api.c:1292
static char * make_serialization_file_name(struct GNUNET_FS_Handle *h, const char *ext)
Create a new random name for serialization.
Definition: fs_api.c:1220
static int write_start_time(struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_TIME_Absolute timestamp)
Serialize a start-time.
Definition: fs_api.c:820
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.
Definition: fs_api.c:678
#define GNUNET_FS_SYNC_PATH_FILE_INFO
Name of the directory with files that are being published.
Definition: fs_api.h:82
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
int GNUNET_BIO_write_spec_commit(struct GNUNET_BIO_WriteHandle *h, struct GNUNET_BIO_WriteSpec *ws)
Execute the write specifications in order.
Definition: bio.c:1359
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
Write a buffer to a handle.
Definition: bio.c:752
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *what, const char *s)
Write a 0-terminated string.
Definition: bio.c:789
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
Definition: bio.c:556
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_string(const char *what, const char *s)
Create the specification to write a 0-terminated string.
Definition: bio.c:1201
#define GNUNET_BIO_write_spec_end()
End of specifications marker.
int GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, const char *what, int64_t i)
Write an (u)int64_t.
Definition: bio.c:867
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_object(const char *what, void *source, size_t size)
Create the specification to read some bytes.
Definition: bio.c:1154
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int32(const char *what, int32_t *i)
Create the specification to write an (u)int32_t.
Definition: bio.c:1246
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_int64(const char *what, int64_t *i)
Create the specification to write an (u)int64_t.
Definition: bio.c:1291
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2017
struct GNUNET_BIO_WriteSpec GNUNET_FS_write_spec_meta_data(const char *what, const struct GNUNET_FS_MetaData *m)
Create the specification to write a metadata container.
Definition: meta_data.c:1217
Handle for buffered writing.
Definition: bio.c:466
Structure specifying a writing operation on an IO handle.
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP,...
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority,...
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
struct GNUNET_TIME_Absolute expiration_time
At what time should the block expire? Data blocks (DBLOCKS and IBLOCKS) may still be used even if the...
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:287
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:258
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:302
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:368
uint64_t contents_completed
How much of the directory have we published (relative to contents_size).
Definition: fs_api.h:379
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:297
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:232
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:275
int is_published
Are we done publishing this file?
Definition: fs_api.h:396
struct GNUNET_FS_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:253
struct GNUNET_FS_Uri * sks_uri
SKS URI for this file or directory.
Definition: fs_api.h:270
void * dir_data
Pointer to the data for the directory (or NULL if not available).
Definition: fs_api.h:374
uint64_t contents_size
Sum of all of the sizes of all of the files in the directory.
Definition: fs_api.h:384
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
struct GNUNET_FS_Handle * h
Handle to the master context.
Definition: fs_api.h:243
struct GNUNET_TIME_Absolute start_time
At what time did we start this upload?
Definition: fs_api.h:280
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:362
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:238
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:264
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:391
A 512-bit hashcode.
uint64_t abs_value_us
The actual value.

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::emsg, GNUNET_FS_FileInformation::entries, GNUNET_FS_BlockOptions::expiration_time, GNUNET_FS_FileInformation::file, 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_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::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, wh, and write_start_time().

Referenced by encode_cont(), fip_signal_start(), 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().

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

◆ GNUNET_FS_publish_sync_()

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.

Parameters
pcthe struct to sync

Definition at line 1747 of file fs_api.c.

1748 {
1749  struct GNUNET_BIO_WriteHandle *wh;
1750  int32_t have_ns;
1751 
1752  if (NULL == pc->serialization)
1753  pc->serialization =
1755  if (NULL == pc->serialization)
1756  return;
1757  if (NULL == pc->fi)
1758  return;
1759  if (NULL == pc->fi->serialization)
1760  {
1761  GNUNET_break (0);
1762  return;
1763  }
1764  wh = get_write_handle (pc->h,
1766  pc->serialization);
1767  if (NULL == wh)
1768  {
1769  GNUNET_break (0);
1770  goto cleanup;
1771  }
1772  have_ns = (NULL != pc->ns) ? GNUNET_YES : GNUNET_NO;
1773  struct GNUNET_BIO_WriteSpec ws[] = {
1776  GNUNET_BIO_write_spec_int32 ("options", (int32_t *) &pc->options),
1777  GNUNET_BIO_write_spec_int32 ("all done", &pc->all_done),
1778  GNUNET_BIO_write_spec_int32 ("have ns", &have_ns),
1779  GNUNET_BIO_write_spec_string ("serialization", pc->fi->serialization),
1780  GNUNET_BIO_write_spec_string ("pos serialization", (NULL == pc->fi_pos)
1781  ? NULL
1782  : pc->fi_pos->serialization),
1784  };
1785  if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws)) ||
1786  ((NULL != pc->ns) &&
1787  (GNUNET_OK !=
1789  "ns",
1790  pc->ns,
1791  sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)))))
1792  {
1793  GNUNET_break (0);
1794  goto cleanup;
1795  }
1796  if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
1797  {
1798  wh = NULL;
1799  GNUNET_break (0);
1800  goto cleanup;
1801  }
1802  return;
1803 cleanup:
1804  if (NULL != wh)
1805  (void) GNUNET_BIO_write_close (wh, NULL);
1808  pc->serialization);
1810  pc->serialization = NULL;
1811 }
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
Definition: fs_api.c:728
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH
Name of the directory with publishing operations.
Definition: fs_api.h:77
#define GNUNET_BIO_read_spec_end()
End of specifications marker.
enum GNUNET_FS_PublishOptions options
Options for publishing.
Definition: fs_api.h:1275
char * nuid
ID for future updates, NULL if we have no namespace or no updates.
Definition: fs_api.h:1209
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1194
char * nid
ID of the content in the namespace, NULL if we have no namespace.
Definition: fs_api.h:1204
struct GNUNET_CRYPTO_EcdsaPrivateKey * ns
Namespace that we are publishing in, NULL if we have no namespace.
Definition: fs_api.h:1199
char * serialization
Filename used for serializing information about this operation (should be determined using 'mktemp').
Definition: fs_api.h:1215

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 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().

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

◆ GNUNET_FS_unindex_sync_()

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.

Parameters
ucthe struct to sync

Definition at line 1823 of file fs_api.c.

1824 {
1825  struct GNUNET_BIO_WriteHandle *wh;
1826  char *uris;
1827 
1828  if (NULL == uc->serialization)
1829  uc->serialization =
1831  if (NULL == uc->serialization)
1832  return;
1833  wh = get_write_handle (uc->h,
1835  uc->serialization);
1836  if (NULL == wh)
1837  {
1838  GNUNET_break (0);
1839  goto cleanup;
1840  }
1841  if (NULL != uc->ksk_uri)
1843  else
1844  uris = NULL;
1845  struct GNUNET_BIO_WriteSpec ws1[] = {
1846  GNUNET_BIO_write_spec_string ("filename", uc->filename),
1847  GNUNET_BIO_write_spec_int64 ("file size", (int64_t *) &uc->file_size),
1849  };
1850  struct GNUNET_BIO_WriteSpec ws2[] = {
1851  GNUNET_BIO_write_spec_int32 ("state", (int32_t *) &uc->state),
1852  GNUNET_BIO_write_spec_object ("hashkey", &uc->chk,
1853  sizeof (struct ContentHashKey)),
1854  GNUNET_BIO_write_spec_string ("uris", uris),
1855  GNUNET_BIO_write_spec_int32 ("ksk offset", (int32_t *) &uc->ksk_offset),
1857  };
1858  if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws1)) ||
1861  ((uc->state == UNINDEX_STATE_FS_NOTIFY) &&
1863  "file id",
1864  &uc->file_id,
1865  sizeof(struct GNUNET_HashCode)))) ||
1866  ((uc->state == UNINDEX_STATE_ERROR) &&
1867  (GNUNET_OK != GNUNET_BIO_write_string (wh, "emsg", uc->emsg))))
1868  {
1869  GNUNET_break (0);
1870  goto cleanup;
1871  }
1872  if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
1873  {
1874  wh = NULL;
1875  GNUNET_break (0);
1876  goto cleanup;
1877  }
1878  return;
1879 cleanup:
1880  if (NULL != wh)
1881  (void) GNUNET_BIO_write_close (wh, NULL);
1884  uc->serialization);
1886  uc->serialization = NULL;
1887 }
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
Definition: fs_api.h:87
content hash key
Definition: fs.h:55
struct ContentHashKey chk
The content hash key of the last block we processed, will in the end be set to the CHK from the URI.
Definition: fs_api.h:1356
char * serialization
Short name under which we are serializing the state of this operation.
Definition: fs_api.h:1391

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, 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().

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

◆ GNUNET_FS_search_sync_()

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.

Parameters
scthe struct to sync

Definition at line 2248 of file fs_api.c.

2249 {
2250  struct GNUNET_BIO_WriteHandle *wh;
2251  char *uris;
2252  char in_pause;
2253  const char *category;
2254 
2255  category = (NULL == sc->psearch_result) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
2257  if (NULL == sc->serialization)
2259  if (NULL == sc->serialization)
2260  return;
2261  uris = NULL;
2262  wh = get_write_handle (sc->h, category, sc->serialization);
2263  if (NULL == wh)
2264  {
2265  GNUNET_break (0);
2266  goto cleanup;
2267  }
2270  uris = GNUNET_FS_uri_to_string (sc->uri);
2271  in_pause = (sc->task != NULL) ? 'r' : '\0';
2272  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, "uris", uris)) ||
2274  (GNUNET_OK != GNUNET_BIO_write_string (wh, "emsg", sc->emsg)) ||
2275  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, "options",
2276  (uint32_t) sc->options)) ||
2277  (GNUNET_OK != GNUNET_BIO_write (wh, "in pause",
2278  &in_pause, sizeof(in_pause))) ||
2279  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, "anonymity", sc->anonymity)))
2280  {
2281  GNUNET_break (0);
2282  goto cleanup;
2283  }
2284  GNUNET_free (uris);
2285  uris = NULL;
2286  if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
2287  {
2288  wh = NULL;
2289  GNUNET_break (0);
2290  goto cleanup;
2291  }
2292  return;
2293 cleanup:
2294  if (NULL != wh)
2295  (void) GNUNET_BIO_write_close (wh, NULL);
2296  GNUNET_free (uris);
2299  sc->serialization = NULL;
2300 }
#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH
Name of the directory with top-level searches.
Definition: fs_api.h:55
#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH
Name of the directory with sub-searches (namespace-updates).
Definition: fs_api.h:60
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
Definition: bio.c:847
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
Definition: fs_uri.c:1271
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:1551
char * serialization
Name of the file on disk we use for persistence.
Definition: fs_api.h:1546
enum GNUNET_FS_SearchOptions options
Options for the search.
Definition: fs_api.h:1598
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1515

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, wh, and write_start_time().

Referenced by GNUNET_FS_search_continue(), GNUNET_FS_search_pause(), and search_start().

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

◆ GNUNET_FS_search_result_sync_()

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.

Parameters
srthe struct to sync

Definition at line 2149 of file fs_api.c.

2150 {
2151  struct GNUNET_BIO_WriteHandle *wh;
2152  char *uris;
2153 
2154  if (NULL == sr->sc)
2155  return;
2156  uris = NULL;
2157  if (NULL == sr->serialization)
2158  sr->serialization =
2160  (sr->sc->psearch_result == NULL)
2163  sr->sc->serialization);
2164  if (NULL == sr->serialization)
2165  return;
2166  wh = get_write_handle_in_dir (sr->h,
2167  (sr->sc->psearch_result == NULL)
2170  sr->sc->serialization,
2171  sr->serialization);
2172  if (NULL == wh)
2173  {
2174  GNUNET_break (0);
2175  goto cleanup;
2176  }
2177  uris = GNUNET_FS_uri_to_string (sr->uri);
2178  struct GNUNET_BIO_WriteSpec ws[] = {
2179  GNUNET_BIO_write_spec_string ("uris", uris),
2180  GNUNET_BIO_write_spec_string ("download serialization",
2181  (sr->download != NULL)
2182  ? sr->download->serialization
2183  : NULL),
2184  GNUNET_BIO_write_spec_string ("update search serialization",
2185  (sr->update_search != NULL)
2187  : NULL),
2188  GNUNET_FS_write_spec_meta_data ("metadata", sr->meta),
2189  GNUNET_BIO_write_spec_object ("key", &sr->key,
2190  sizeof(struct GNUNET_HashCode)),
2191  GNUNET_BIO_write_spec_int32 ("mandatory missing",
2192  (int32_t *) &sr->mandatory_missing),
2193  GNUNET_BIO_write_spec_int32 ("optional support",
2194  (int32_t *) &sr->optional_support),
2195  GNUNET_BIO_write_spec_int32 ("availability success",
2196  (int32_t *) &sr->availability_success),
2197  GNUNET_BIO_write_spec_int32 ("availability trials",
2198  (int32_t *) &sr->availability_trials),
2200  };
2201  if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws)))
2202  {
2203  GNUNET_break (0);
2204  goto cleanup;
2205  }
2206  if ((NULL != sr->uri) && (GNUNET_FS_URI_KSK == sr->sc->uri->type) &&
2207  (GNUNET_OK !=
2209  "keyword bitmap",
2210  sr->keyword_bitmap,
2211  (sr->sc->uri->data.ksk.keywordCount + 7) / 8)))
2212  {
2213  GNUNET_break (0);
2214  goto cleanup;
2215  }
2216  if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
2217  {
2218  wh = NULL;
2219  GNUNET_break (0);
2220  goto cleanup;
2221  }
2222  GNUNET_free (uris);
2223  return;
2224 cleanup:
2225  GNUNET_free (uris);
2226  if (NULL != wh)
2227  (void) GNUNET_BIO_write_close (wh, NULL);
2229  (NULL == sr->sc->psearch_result)
2232  sr->sc->serialization,
2233  sr->serialization);
2234  GNUNET_free (sr->serialization);
2235  sr->serialization = NULL;
2236 }
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.
Definition: fs_api.c:758
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.
Definition: fs_api.c:1256
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.
Definition: fs_api.c:703
char * serialization
Random portion of filename we use for syncing state of this download.
Definition: fs_api.h:1816
uint32_t optional_support
Number of optional keywords under which this result was also found.
Definition: fs_api.h:602
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
Definition: fs_api.h:552
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:562
struct GNUNET_HashCode key
Key for the search result based on the URI.
Definition: fs_api.h:567
char * serialization
Name under which this search result is stored on disk.
Definition: fs_api.h:557
struct GNUNET_FS_SearchContext * sc
Search context this result belongs to; can be NULL for probes that come from a directory result.
Definition: fs_api.h:519
uint32_t mandatory_missing
Number of mandatory keywords for which we have NOT yet found the search result; when this value hits ...
Definition: fs_api.h:596

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::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 wh.

Referenced by GNUNET_FS_download_start_task_(), GNUNET_FS_search_probe_progress_(), probe_failure_handler(), probe_success_handler(), process_ksk_result(), and process_sks_result().

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

◆ 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.

Parameters
dcthe struct to sync

Definition at line 2036 of file fs_api.c.

2037 {
2038  struct GNUNET_BIO_WriteHandle *wh;
2039  char *uris;
2040  char *fn;
2041  char *dir;
2042 
2043  if (0 != (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
2044  return; /* we don't sync probes */
2045  if (NULL == dc->serialization)
2046  {
2047  dir = get_download_sync_filename (dc, "", "");
2048  if (NULL == dir)
2049  return;
2051  {
2052  GNUNET_free (dir);
2053  return;
2054  }
2055  fn = GNUNET_DISK_mktemp (dir);
2056  GNUNET_free (dir);
2057  if (NULL == fn)
2058  return;
2060  }
2061  else
2062  {
2064  if (NULL == fn)
2065  {
2067  dc->serialization = NULL;
2068  GNUNET_free (fn);
2069  return;
2070  }
2071  }
2073  if (NULL == wh)
2074  {
2076  dc->serialization = NULL;
2077  GNUNET_free (fn);
2078  return;
2079  }
2082  uris = GNUNET_FS_uri_to_string (dc->uri);
2083  struct GNUNET_BIO_WriteSpec ws1[] = {
2084  GNUNET_BIO_write_spec_string ("uris", uris),
2085  GNUNET_FS_write_spec_meta_data ("metadata", dc->meta),
2087  GNUNET_BIO_write_spec_string ("filename", dc->filename),
2088  GNUNET_BIO_write_spec_string ("temp filename", dc->temp_filename),
2089  GNUNET_BIO_write_spec_int64 ("old file size",
2090  (int64_t *) &dc->old_file_size),
2091  GNUNET_BIO_write_spec_int64 ("offset", (int64_t *) &dc->offset),
2092  GNUNET_BIO_write_spec_int64 ("length", (int64_t *) &dc->length),
2093  GNUNET_BIO_write_spec_int64 ("completed", (int64_t *) &dc->completed),
2095  };
2096  struct GNUNET_BIO_WriteSpec ws2[] = {
2097  GNUNET_BIO_write_spec_int32 ("anonymity", (int32_t *) &dc->anonymity),
2098  GNUNET_BIO_write_spec_int32 ("options", (int32_t *) &dc->options),
2099  GNUNET_BIO_write_spec_int32 ("has finished", (int32_t *) &dc->has_finished),
2101  };
2102  if ((GNUNET_OK != GNUNET_BIO_write_spec_commit (wh, ws1)) ||
2105  {
2106  GNUNET_break (0);
2107  goto cleanup;
2108  }
2109  if (NULL == dc->emsg)
2110  {
2111  GNUNET_assert (dc->top_request != NULL);
2113  {
2114  GNUNET_break (0);
2115  goto cleanup;
2116  }
2117  }
2118  GNUNET_free (uris);
2119  uris = NULL;
2120  if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
2121  {
2122  wh = NULL;
2123  GNUNET_break (0);
2124  goto cleanup;
2125  }
2126  GNUNET_free (fn);
2127  return;
2128 cleanup:
2129  if (NULL != wh)
2130  (void) GNUNET_BIO_write_close (wh, NULL);
2131  GNUNET_free (uris);
2132  if (0 != unlink (fn))
2134  GNUNET_free (fn);
2136  dc->serialization = NULL;
2137 }
static int write_download_request(struct GNUNET_BIO_WriteHandle *wh, struct DownloadRequest *dr)
Serialize a download request.
Definition: fs_api.c:1898
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.
Definition: fs_api.c:2003
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),...
Definition: fs_api.c:1186
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
Definition: bio.c:508
char * GNUNET_DISK_mktemp(const char *t)
Create an (empty) temporary file on disk.
Definition: disk.c:380
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:581
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
Definition: fs_uri.c:1346
int has_finished
Flag set upon transitive completion (includes child downloads).
Definition: fs_api.h:1930
uint64_t old_file_size
What was the size of the file on disk that we're downloading before we started? Used to detect if the...
Definition: fs_api.h:1898
char * temp_filename
Where are we writing the data temporarily (name of the file, can be NULL!); used if we do not have a ...
Definition: fs_api.h:1829

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, 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().

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

◆ GNUNET_FS_publish_signal_suspend_()

void GNUNET_FS_publish_signal_suspend_ ( void *  cls)

Create SUSPEND event for the given publish operation and then clean up our state (without stop signal).

Parameters
clsthe struct GNUNET_FS_PublishContext to signal for

Definition at line 1355 of file fs_publish.c.

1356 {
1357  struct GNUNET_FS_PublishContext *pc = cls;
1358 
1359  if (NULL != pc->upload_task)
1360  {
1362  pc->upload_task = NULL;
1363  }
1366  suspend_operation (pc->fi, pc);
1367  GNUNET_FS_end_top (pc->h, pc->top);
1368  pc->top = NULL;
1369  publish_cleanup (pc);
1370 }
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:402
static int fip_signal_suspend(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 suspending an upload.
Definition: fs_publish.c:1320
static void publish_cleanup(struct GNUNET_FS_PublishContext *pc)
Cleanup the publish context, we're done with it.
Definition: fs_publish.c:79
static void suspend_operation(struct GNUNET_FS_FileInformation *fi, struct GNUNET_FS_PublishContext *pc)
Actually signal the FS's progress function that we are suspending an upload.
Definition: fs_publish.c:1267
void GNUNET_FS_file_information_inspect(struct GNUNET_FS_FileInformation *dir, GNUNET_FS_FileInformationProcessor proc, void *proc_cls)
Inspect a file or directory in a publish-structure.
int skip_next_fi_callback
Flag set to GNUNET_YES if the next callback from GNUNET_FS_file_information_inspect should be skipped...
Definition: fs_api.h:1299
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1189

References GNUNET_FS_PublishContext::fi, fip_signal_suspend(), GNUNET_FS_end_top(), GNUNET_FS_file_information_inspect(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_FS_PublishContext::h, pc, publish_cleanup(), GNUNET_FS_PublishContext::skip_next_fi_callback, suspend_operation(), GNUNET_FS_PublishContext::top, and GNUNET_FS_PublishContext::upload_task.

Referenced by deserialize_publish_file(), and GNUNET_FS_publish_start().

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

◆ GNUNET_FS_search_signal_suspend_()

void GNUNET_FS_search_signal_suspend_ ( void *  cls)

Create SUSPEND event for the given search operation and then clean up our state (without stop signal).

Parameters
clsthe 'struct GNUNET_FS_SearchContext' to signal for

Definition at line 1555 of file fs_search.c.

1556 {
1557  struct GNUNET_FS_SearchContext *sc = cls;
1558  struct GNUNET_FS_ProgressInfo pi;
1559  unsigned int i;
1560 
1561  GNUNET_FS_end_top (sc->h, sc->top);
1566  GNUNET_break (NULL == sc->client_info);
1567  if (sc->task != NULL)
1568  {
1570  sc->task = NULL;
1571  }
1572  if (NULL != sc->mq)
1573  {
1574  GNUNET_MQ_destroy (sc->mq);
1575  sc->mq = NULL;
1576  }
1578  if (NULL != sc->requests)
1579  {
1581  for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1582  {
1585  }
1586  }
1587  GNUNET_free (sc->requests);
1588  GNUNET_free (sc->emsg);
1591  GNUNET_free (sc);
1592 }
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:49
static int search_result_suspend(void *cls, const struct GNUNET_HashCode *key, void *value)
Signal suspend and free the given search result.
Definition: fs_search.c:1516
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
@ GNUNET_FS_STATUS_SEARCH_SUSPEND
Last event when a search is being suspended; note that "GNUNET_FS_SEARCH_STOPPED" will not be generat...
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
Handle for controlling a search.
Definition: fs_api.h:1511
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1520

References GNUNET_FS_SearchContext::client_info, GNUNET_FS_Uri::data, GNUNET_FS_SearchContext::emsg, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_FS_end_top(), GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_SUSPEND, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_test_ksk(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_FS_SearchContext::h, SearchRequestEntry::keyword, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, pi, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, search_result_suspend(), GNUNET_FS_SearchContext::serialization, GNUNET_FS_SearchContext::task, GNUNET_FS_SearchContext::top, and GNUNET_FS_SearchContext::uri.

Referenced by deserialize_search_file(), GNUNET_FS_search_start(), and search_result_suspend().

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

◆ GNUNET_FS_download_signal_suspend_()

void GNUNET_FS_download_signal_suspend_ ( void *  cls)

Create SUSPEND event for the given download operation and then clean up our state (without stop signal).

Parameters
clsthe struct GNUNET_FS_DownloadContext to signal for

Definition at line 1953 of file fs_download.c.

1954 {
1955  struct GNUNET_FS_DownloadContext *dc = cls;
1956  struct GNUNET_FS_ProgressInfo pi;
1957 
1958  if (NULL != dc->top)
1959  GNUNET_FS_end_top (dc->h, dc->top);
1960  while (NULL != dc->child_head)
1962  if (NULL != dc->search)
1963  {
1964  dc->search->download = NULL;
1965  dc->search = NULL;
1966  }
1967  if (NULL != dc->job_queue)
1968  {
1970  dc->job_queue = NULL;
1971  }
1972  if (NULL != dc->parent)
1974  dc->parent->child_tail,
1975  dc);
1976  if (NULL != dc->task)
1977  {
1979  dc->task = NULL;
1980  }
1983  if (NULL != dc->te)
1984  {
1986  dc->te = NULL;
1987  }
1988  if (NULL != dc->rfh)
1989  {
1991  dc->rfh = NULL;
1992  }
1994  if (NULL != dc->active)
1995  {
1997  dc->active = NULL;
1998  }
1999  GNUNET_free (dc->filename);
2004  GNUNET_assert (NULL == dc->job_queue);
2005  GNUNET_free (dc);
2006 }
void GNUNET_FS_dequeue_(struct GNUNET_FS_QueueEntry *qe)
Dequeue a job from the queue.
Definition: fs_api.c:356
void GNUNET_FS_download_signal_suspend_(void *cls)
Create SUSPEND event for the given download operation and then clean up our state (without stop signa...
Definition: fs_download.c:1953
void GNUNET_FS_free_download_request_(struct DownloadRequest *dr)
(recursively) free download request structure
Definition: fs_download.c:997
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
Definition: fs_tree.c:432
void GNUNET_FS_meta_data_destroy(struct GNUNET_FS_MetaData *md)
Free meta data.
Definition: meta_data.c:170
struct GNUNET_FS_DownloadContext * child_tail
Tail of list of child downloads.
Definition: fs_api.h:1780
struct GNUNET_FS_DownloadContext * child_head
Head of list of child downloads.
Definition: fs_api.h:1775
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1753

References GNUNET_FS_DownloadContext::active, GNUNET_FS_DownloadContext::child_head, GNUNET_FS_DownloadContext::child_tail, dc, GNUNET_FS_SearchResult::download, GNUNET_FS_DownloadContext::filename, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_DISK_file_close(), GNUNET_free, GNUNET_FS_dequeue_(), GNUNET_FS_download_make_status_(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_end_top(), GNUNET_FS_free_download_request_(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_STATUS_DOWNLOAD_SUSPEND, GNUNET_FS_tree_encoder_finish(), GNUNET_FS_uri_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_FS_DownloadContext::h, GNUNET_FS_DownloadContext::job_queue, GNUNET_FS_DownloadContext::meta, GNUNET_FS_DownloadContext::parent, pi, GNUNET_FS_DownloadContext::rfh, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::serialization, GNUNET_FS_DownloadContext::task, GNUNET_FS_DownloadContext::te, GNUNET_FS_DownloadContext::temp_filename, GNUNET_FS_DownloadContext::top, GNUNET_FS_DownloadContext::top_request, and GNUNET_FS_DownloadContext::uri.

Referenced by deserialize_download(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_start(), search_result_stop(), and search_result_suspend().

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

◆ GNUNET_FS_unindex_signal_suspend_()

void GNUNET_FS_unindex_signal_suspend_ ( void *  cls)

Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal).

Parameters
clsthe struct GNUNET_FS_UnindexContext to signal for

Definition at line 728 of file fs_unindex.c.

729 {
730  struct GNUNET_FS_UnindexContext *uc = cls;
731  struct GNUNET_FS_ProgressInfo pi;
732 
733  /* FIXME: lots of duplication with unindex_stop here! */
734  if (uc->dscan != NULL)
735  {
737  uc->dscan = NULL;
738  }
739  if (NULL != uc->dqe)
740  {
742  uc->dqe = NULL;
743  }
744  if (uc->fhc != NULL)
745  {
747  uc->fhc = NULL;
748  }
749  if (NULL != uc->ksk_uri)
750  {
752  uc->ksk_uri = NULL;
753  }
754  if (NULL != uc->mq)
755  {
757  uc->mq = NULL;
758  }
759  if (NULL != uc->dsh)
760  {
762  uc->dsh = NULL;
763  }
764  if (NULL != uc->tc)
765  {
767  uc->tc = NULL;
768  }
769  if (uc->fh != NULL)
770  {
772  uc->fh = NULL;
773  }
774  GNUNET_FS_end_top (uc->h, uc->top);
777  (uc->state ==
779  GNUNET_break (NULL == uc->client_info);
782  GNUNET_free (uc->emsg);
783  GNUNET_free (uc);
784 }
void GNUNET_FS_unindex_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_UnindexContext *uc, uint64_t offset)
Fill in all of the generic fields for an unindex event and call the callback.
Definition: fs_unindex.c:85
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
@ GNUNET_FS_STATUS_UNINDEX_SUSPEND
Notification that we suspended unindexing a file.
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
struct TopLevelActivity * top
Our top-level activity entry.
Definition: fs_api.h:1366
struct GNUNET_MQ_Handle * mq
Connection to the FS service, only valid during the UNINDEX_STATE_FS_NOTIFY phase.
Definition: fs_api.h:1397

References GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::dqe, GNUNET_FS_UnindexContext::dscan, GNUNET_FS_UnindexContext::dsh, GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::fh, GNUNET_FS_UnindexContext::fhc, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_break, GNUNET_CRYPTO_hash_file_cancel(), GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_disconnect(), GNUNET_DISK_file_close(), GNUNET_free, GNUNET_FS_directory_scan_abort(), GNUNET_FS_end_top(), GNUNET_FS_STATUS_UNINDEX_SUSPEND, GNUNET_FS_tree_encoder_finish(), GNUNET_FS_unindex_make_status_(), GNUNET_FS_uri_destroy(), GNUNET_MQ_destroy(), GNUNET_NO, GNUNET_FS_UnindexContext::h, GNUNET_FS_UnindexContext::ksk_uri, GNUNET_FS_UnindexContext::mq, pi, GNUNET_FS_UnindexContext::serialization, GNUNET_FS_UnindexContext::state, GNUNET_FS_UnindexContext::tc, GNUNET_FS_UnindexContext::top, uc, and UNINDEX_STATE_COMPLETE.

Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_start().

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

◆ GNUNET_FS_make_top()

struct TopLevelActivity* GNUNET_FS_make_top ( struct GNUNET_FS_Handle h,
SuspendSignalFunction  ssf,
void *  ssf_cls 
)

Create a top-level activity entry.

Parameters
hglobal fs handle
ssfsuspend signal function to use
ssf_clsclosure for ssf
Returns
fresh top-level activity handle

Definition at line 381 of file fs_api.c.

384 {
385  struct TopLevelActivity *ret;
386 
387  ret = GNUNET_new (struct TopLevelActivity);
388  ret->ssf = ssf;
389  ret->ssf_cls = ssf_cls;
390  GNUNET_CONTAINER_DLL_insert (h->top_head, h->top_tail, ret);
391  return ret;
392 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
We track all of the top-level activities of FS so that we can signal 'suspend' on shutdown.
Definition: fs_api.h:1018
void * ssf_cls
Closure for 'ssf' (some struct GNUNET_FS_XXXHandle*)
Definition: fs_api.h:1037
SuspendSignalFunction ssf
Function to call for suspend-signalling and clean up.
Definition: fs_api.h:1032

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().

Here is the caller graph for this function:

◆ GNUNET_FS_end_top()

void GNUNET_FS_end_top ( struct GNUNET_FS_Handle h,
struct TopLevelActivity top 
)

Destroy a top-level activity entry.

Parameters
hglobal fs handle
toptop level activity entry

Definition at line 402 of file fs_api.c.

403 {
404  GNUNET_CONTAINER_DLL_remove (h->top_head, h->top_tail, top);
405  GNUNET_free (top);
406 }

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, and h.

Referenced by GNUNET_FS_download_signal_suspend_(), 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().

Here is the caller graph for this function:

◆ GNUNET_FS_free_download_request_()

void GNUNET_FS_free_download_request_ ( struct DownloadRequest dr)

(recursively) free download request structure

Parameters
drrequest to free

Definition at line 997 of file fs_download.c.

998 {
999  if (NULL == dr)
1000  return;
1001  for (unsigned int i = 0; i < dr->num_children; i++)
1003  GNUNET_free (dr->children);
1004  GNUNET_free (dr);
1005 }
struct DownloadRequest ** children
Array (!) of child-requests, or NULL for the bottom of the tree.
Definition: fs_api.h:1685
unsigned int num_children
Number of entries in children array.
Definition: fs_api.h:1703

References DownloadRequest::children, GNUNET_free, GNUNET_FS_free_download_request_(), and DownloadRequest::num_children.

Referenced by free_download_context(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_free_download_request_(), process_result_with_request(), and read_download_request().

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

◆ GNUNET_FS_stop_probe_ping_task_()

void GNUNET_FS_stop_probe_ping_task_ ( struct GNUNET_FS_SearchResult sr)

Stop the ping task for this search result.

Parameters
srresult to start pinging for.

Definition at line 410 of file fs_search.c.

411 {
412  struct GNUNET_FS_Handle *h = sr->h;
413 
414  GNUNET_CONTAINER_DLL_remove (h->probes_head,
415  h->probes_tail,
416  sr);
417  if (NULL == h->probes_head)
418  {
419  GNUNET_SCHEDULER_cancel (h->probe_ping_task);
420  h->probe_ping_task = NULL;
421  }
422 }

References GNUNET_CONTAINER_DLL_remove, GNUNET_SCHEDULER_cancel(), h, and GNUNET_FS_SearchResult::h.

Referenced by GNUNET_FS_download_start_from_search(), GNUNET_FS_search_stop_probe_(), probe_failure_handler(), probe_success_handler(), and search_result_freeze_probes().

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