GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
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 achive 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 achive 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 43 of file fs_api.h.

Referenced by compute_chk_offset(), compute_disk_offset(), create_download_request(), GNUNET_FS_compute_depth(), GNUNET_FS_tree_calculate_block_size(), GNUNET_FS_tree_compute_iblock_size(), GNUNET_FS_tree_compute_tree_size(), GNUNET_FS_tree_encoder_create(), GNUNET_FS_tree_encoder_next(), and read_download_request().

◆ MAX_INLINE_SIZE

#define MAX_INLINE_SIZE   65536

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

Definition at line 49 of file fs_api.h.

Referenced by GNUNET_FS_directory_builder_add(), GNUNET_FS_download_start_task_(), and publish_content().

◆ GNUNET_FS_SYNC_PATH_MASTER_SEARCH

#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH   "search"

◆ 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 59 of file fs_api.h.

Referenced by deserialize_search(), deserialize_search_result(), free_search_context(), GNUNET_FS_search_result_sync_(), GNUNET_FS_search_stop(), and GNUNET_FS_search_sync_().

◆ 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 65 of file fs_api.h.

Referenced by get_download_sync_filename(), GNUNET_FS_download_stop(), and GNUNET_FS_start().

◆ 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 71 of file fs_api.h.

Referenced by deserialize_search_result(), get_download_sync_filename(), GNUNET_FS_download_stop(), and search_result_stop().

◆ GNUNET_FS_SYNC_PATH_MASTER_PUBLISH

#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH   "publish"

Name of the directory with publishing operations.

Definition at line 76 of file fs_api.h.

Referenced by GNUNET_FS_publish_stop(), GNUNET_FS_publish_sync_(), and GNUNET_FS_start().

◆ 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 81 of file fs_api.h.

Referenced by deserialize_file_information(), fip_signal_stop(), GNUNET_FS_file_information_sync_(), and GNUNET_FS_publish_stop().

◆ GNUNET_FS_SYNC_PATH_MASTER_UNINDEX

#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX   "unindex"

Name of the directory with unindex operations.

Definition at line 86 of file fs_api.h.

Referenced by deserialize_unindex_file(), GNUNET_FS_start(), GNUNET_FS_unindex_stop(), and GNUNET_FS_unindex_sync_().

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 1010 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 138 of file fs_api.h.

139 {
144 
149 
154 
159 };
Keyword search key (query with keywords).
Definition: fs_api.h:153
Content-hash-key (simple file).
Definition: fs_api.h:143
Signed key space (file in namespace).
Definition: fs_api.h:148
Location (chk with identity of hosting peer).
Definition: fs_api.h:158

◆ 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 402 of file fs_api.h.

403 {
408 
413 };
This is a probe (low priority).
Definition: fs_api.h:407
Default priority.
Definition: fs_api.h:412

◆ 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 1305 of file fs_api.h.

1306 {
1311 
1317 
1322 
1327 
1333 
1338 
1343 };
We're done.
Definition: fs_api.h:1337
Find out which keywords apply.
Definition: fs_api.h:1321
We're notifying the FS service about the unindexing.
Definition: fs_api.h:1332
We're telling the datastore to remove KBlocks.
Definition: fs_api.h:1326
We've encountered a fatal error.
Definition: fs_api.h:1342
We're currently hashing the file.
Definition: fs_api.h:1310
We're telling the datastore to delete the respective DBlocks and IBlocks.
Definition: fs_api.h:1316

◆ 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 1606 of file fs_api.h.

1607 {
1612  BRS_INIT = 0,
1613 
1621 
1629 
1636  BRS_RECONSTRUCT_UP = 3,
1637 
1645  BRS_CHK_SET = 4,
1646 
1654  BRS_DOWNLOAD_DOWN = 5,
1655 
1660  BRS_DOWNLOAD_UP = 6,
1661 
1667  BRS_ERROR = 7
1668 };
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:1636
Initial state, block has only been allocated (since it is relevant to the overall download request)...
Definition: fs_api.h:1612
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:1620
We've calculated the CHK bottom-up based on the meta data.
Definition: fs_api.h:1628
We've successfully downloaded this block, but the children still need to be either downloaded or veri...
Definition: fs_api.h:1654
This block and all of its children have been downloaded successfully (full completion propagates up)...
Definition: fs_api.h:1660
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:1667
We've determined the real, desired CHK for this block (full tree reconstruction failed), request is now pending.
Definition: fs_api.h:1645

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
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 jobs uses
priorityhow important is this download
Returns
queue handle

Definition at line 331 of file fs_api.c.

References GNUNET_FS_QueueEntry::blocks, GNUNET_FS_QueueEntry::cls, GNUNET_CONTAINER_DLL_insert_after, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), h, GNUNET_FS_QueueEntry::h, GNUNET_FS_Handle::pending_head, GNUNET_FS_Handle::pending_tail, GNUNET_FS_QueueEntry::priority, process_job_queue(), qe, GNUNET_FS_Handle::queue_job, GNUNET_FS_QueueEntry::queue_time, start, GNUNET_FS_QueueEntry::start, and GNUNET_FS_QueueEntry::stop.

Referenced by GNUNET_FS_download_resume(), and GNUNET_FS_download_start_downloading_().

337 {
338  struct GNUNET_FS_QueueEntry *qe;
339 
340  qe = GNUNET_new (struct GNUNET_FS_QueueEntry);
341  qe->h = h;
342  qe->start = start;
343  qe->stop = stop;
344  qe->cls = cls;
346  qe->blocks = blocks;
347  qe->priority = priority;
349  h->pending_tail,
350  h->pending_tail,
351  qe);
352  if (NULL != h->queue_job)
355  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing job %p\n", qe);
356  return qe;
357 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct GNUNET_SCHEDULER_Task * queue_job
Task that processes the jobs in the running and pending queues (and moves jobs around as needed)...
Definition: fs_api.h:1134
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
struct GNUNET_FS_QueueEntry * pending_head
Head of DLL of pending jobs.
Definition: fs_api.h:1113
static void process_job_queue(void *cls)
Process the jobs in the job queue, possibly starting some and stopping others.
Definition: fs_api.c:106
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_TIME_Absolute queue_time
Time the job was originally queued.
Definition: fs_api.h:459
enum GNUNET_FS_QueuePriority priority
How important is this download?
Definition: fs_api.h:480
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:1280
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
GNUNET_SCHEDULER_TaskCallback start
Function to call when the job is started.
Definition: fs_api.h:434
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_FS_Handle * h
Handle to FS primary context.
Definition: fs_api.h:449
unsigned int blocks
How many blocks do the active downloads have?
Definition: fs_api.h:475
#define GNUNET_log(kind,...)
GNUNET_SCHEDULER_TaskCallback stop
Function to call when the job needs to stop (or is done / dequeued).
Definition: fs_api.h:439
struct GNUNET_FS_QueueEntry * pending_tail
Tail of DLL of pending jobs.
Definition: fs_api.h:1118
void * cls
Closure for start and stop.
Definition: fs_api.h:444
Entry in the job queue.
Definition: fs_api.h:419
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 366 of file fs_api.c.

References GNUNET_FS_QueueEntry::active, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, h, GNUNET_FS_QueueEntry::h, GNUNET_FS_Handle::pending_head, GNUNET_FS_Handle::pending_tail, process_job_queue(), GNUNET_FS_Handle::queue_job, and stop_job().

Referenced by check_completed(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_stop(), and process_result_with_request().

367 {
368  struct GNUNET_FS_Handle *h;
369 
370  h = qe->h;
371  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dequeueing job %p\n", qe);
372  if (GNUNET_YES == qe->active)
373  stop_job (qe);
375  GNUNET_free (qe);
376  if (NULL != h->queue_job)
379 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_SCHEDULER_Task * queue_job
Task that processes the jobs in the running and pending queues (and moves jobs around as needed)...
Definition: fs_api.h:1134
Master context for most FS operations.
Definition: fs_api.h:1068
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:77
struct GNUNET_FS_QueueEntry * pending_head
Head of DLL of pending jobs.
Definition: fs_api.h:1113
static void process_job_queue(void *cls)
Process the jobs in the job queue, possibly starting some and stopping others.
Definition: fs_api.c:106
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
int active
GNUNET_YES if the job is active now.
Definition: fs_api.h:490
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:1280
struct GNUNET_FS_Handle * h
Handle to FS primary context.
Definition: fs_api.h:449
#define GNUNET_log(kind,...)
struct GNUNET_FS_QueueEntry * pending_tail
Tail of DLL of pending jobs.
Definition: fs_api.h:1118
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 457 of file fs_api.c.

References _, FileInfo::fd, FileInfo::filename, GNUNET_asprintf(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_DISK_SEEK_SET, GNUNET_free, GNUNET_SYSERR, and ret.

Referenced by block_reader(), deserialize_fi_node(), GNUNET_FS_file_information_create_from_file(), and GNUNET_FS_file_information_create_from_reader().

462 {
463  struct FileInfo *fi = cls;
464  ssize_t ret;
465 
466  if (UINT64_MAX == offset)
467  {
468  if (NULL != fi->fd)
469  {
471  fi->fd = NULL;
472  }
473  return 0;
474  }
475  if (0 == max)
476  {
477  if (NULL != fi->fd)
479  GNUNET_free (fi->filename);
480  GNUNET_free (fi);
481  return 0;
482  }
483  if (NULL == fi->fd)
484  {
485  fi->fd = GNUNET_DISK_file_open (fi->filename,
488  if (NULL == fi->fd)
489  {
490  GNUNET_asprintf (emsg,
491  _ ("Could not open file `%s': %s"),
492  fi->filename,
493  strerror (errno));
494  return 0;
495  }
496  }
497  if ((GNUNET_SYSERR ==
499  (-1 == (ret = GNUNET_DISK_file_read (fi->fd, buf, max))))
500  {
501  GNUNET_asprintf (emsg,
502  _ ("Could not read file `%s': %s"),
503  fi->filename,
504  strerror (errno));
505  return 0;
506  }
507  if (ret != max)
508  {
509  GNUNET_asprintf (emsg,
510  _ ("Short read reading from file `%s'!"),
511  fi->filename);
512  return 0;
513  }
514  return max;
515 }
Open the file for reading.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
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:732
Nobody is allowed to do anything to the file.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_DISK_FileHandle * fd
File descriptor, NULL if it has not yet been opened.
Definition: fs_api.c:432
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:226
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Seek an absolute position (from the start of the file).
char * filename
Name of the file to read.
Definition: fs_api.c:427
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:1268
Closure for GNUNET_FS_data_reader_file_().
Definition: fs_api.c:422
#define GNUNET_free(ptr)
Wrapper around free.
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
Parameters
filenamefile to read
Returns
closure to use, NULL on error

Definition at line 525 of file fs_api.c.

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

Referenced by deserialize_fi_node(), and GNUNET_FS_file_information_create_from_file().

526 {
527  struct FileInfo *fi;
528 
529  fi = GNUNET_new (struct FileInfo);
531  if (NULL == fi->filename)
532  {
533  GNUNET_free (fi);
534  return NULL;
535  }
536  return fi;
537 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static char * filename
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:603
char * filename
Name of the file to read.
Definition: fs_api.c:427
Closure for GNUNET_FS_data_reader_file_().
Definition: fs_api.c:422
#define GNUNET_free(ptr)
Wrapper around free.
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 561 of file fs_api.c.

References data, GNUNET_free_non_null, and GNUNET_memcpy.

Referenced by deserialize_fi_node(), and GNUNET_FS_file_information_create_from_data().

566 {
567  char *data = cls;
568 
569  if (UINT64_MAX == offset)
570  return 0;
571  if (0 == max)
572  {
573  GNUNET_free_non_null (data);
574  return 0;
575  }
576  GNUNET_memcpy (buf, &data[offset], max);
577  return max;
578 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char buf[2048]
uint32_t data
The data value.
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 280 of file fs_search.c.

References GNUNET_FS_ProgressInfo::download, 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(), GNUNET_FS_SearchResult::probe_active_time, GNUNET_FS_SearchResult::probe_cancel_task, probe_failure_handler(), probe_success_handler(), GNUNET_TIME_Relative::rel_value_us, GNUNET_FS_SearchResult::remaining_probe_time, GetResultContext::sr, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.

Referenced by GNUNET_FS_download_make_status_().

282 {
283  struct GNUNET_FS_SearchResult *sr = info->value.download.cctx;
284  struct GNUNET_TIME_Relative dur;
285 
286  switch (info->status)
287  {
289  /* ignore */
290  break;
292  /* probes should never be resumed */
293  GNUNET_assert (0);
294  break;
296  /* probes should never be suspended */
297  GNUNET_break (0);
298  break;
300  /* ignore */
301  break;
303  if (NULL != sr->probe_cancel_task)
304  {
306  sr->probe_cancel_task = NULL;
307  }
308  sr->probe_cancel_task =
310  &probe_failure_handler, sr);
311  break;
313  if (NULL != sr->probe_cancel_task)
314  {
316  sr->probe_cancel_task = NULL;
317  }
318  sr->probe_cancel_task =
320  break;
322  if (NULL != sr->probe_cancel_task)
323  {
325  sr->probe_cancel_task = NULL;
326  }
327  sr = NULL;
328  break;
330  if (NULL == sr->probe_cancel_task)
331  {
333  sr->probe_cancel_task =
335  &probe_failure_handler, sr);
336  }
337  break;
339  if (NULL != sr->probe_cancel_task)
340  {
342  sr->probe_cancel_task = NULL;
343  }
347  if (0 == sr->remaining_probe_time.rel_value_us)
348  sr->probe_cancel_task =
351  break;
352 
353  default:
354  GNUNET_break (0);
355  return NULL;
356  }
357  return sr;
358 }
Notification that we have started this download.
uint64_t rel_value_us
The actual value.
struct GNUNET_FS_ProgressInfo::@25::@27 download
Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
Notification that this download was suspended.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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:221
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Notification that this download completed.
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
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:1253
struct GNUNET_TIME_Relative remaining_probe_time
How much longer should we run the current probe before giving up?
Definition: fs_api.h:583
Information we store for each search result.
Definition: fs_api.h:497
static void probe_success_handler(void *cls)
Handle the case where we have gotten a response for our probe.
Definition: fs_search.c:245
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:1280
enum GNUNET_FS_Status status
Specific status code (determines the event type).
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2076
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:604
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Notification that this download is no longer actively being pursued (back in the queue).
Notification about progress with this download.
Notification that this download is now actively being pursued (as opposed to waiting in the queue)...
Notification that this download is being resumed.
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:375
struct GNUNET_TIME_Absolute probe_active_time
When did the current probe become active?
Definition: fs_api.h:578
Notification that this download was stopped (final event with respect to this action).
Notification that this download encountered an error.
Time for relative time used by GNUnet, in microseconds.
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:573
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 1062 of file fs_publish.c.

References _, GNUNET_FS_PublishContext::all_done, GNUNET_FS_BlockOptions::anonymity_level, GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_FileInformation::client_info, create_loc_uri(), GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::emsg, GNUNET_FS_FileInformation::entries, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, GNUNET_FS_PublishContext::fhc, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::filename, fn, GNUNET_asprintf(), GNUNET_CONTAINER_meta_data_get_by_type(), GNUNET_CRYPTO_hash_file(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_file_information_sync_(), 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, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_FileInformation::meta, p, pc, GNUNET_FS_ProgressInfo::publish, publish_content(), publish_kblocks(), publish_sblock(), GNUNET_FS_FileInformation::start_time, GNUNET_FS_ProgressInfo::status, GNUNET_FS_PublishContext::upload_task, and GNUNET_FS_ProgressInfo::value.

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

1063 {
1064  struct GNUNET_FS_PublishContext *pc = cls;
1065  struct GNUNET_FS_ProgressInfo pi;
1066  struct GNUNET_FS_FileInformation *p;
1067  char *fn;
1068 
1069  pc->upload_task = NULL;
1070  p = pc->fi_pos;
1071  if (NULL == p)
1072  {
1074  "Publishing complete, now publishing SKS and KSK blocks.\n");
1075  /* upload of entire hierarchy complete,
1076  * publish namespace entries */
1078  publish_sblock (pc);
1079  return;
1080  }
1081  /* find starting position */
1082  while ((GNUNET_YES == p->is_directory) &&
1083  (NULL != p->data.dir.entries) &&
1084  (NULL == p->emsg) &&
1085  (NULL == p->data.dir.entries->chk_uri))
1086  {
1087  p = p->data.dir.entries;
1088  pc->fi_pos = p;
1090  }
1091  /* abort on error */
1092  if (NULL != p->emsg)
1093  {
1095  "Error uploading: %s\n",
1096  p->emsg);
1097  /* error with current file, abort all
1098  * related files as well! */
1099  while (NULL != p->dir)
1100  {
1103  p = p->dir;
1104  if (fn != NULL)
1105  {
1106  GNUNET_asprintf (&p->emsg,
1107  _ ("Recursive upload failed at `%s': %s"),
1108  fn,
1109  p->emsg);
1110  GNUNET_free (fn);
1111  }
1112  else
1113  {
1114  GNUNET_asprintf (&p->emsg,
1115  _ ("Recursive upload failed: %s"),
1116  p->emsg);
1117  }
1119  pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
1120  pi.value.publish.specifics.error.message = p->emsg;
1121  p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
1122  }
1123  pc->all_done = GNUNET_YES;
1125  return;
1126  }
1127  /* handle completion */
1128  if (NULL != p->chk_uri)
1129  {
1131  "File upload complete, now publishing KSK blocks.\n");
1133 
1134  if ((0 == p->bo.anonymity_level) &&
1135  (GNUNET_YES !=
1137  {
1138  /* zero anonymity, box CHK URI in LOC URI */
1139  create_loc_uri (pc);
1140  }
1141  else
1142  {
1143  publish_kblocks (pc);
1144  }
1145  return;
1146  }
1147  if ((GNUNET_YES != p->is_directory) && (p->data.file.do_index))
1148  {
1149  if (NULL == p->filename)
1150  {
1151  p->data.file.do_index = GNUNET_NO;
1153  _ (
1154  "Can not index file `%s': %s. Will try to insert instead.\n"),
1155  "<no-name>",
1156  _ ("needs to be an actual file"));
1158  publish_content (pc);
1159  return;
1160  }
1161  if (p->data.file.have_hash)
1162  {
1163  hash_for_index_cb (pc, &p->data.file.file_id);
1164  }
1165  else
1166  {
1168  pc->fhc =
1171  }
1172  return;
1173  }
1174  publish_content (pc);
1175 }
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:361
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:237
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:1312
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
static void publish_content(struct GNUNET_FS_PublishContext *pc)
We are uploading a file or directory; load (if necessary) the next block into memory, encrypt it and send it to the FS service.
Definition: fs_publish.c:615
struct GNUNET_TIME_Absolute start_time
At what time did we start this upload?
Definition: fs_api.h:279
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_FileHashContext * fhc
Non-null if we are currently hashing a file.
Definition: fs_api.h:1230
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
char * GNUNET_CONTAINER_meta_data_get_by_type(const struct GNUNET_CONTAINER_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
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.
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
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:805
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_FS_uri_test_loc(const struct GNUNET_FS_Uri *uri)
Is this a location URI?
Definition: fs_uri.c:1395
static void publish_kblocks(struct GNUNET_FS_PublishContext *pc)
We&#39;ve computed the CHK/LOC URI, now publish the KSKs (if applicable).
Definition: fs_publish.c:933
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP, >1: with cover traffic).
static void publish_sblock(struct GNUNET_FS_PublishContext *pc)
We are almost done publishing the structure, add SBlocks (if needed).
Definition: fs_publish.c:285
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static void create_loc_uri(struct GNUNET_FS_PublishContext *pc)
We&#39;re publishing without anonymity.
Definition: fs_publish.c:1016
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1706
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
static char * fn
Filename of the unique file.
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:263
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Run when otherwise idle.
int all_done
Set to GNUNET_YES if all processing has completed.
Definition: fs_api.h:1291
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:47
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
Notification that an error was encountered sharing a file structure.
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:47
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
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 694 of file fs_unindex.c.

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

696 {
697  struct GNUNET_FS_UnindexContext *uc = cls;
698 
699  uc->fhc = NULL;
700  if (uc->state != UNINDEX_STATE_HASHING)
701  {
703  return;
704  }
705  if (file_id == NULL)
706  {
708  uc->emsg = GNUNET_strdup (_ ("Failed to compute hash of file."));
711  return;
712  }
713  uc->file_id = *file_id;
717 }
static void signal_unindex_error(struct GNUNET_FS_UnindexContext *uc)
We&#39;ve encountered an error during unindexing.
Definition: fs_unindex.c:138
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:837
static struct GNUNET_FS_UnindexContext * uc
struct GNUNET_HashCode file_id
Hash of the file&#39;s contents (once computed).
Definition: fs_api.h:1458
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1463
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle for controlling an unindexing operation.
Definition: fs_api.h:1349
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1443
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
void GNUNET_FS_unindex_do_remove_(struct GNUNET_FS_UnindexContext *uc)
Connect to the datastore and remove the blocks.
Definition: fs_unindex.c:649
We&#39;ve encountered a fatal error.
Definition: fs_api.h:1342
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1778
We&#39;re currently hashing the file.
Definition: fs_api.h:1310
We&#39;re telling the datastore to delete the respective DBlocks and IBlocks.
Definition: fs_api.h:1316
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1438
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 406 of file fs_unindex.c.

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

Referenced by deserialize_unindex_file(), and unindex_extract_keywords().

407 {
408  char *ex;
409 
410  if (GNUNET_OK !=
411  GNUNET_CONFIGURATION_get_value_string (uc->h->cfg, "FS", "EXTRACTORS",
412  &ex))
413  ex = NULL;
415  GNUNET_NO, ex,
417  uc);
419 }
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.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
int 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.
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:354
struct GNUNET_FS_DirScanner * dscan
Directory scanner to find keywords (KBlock removal).
Definition: fs_api.h:1370
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
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 580 of file fs_unindex.c.

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

581 {
582  const char *keyword;
583  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
584  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
585  struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
586 
587  if (NULL == uc->dsh)
588  uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
589  if (NULL == uc->dsh)
590  {
592  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
595  return;
596  }
597  if ((NULL == uc->ksk_uri) ||
598  (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount))
599  {
600  unindex_finish (uc);
601  return;
602  }
605  &anon_pub);
606  keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
608  keyword,
609  "fs-ublock",
610  &dpub);
611  GNUNET_CRYPTO_hash (&dpub,
612  sizeof(dpub),
613  &uc->uquery);
614  uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
615  0 /* next_uid */,
616  false /* random */,
617  &uc->uquery,
619  0 /* priority */,
620  1 /* queue size */,
622  uc);
623 }
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:812
static void signal_unindex_error(struct GNUNET_FS_UnindexContext *uc)
We&#39;ve encountered an error during unindexing.
Definition: fs_unindex.c:138
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.
Definition: crypto_ecc.c:1338
uint32_t ksk_offset
Current offset in KSK removal.
Definition: fs_api.h:1380
Private ECC key encoded for transmission.
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1463
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase...
Definition: fs_api.h:1402
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_HashCode uquery
Current query of &#39;get_key&#39; operation.
Definition: fs_api.h:1433
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
We&#39;ve encountered a fatal error.
Definition: fs_api.h:1342
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1375
Type of a block representing any type of search result (universal).
struct GNUNET_DATASTORE_QueueEntry * dqe
Handle to datastore &#39;get_key&#39; operation issued for obtaining KBlocks.
Definition: fs_api.h:1423
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:239
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1778
union GNUNET_FS_Uri::@13 data
static void unindex_finish(struct GNUNET_FS_UnindexContext *uc)
Function called when we are done with removing UBlocks.
Definition: fs_unindex.c:289
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:476
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_FS_Uri::@13::@14 ksk
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1438
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.
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
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 47 of file fs_publish.c.

References GNUNET_FS_BlockOptions::anonymity_level, GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::filename, GNUNET_FS_ProgressInfo::fsh, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_calculate_eta(), GNUNET_YES, GNUNET_FS_PublishContext::h, GNUNET_FS_FileInformation::is_directory, p, pc, GNUNET_FS_ProgressInfo::publish, GNUNET_FS_FileInformation::start_time, GNUNET_FS_Handle::upcb, GNUNET_FS_Handle::upcb_cls, and GNUNET_FS_ProgressInfo::value.

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

51 {
52  pi->value.publish.pc = pc;
53  pi->value.publish.fi = p;
54  pi->value.publish.cctx = p->client_info;
55  pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info;
56  pi->value.publish.filename = p->filename;
57  pi->value.publish.size =
58  (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size :
59  p->data.file.file_size;
60  pi->value.publish.eta =
62  pi->value.publish.size);
63  pi->value.publish.completed = offset;
64  pi->value.publish.duration =
66  pi->value.publish.anonymity = p->bo.anonymity_level;
67  pi->fsh = pc->h;
68  return pc->h->upcb (pc->h->upcb_cls, pi);
69 }
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:237
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
struct GNUNET_TIME_Absolute start_time
At what time did we start this upload?
Definition: fs_api.h:279
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP, >1: with cover traffic).
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1083
struct GNUNET_FS_ProgressInfo::@25::@26 publish
Values for all "GNUNET_FS_STATUS_PUBLISH_*" events.
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:375
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1088
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:551
#define GNUNET_YES
Definition: gnunet_common.h:77
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:367
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 103 of file fs_download.c.

References GNUNET_FS_DownloadContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_DownloadContext::client_info, GNUNET_FS_DownloadContext::completed, dc, GNUNET_FS_ProgressInfo::download, GNUNET_FS_DownloadContext::filename, GNUNET_FS_ProgressInfo::fsh, 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, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::start_time, GNUNET_FS_Handle::upcb, GNUNET_FS_Handle::upcb_cls, GNUNET_FS_DownloadContext::uri, and GNUNET_FS_ProgressInfo::value.

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

105 {
106  pi->value.download.dc = dc;
107  pi->value.download.cctx = dc->client_info;
108  pi->value.download.pctx =
109  (NULL == dc->parent) ? NULL : dc->parent->client_info;
110  pi->value.download.sctx =
111  (NULL == dc->search) ? NULL : dc->search->client_info;
112  pi->value.download.uri = dc->uri;
113  pi->value.download.filename = dc->filename;
114  pi->value.download.size = dc->length;
115  /* FIXME: Fix duration calculation to account for pauses */
116  pi->value.download.duration =
118  pi->value.download.completed = dc->completed;
119  pi->value.download.anonymity = dc->anonymity;
120  pi->value.download.eta =
122  pi->value.download.is_active = (NULL == dc->mq) ? GNUNET_NO : GNUNET_YES;
123  pi->fsh = dc->h;
124  if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
125  dc->client_info = dc->h->upcb (dc->h->upcb_cls, pi);
126  else
128 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
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:280
struct GNUNET_FS_ProgressInfo::@25::@27 download
Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
enum GNUNET_FS_DownloadOptions options
Options for the download.
Definition: fs_api.h:1922
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1747
struct GNUNET_FS_DownloadContext * parent
Parent download (used when downloading files in directories).
Definition: fs_api.h:1763
#define GNUNET_NO
Definition: gnunet_common.h:78
char * filename
Where are we writing the data (name of the file, can be NULL!).
Definition: fs_api.h:1821
void * client_info
Context kept for the client.
Definition: fs_api.h:1794
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file! ...
Definition: fs_api.h:1883
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
Internal option used to flag this download as a &#39;probe&#39; for a search result.
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none...
Definition: fs_api.h:1769
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1083
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:375
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1088
uint32_t anonymity
Desired level of anonymity.
Definition: fs_api.h:1912
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1757
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:551
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_TIME_Absolute start_time
Time download was started.
Definition: fs_api.h:1902
uint64_t completed
How many bytes have we already received within the specified range (DBlocks only).
Definition: fs_api.h:1889
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
Definition: fs_api.h:1799
static struct GNUNET_FS_DownloadContext * dc
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 1809 of file fs_download.c.

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, GNUNET_FS_ProgressInfo::download, GNUNET_FS_DownloadContext::emsg, fh, fh_reader(), Location::fi, GNUNET_FS_DownloadContext::filename, get_next_block(), GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_meta_data_get_serialized_size(), GNUNET_CONTAINER_meta_data_iterate(), 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_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, reconstruct_cb(), reconstruct_cont(), GNUNET_FS_DownloadContext::rfh, schedule_block_download(), GNUNET_FS_DownloadContext::search, DownloadRequest::state, GNUNET_FS_ProgressInfo::status, 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, GNUNET_FS_DownloadContext::uri, and GNUNET_FS_ProgressInfo::value.

Referenced by create_download_context(), and deserialize_download().

1810 {
1811  struct GNUNET_FS_DownloadContext *dc = cls;
1812  struct GNUNET_FS_ProgressInfo pi;
1813  struct GNUNET_DISK_FileHandle *fh;
1814 
1815  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start task running...\n");
1816  dc->task = NULL;
1817  if (0 == dc->length)
1818  {
1819  /* no bytes required! */
1820  if (NULL != dc->filename)
1821  {
1822  fh = GNUNET_DISK_file_open (dc->filename,
1825  | ((0 ==
1828  : 0),
1834  }
1837  pi.value.download.specifics.start.meta = dc->meta;
1839  check_completed (dc);
1840  return;
1841  }
1842  if (NULL != dc->emsg)
1843  return;
1844  if (NULL == dc->top_request)
1845  {
1847  0,
1848  dc->treedepth - 1,
1849  0,
1850  dc->offset,
1851  dc->length);
1852  dc->top_request->state = BRS_CHK_SET;
1853  dc->top_request->chk = (dc->uri->type == GNUNET_FS_URI_CHK)
1854  ? dc->uri->data.chk.chk
1855  : dc->uri->data.loc.fi.chk;
1856  /* signal start */
1858  if (NULL != dc->search)
1861  pi.value.download.specifics.start.meta = dc->meta;
1863  }
1865  /* attempt reconstruction from disk */
1867  dc->rfh = GNUNET_DISK_file_open (dc->filename,
1870  if (dc->top_request->state == BRS_CHK_SET)
1871  {
1872  if (NULL != dc->rfh)
1873  {
1874  /* first, try top-down */
1876  "Trying top-down reconstruction for `%s'\n",
1877  dc->filename);
1879  switch (dc->top_request->state)
1880  {
1881  case BRS_CHK_SET:
1882  break; /* normal */
1883 
1884  case BRS_DOWNLOAD_DOWN:
1885  break; /* normal, some blocks already down */
1886 
1887  case BRS_DOWNLOAD_UP:
1888  /* already done entirely, party! */
1889  if (NULL != dc->rfh)
1890  {
1891  /* avoid hanging on to file handle longer than
1892  * necessary */
1894  dc->rfh = NULL;
1895  }
1896  return;
1897 
1898  case BRS_ERROR:
1899  GNUNET_asprintf (&dc->emsg, _ ("Invalid URI"));
1902  pi.value.download.specifics.error.message = dc->emsg;
1904  return;
1905 
1906  default:
1907  GNUNET_assert (0);
1908  break;
1909  }
1910  }
1911  }
1912  /* attempt reconstruction from meta data */
1914  (NULL != dc->meta))
1915  {
1916  GNUNET_log (
1918  "Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
1919  (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
1922  if (BRS_DOWNLOAD_UP == dc->top_request->state)
1923  {
1924  if (NULL != dc->rfh)
1925  {
1926  /* avoid hanging on to file handle longer than
1927  * necessary */
1929  dc->rfh = NULL;
1930  }
1931  return; /* finished, status update was already done for us */
1932  }
1933  }
1934  if (NULL != dc->rfh)
1935  {
1936  /* finally, actually run bottom-up */
1938  "Trying bottom-up reconstruction of file `%s'\n",
1939  dc->filename);
1940  dc->te =
1943  dc,
1944  &fh_reader,
1945  &reconstruct_cb,
1946  NULL,
1947  &reconstruct_cont);
1949  }
1950  else
1951  {
1952  /* simple, top-level download */
1953  dc->issue_requests = GNUNET_YES;
1955  }
1956  if (BRS_DOWNLOAD_UP == dc->top_request->state)
1957  check_completed (dc);
1958 }
ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size(const struct GNUNET_CONTAINER_MetaData *md)
Get the size of the full meta-data in serialized form.
int 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:544
Notification that we have started this download.
Open the file for reading.
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:103
Create file if it doesn&#39;t exist.
Context for controlling a download.
Definition: fs_api.h:1742
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:1625
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1747
static void try_top_down_reconstruction(struct GNUNET_FS_DownloadContext *dc, struct DownloadRequest *dr)
Try top-down reconstruction.
Definition: fs_download.c:662
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:103
void GNUNET_FS_download_sync_(struct GNUNET_FS_DownloadContext *dc)
Synchronize this download struct with its mirror on disk.
Definition: fs_api.c:1972
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:1494
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct DownloadRequest * top_request
Top-level download request.
Definition: fs_api.h:1855
Nobody is allowed to do anything to the file.
char * filename
Where are we writing the data (name of the file, can be NULL!).
Definition: fs_api.h:1821
struct ContentHashKey chk
CHK for the request for this block (set during reconstruction to what we have on disk, later to what we want to have).
Definition: fs_api.h:1690
enum BlockRequestState state
State in the FSM.
Definition: fs_api.h:1717
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define MAX_INLINE_SIZE
Maximum size for a file to be considered for inlining in a directory.
Definition: fs_api.h:49
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file! ...
Definition: fs_api.h:1883
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Truncate file if it exists.
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:1280
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2076
static void check_completed(struct GNUNET_FS_DownloadContext *dc)
Check if all child-downloads have completed (or trigger them if necessary) and once we&#39;re completely ...
Definition: fs_download.c:375
static void reconstruct_cont(void *cls)
Continuation after a possible attempt to reconstruct the current IBlock from the existing file...
Definition: fs_download.c:1570
int issue_requests
Are we ready to issue requests (reconstructions are finished)?
Definition: fs_api.h:1934
static int fh
Handle to the unique file.
struct GNUNET_FS_TreeEncoder * te
Tree encoder used for the reconstruction.
Definition: fs_api.h:1838
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:269
uint64_t offset
What is the first offset that we&#39;re interested in?
Definition: fs_api.h:1877
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:1777
We&#39;ve successfully downloaded this block, but the children still need to be either downloaded or veri...
Definition: fs_api.h:1654
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:1871
struct GNUNET_DISK_FileHandle * rfh
File handle for reading data from an existing file (to pass to tree encoder).
Definition: fs_api.h:1844
This block and all of its children have been downloaded successfully (full completion propagates up)...
Definition: fs_api.h:1660
Content-hash-key (simple file).
Definition: fs_api.h:143
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none...
Definition: fs_api.h:1769
char * emsg
Error message, NULL if we&#39;re doing OK.
Definition: fs_api.h:1809
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
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:1667
static void get_next_block(void *cls)
Task requesting the next block from the tree encoder.
Definition: fs_download.c:1598
Everybody can read.
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:601
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:1371
struct FileIdentifier fi
Information about the shared file.
Definition: fs_api.h:116
int GNUNET_CONTAINER_meta_data_iterate(const struct GNUNET_CONTAINER_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
Iterate over MD entries.
#define GNUNET_log(kind,...)
Open the file for both reading and writing.
unsigned int treedepth
The depth of the file-tree.
Definition: fs_api.h:1917
struct GNUNET_CONTAINER_MetaData * meta
Known meta-data for the file (can be NULL).
Definition: fs_api.h:1804
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
Definition: fs_api.h:1799
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:1268
void GNUNET_FS_download_start_downloading_(struct GNUNET_FS_DownloadContext *dc)
Start the downloading process (by entering the queue).
Definition: fs_download.c:2263
Handle used to access files (and pipes).
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:777
We&#39;ve determined the real, desired CHK for this block (full tree reconstruction failed), request is now pending.
Definition: fs_api.h:1645
Notification that this download encountered an error.
static struct GNUNET_FS_DownloadContext * dc
Argument given to the progress callback with information about what is going on.
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 84 of file fs_unindex.c.

References GNUNET_FS_UnindexContext::client_info, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, GNUNET_FS_ProgressInfo::fsh, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_calculate_eta(), GNUNET_FS_UnindexContext::h, GNUNET_FS_UnindexContext::start_time, uc, GNUNET_FS_ProgressInfo::unindex, GNUNET_FS_Handle::upcb, GNUNET_FS_Handle::upcb_cls, and GNUNET_FS_ProgressInfo::value.

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

87 {
88  pi->value.unindex.uc = uc;
89  pi->value.unindex.cctx = uc->client_info;
90  pi->value.unindex.filename = uc->filename;
91  pi->value.unindex.size = uc->file_size;
92  pi->value.unindex.eta =
94  pi->value.unindex.duration =
96  pi->value.unindex.completed = offset;
97  pi->fsh = uc->h;
98  uc->client_info = uc->h->upcb (uc->h->upcb_cls, pi);
99 }
static struct GNUNET_FS_UnindexContext * uc
struct GNUNET_FS_ProgressInfo::@25::@29 unindex
Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1453
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1083
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:375
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1088
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:551
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1407
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1448
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 48 of file fs_search.c.

References GNUNET_FS_SearchContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchContext::client_info, GNUNET_FS_ProgressInfo::fsh, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_ZERO, GNUNET_FS_SearchContext::psearch_result, ret, sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_SearchContext::start_time, GNUNET_FS_Handle::upcb, GNUNET_FS_Handle::upcb_cls, GNUNET_FS_SearchContext::uri, and GNUNET_FS_ProgressInfo::value.

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

51 {
52  void *ret;
53 
54  pi->value.search.sc = sc;
55  pi->value.search.cctx = (NULL != sc) ? sc->client_info : NULL;
56  pi->value.search.pctx =
57  ((NULL == sc) || (NULL == sc->psearch_result))
58  ? NULL
60  pi->value.search.query = (NULL != sc) ? sc->uri : NULL;
61  pi->value.search.duration = (NULL != sc)
63  sc->start_time)
65  pi->value.search.anonymity = (NULL != sc) ? sc->anonymity : 0;
66  pi->fsh = h;
67  ret = h->upcb (h->upcb_cls, pi);
68  return ret;
69 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
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:1530
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1569
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
uint32_t anonymity
Anonymity level for the search.
Definition: fs_api.h:1587
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
struct GNUNET_FS_ProgressInfo::@25::@28 search
Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1083
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:375
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1088
void * client_info
Pointer we keep for the client.
Definition: fs_api.h:1540
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 649 of file fs_unindex.c.

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, unindex_extract_keywords(), unindex_process(), unindex_progress(), unindex_reader(), and UNINDEX_STATE_ERROR.

Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_process_hash_().

650 {
651  if (NULL == uc->dsh)
652  uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
653  if (NULL == uc->dsh)
654  {
656  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
659  return;
660  }
661  uc->fh =
664  if (NULL == uc->fh)
665  {
667  uc->dsh = NULL;
669  uc->emsg = GNUNET_strdup (_ ("Failed to open file for unindexing."));
672  return;
673  }
674  uc->tc =
676  uc->file_size,
677  uc,
683 }
Open the file for reading.
static void signal_unindex_error(struct GNUNET_FS_UnindexContext *uc)
We&#39;ve encountered an error during unindexing.
Definition: fs_unindex.c:138
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:113
struct GNUNET_FS_TreeEncoder * tc
Merkle-ish tree encoder context.
Definition: fs_api.h:1412
Nobody is allowed to do anything to the file.
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:331
#define GNUNET_NO
Definition: gnunet_common.h:78
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1463
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase...
Definition: fs_api.h:1402
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:193
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_DISK_FileHandle * fh
Handle used to read the file.
Definition: fs_api.h:1417
We&#39;ve encountered a fatal error.
Definition: fs_api.h:1342
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:269
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1778
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
static void unindex_extract_keywords(void *cls)
Function called when the tree encoder has processed all blocks.
Definition: fs_unindex.c:633
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1438
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:51
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
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:1268
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1448
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
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
Parameters
scsearch context
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 1408 of file fs_search.c.

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, GNUNET_FS_SearchContext::task, update_sre_result_maps(), SearchRequestEntry::uquery, and GNUNET_FS_SearchContext::uri.

Referenced by deserialize_search(), and search_start().

1409 {
1410  unsigned int i;
1411  const char *keyword;
1412  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
1413  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
1414  struct SearchRequestEntry *sre;
1415 
1416  GNUNET_assert (NULL == sc->mq);
1417  if (GNUNET_FS_uri_test_ksk (sc->uri))
1418  {
1419  GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
1421  GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub);
1422  sc->requests
1423  = GNUNET_new_array (sc->uri->data.ksk.keywordCount,
1424  struct SearchRequestEntry);
1425 
1426  for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1427  {
1428  keyword = &sc->uri->data.ksk.keywords[i][1];
1429  sre = &sc->requests[i];
1430  sre->keyword = GNUNET_strdup (keyword);
1432  keyword,
1433  "fs-ublock",
1434  &sre->dpub);
1435  GNUNET_CRYPTO_hash (&sre->dpub,
1436  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
1437  &sre->uquery);
1438  sre->mandatory = (sc->uri->data.ksk.keywords[i][0] == '+');
1439  if (sre->mandatory)
1440  sc->mandatory_count++;
1442  }
1445  sc);
1446  }
1447  GNUNET_assert (NULL == sc->task);
1448  do_reconnect (sc);
1449  if (NULL == sc->mq)
1450  {
1452  sc->task = NULL;
1453  return GNUNET_SYSERR;
1454  }
1455  return GNUNET_OK;
1456 }
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1335
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:812
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.
Definition: crypto_ecc.c:1338
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:1582
uint32_t mandatory_count
Number of mandatory keywords in this query.
Definition: fs_api.h:1592
struct GNUNET_HashCode uquery
Hash of the public key, also known as the query.
Definition: fs_api.h:1475
struct GNUNET_CRYPTO_EcdsaPublicKey dpub
Derived public key, hashes to &#39;uquery&#39;.
Definition: fs_api.h:1480
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int mandatory
Is this keyword a mandatory keyword (started with &#39;+&#39;)?
Definition: fs_api.h:1502
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
static void do_reconnect(void *cls)
Reconnect to the FS service and transmit our queries NOW.
Definition: fs_search.c:1271
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:1558
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
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:1496
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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:239
union GNUNET_FS_Uri::@13 data
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_FS_Uri::@13::@14 ksk
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static int update_sre_result_maps(void *cls, const struct GNUNET_HashCode *key, void *value)
Update the &#39;results&#39; map for the individual keywords with the results from the &#39;global&#39; result set...
Definition: fs_search.c:1380
Information we keep for each keyword in a keyword search.
Definition: fs_api.h:1470
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
char * keyword
The original keyword, used to derive the key (for decrypting the UBlock).
Definition: fs_api.h:1486
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 2263 of file fs_download.c.

References activate_fs_download(), GNUNET_FS_DownloadContext::active, GNUNET_FS_DownloadContext::completed, DBLOCK_SIZE, 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_().

2264 {
2265  if (dc->completed == dc->length)
2266  return;
2267  if (NULL != dc->mq)
2268  return; /* already running */
2269  GNUNET_assert (NULL == dc->job_queue);
2270  GNUNET_assert (NULL == dc->task);
2271  GNUNET_assert (NULL != dc->active);
2272  dc->job_queue =
2273  GNUNET_FS_queue_ (dc->h,
2276  dc,
2277  (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE,
2278  (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
2282  "Download %p put into queue as job %p\n",
2283  dc,
2284  dc->job_queue);
2285 }
This is a probe (low priority).
Definition: fs_api.h:407
enum GNUNET_FS_DownloadOptions options
Options for the download.
Definition: fs_api.h:1922
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1747
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void activate_fs_download(void *cls)
We&#39;re allowed to ask the FS service for our blocks.
Definition: fs_download.c:1437
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file! ...
Definition: fs_api.h:1883
Internal option used to flag this download as a &#39;probe&#39; for a search result.
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:331
struct GNUNET_CONTAINER_MultiHashMap * active
Map of active requests (those waiting for a response).
Definition: fs_api.h:1850
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:1871
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:40
static void deactivate_fs_download(void *cls)
We must stop to ask the FS service for our blocks.
Definition: fs_download.c:1458
#define GNUNET_log(kind,...)
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1757
uint64_t completed
How many bytes have we already received within the specified range (DBlocks only).
Definition: fs_api.h:1889
Default priority.
Definition: fs_api.h:412
struct GNUNET_FS_QueueEntry * job_queue
Our entry in the job queue.
Definition: fs_api.h:1833
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 430 of file fs_search.c.

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

431 {
432  uint64_t off;
433  uint64_t len;
434 
435  if (NULL != sr->probe_ctx)
436  return;
437  if (NULL != sr->download)
438  return;
439  if (0 == (sr->h->flags & GNUNET_FS_FLAGS_DO_PROBES))
440  return;
442  return;
443  if ( (GNUNET_FS_URI_CHK != sr->uri->type) &&
444  (GNUNET_FS_URI_LOC != sr->uri->type) )
445  return;
447  if (0 == len)
448  return;
449  if ((len <= DBLOCK_SIZE) && (sr->availability_success > 0))
450  return;
451  off = len / DBLOCK_SIZE;
452  if (off > 0)
454  off *= DBLOCK_SIZE;
455  if (len - off < DBLOCK_SIZE)
456  len = len - off;
457  else
458  len = DBLOCK_SIZE;
460  "Starting probe #%u (at offset %llu) for search result %p\n",
461  sr->availability_trials + 1,
462  (unsigned long long) off,
463  sr);
466  2 * (1
467  + sr->availability_trials));
468  sr->probe_ctx =
469  GNUNET_FS_download_start (sr->h, sr->uri, sr->meta, NULL, NULL, off,
470  len, sr->anonymity,
472  | GNUNET_FS_DOWNLOAD_IS_PROBE, sr, NULL);
474 }
static void start_probe_ping_task(struct GNUNET_FS_SearchResult *sr)
Start the ping task for this search result.
Definition: fs_search.c:389
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:545
struct GNUNET_TIME_Relative avg_block_latency
Average time we take for a single request to be satisfied.
Definition: fs_api.h:1146
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results&#39; availability (NULL if we are not currently probin...
Definition: fs_api.h:539
struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_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:2145
Do not append temporary data to the target file (for the IBlocks).
struct GNUNET_TIME_Relative remaining_probe_time
How much longer should we run the current probe before giving up?
Definition: fs_api.h:583
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:612
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
Should we automatically trigger probes for search results to determine availability? (will create GNUNET_FS_STATUS_SEARCH_UPDATE events).
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Definition: fs_api.h:606
Internal option used to flag this download as a &#39;probe&#39; for a search result.
uint32_t anonymity
Anonymity level to use for probes using this search result.
Definition: fs_api.h:588
#define AVAILABILITY_TRIALS_MAX
Number of availability trials we perform per search result.
Definition: fs_search.c:36
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:40
Content-hash-key (simple file).
Definition: fs_api.h:143
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
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:1371
#define GNUNET_log(kind,...)
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
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:501
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
enum GNUNET_FS_Flags flags
General flags.
Definition: fs_api.h:1161
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 744 of file fs_api.c.

References FileInfo::filename, get_serialization_file_name(), GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, and GNUNET_log_strerror_file.

Referenced by deserialize_search_file(), deserialize_unindex_file(), fip_signal_stop(), free_search_context(), GNUNET_FS_download_stop(), GNUNET_FS_publish_stop(), GNUNET_FS_publish_sync_(), GNUNET_FS_search_stop(), GNUNET_FS_search_sync_(), GNUNET_FS_unindex_stop(), GNUNET_FS_unindex_sync_(), and search_result_stop().

747 {
748  char *filename;
749 
750  if ((NULL == ent) || (0 == strlen (ent)))
751  {
752  GNUNET_break (0);
753  return;
754  }
755  filename = get_serialization_file_name (h, ext, ent);
756  if (NULL != filename)
757  {
758  if ((0 != unlink (filename)) && (ENOENT != errno))
760  GNUNET_free (filename);
761  }
762 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * filename
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:591
#define GNUNET_free(ptr)
Wrapper around free.
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 803 of file fs_api.c.

References get_serialization_file_name_in_dir(), GNUNET_DISK_directory_remove(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, GNUNET_OK, and GNUNET_YES.

Referenced by free_search_context(), GNUNET_FS_download_stop(), and GNUNET_FS_search_stop().

806 {
807  char *dn;
808 
809  if (NULL == uni)
810  return;
811  dn = get_serialization_file_name_in_dir (h, ext, uni, "");
812  if (NULL == dn)
813  return;
817  GNUNET_free (dn);
818 }
int GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition: disk.c:503
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
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:631
int GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1029
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
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 1312 of file fs_api.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_FS_BlockOptions::anonymity_level, GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::chk_uri, cleanup(), GNUNET_FS_BlockOptions::content_priority, GNUNET_FS_FileInformation::contents_completed, GNUNET_FS_FileInformation::contents_size, copy_from_reader(), GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_data, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::emsg, GNUNET_FS_FileInformation::entries, GNUNET_FS_BlockOptions::expiration_time, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::filename, fn, get_serialization_file_name(), get_write_handle(), GNUNET_assert, GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_int64(), GNUNET_BIO_write_meta_data(), GNUNET_BIO_write_string(), GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_free_non_null, GNUNET_FS_file_information_sync_(), GNUNET_FS_SYNC_PATH_FILE_INFO, GNUNET_FS_uri_to_string(), 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_file_information_sync_(), GNUNET_FS_publish_main_(), handle_index_start_failed(), handle_index_start_ok(), handle_signature_response(), hash_for_index_cb(), index_mq_error_handler(), publish_content(), and publish_kblocks_cont().

1313 {
1314  char *fn;
1315  struct GNUNET_BIO_WriteHandle *wh;
1316  char b;
1317  char *ksks;
1318  char *chks;
1319  char *skss;
1320 
1321  if (NULL == fi->serialization)
1322  fi->serialization =
1324  if (NULL == fi->serialization)
1325  return;
1326  wh =
1328  if (NULL == wh)
1329  {
1330  GNUNET_free (fi->serialization);
1331  fi->serialization = NULL;
1332  return;
1333  }
1334  if (GNUNET_YES == fi->is_directory)
1335  b = 4;
1336  else if (GNUNET_YES == fi->data.file.index_start_confirmed)
1337  b = 3;
1338  else if (GNUNET_YES == fi->data.file.have_hash)
1339  b = 2;
1340  else if (GNUNET_YES == fi->data.file.do_index)
1341  b = 1;
1342  else
1343  b = 0;
1344  if (NULL != fi->keywords)
1345  ksks = GNUNET_FS_uri_to_string (fi->keywords);
1346  else
1347  ksks = NULL;
1348  if (NULL != fi->chk_uri)
1349  chks = GNUNET_FS_uri_to_string (fi->chk_uri);
1350  else
1351  chks = NULL;
1352  if (NULL != fi->sks_uri)
1353  skss = GNUNET_FS_uri_to_string (fi->sks_uri);
1354  else
1355  skss = NULL;
1356  if ((GNUNET_OK != GNUNET_BIO_write (wh, &b, sizeof(b))) ||
1357  (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, fi->meta)) ||
1358  (GNUNET_OK != GNUNET_BIO_write_string (wh, ksks)) ||
1359  (GNUNET_OK != GNUNET_BIO_write_string (wh, chks)) ||
1360  (GNUNET_OK != GNUNET_BIO_write_string (wh, skss)) ||
1361  (GNUNET_OK != write_start_time (wh, fi->start_time)) ||
1362  (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->emsg)) ||
1363  (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->filename)) ||
1364  (GNUNET_OK !=
1369  {
1370  GNUNET_break (0);
1371  goto cleanup;
1372  }
1373  GNUNET_free_non_null (chks);
1374  chks = NULL;
1375  GNUNET_free_non_null (ksks);
1376  ksks = NULL;
1377  GNUNET_free_non_null (skss);
1378  skss = NULL;
1379 
1380  switch (b)
1381  {
1382  case 0: /* file-insert */
1383  if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size))
1384  {
1385  GNUNET_break (0);
1386  goto cleanup;
1387  }
1388  if ((GNUNET_NO == fi->is_published) && (NULL == fi->filename))
1389  if (GNUNET_OK != copy_from_reader (wh, fi))
1390  {
1391  GNUNET_break (0);
1392  goto cleanup;
1393  }
1394  break;
1395 
1396  case 1: /* file-index, no hash */
1397  if (NULL == fi->filename)
1398  {
1399  GNUNET_break (0);
1400  goto cleanup;
1401  }
1402  if (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size))
1403  {
1404  GNUNET_break (0);
1405  goto cleanup;
1406  }
1407  break;
1408 
1409  case 2: /* file-index-with-hash */
1410  case 3: /* file-index-with-hash-confirmed */
1411  if (NULL == fi->filename)
1412  {
1413  GNUNET_break (0);
1414  goto cleanup;
1415  }
1416  if ((GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) ||
1417  (GNUNET_OK != GNUNET_BIO_write (wh,
1418  &fi->data.file.file_id,
1419  sizeof(struct GNUNET_HashCode))))
1420  {
1421  GNUNET_break (0);
1422  goto cleanup;
1423  }
1424  break;
1425 
1426  case 4: /* directory */
1427  if ((NULL != fi->data.dir.entries) &&
1428  (NULL == fi->data.dir.entries->serialization))
1430  if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) ||
1431  (GNUNET_OK !=
1433  (GNUNET_OK !=
1435  (GNUNET_OK != GNUNET_BIO_write (wh,
1436  fi->data.dir.dir_data,
1437  (uint32_t) fi->data.dir.dir_size)) ||
1438  (GNUNET_OK !=
1440  (fi->data.dir.entries == NULL)
1441  ? NULL
1442  : fi->data.dir.entries->serialization)))
1443  {
1444  GNUNET_break (0);
1445  goto cleanup;
1446  }
1447  break;
1448 
1449  default:
1450  GNUNET_assert (0);
1451  goto cleanup;
1452  }
1453  if ((NULL != fi->next) && (NULL == fi->next->serialization))
1456  (fi->next != NULL)
1457  ? fi->next->serialization
1458  : NULL))
1459  {
1460  GNUNET_break (0);
1461  goto cleanup;
1462  }
1463  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
1464  {
1465  wh = NULL;
1466  GNUNET_break (0);
1467  goto cleanup;
1468  }
1469  return; /* done! */
1470 cleanup:
1471  if (NULL != wh)
1472  (void) GNUNET_BIO_write_close (wh);
1473  GNUNET_free_non_null (chks);
1474  GNUNET_free_non_null (ksks);
1475  GNUNET_free_non_null (skss);
1476  fn = get_serialization_file_name (fi->h,
1478  fi->serialization);
1479  if (NULL != fn)
1480  {
1481  if (0 != unlink (fn))
1483  GNUNET_free (fn);
1484  }
1485  GNUNET_free (fi->serialization);
1486  fi->serialization = NULL;
1487 }
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...
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:361
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m)
Write metadata container to a file.
Definition: bio.c:544
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:237
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:1312
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:286
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, int64_t i)
Write an (u)int64_t.
Definition: bio.c:599
struct GNUNET_TIME_Absolute start_time
At what time did we start this upload?
Definition: fs_api.h:279
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
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:694
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_FS_Handle * h
Handle to the master context.
Definition: fs_api.h:242
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
void * dir_data
Pointer to the data for the directory (or NULL if not available).
Definition: fs_api.h:373
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2028
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP, >1: with cover traffic).
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
Handle for buffered writing.
Definition: bio.c:379
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:263
A 512-bit hashcode.
uint64_t contents_size
Sum of all of the sizes of all of the files in the directory.
Definition: fs_api.h:383
#define GNUNET_FS_SYNC_PATH_FILE_INFO
Name of the directory with files that are being published.
Definition: fs_api.h:81
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:591
static int write_start_time(struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_TIME_Absolute timestamp)
Serialize a start-time.
Definition: fs_api.c:836
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:231
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
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:1204
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:257
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority, non-expired blocks will be kept.
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
uint64_t contents_completed
How much of the directory have we published (relative to contents_size).
Definition: fs_api.h:378
#define GNUNET_YES
Definition: gnunet_common.h:77
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: bio.c:483
int is_published
Are we done publishing this file?
Definition: fs_api.h:395
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:367
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:1276
struct GNUNET_FS_Uri * sks_uri
SKS URI for this file or directory.
Definition: fs_api.h:269
#define GNUNET_free(ptr)
Wrapper around free.
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 1706 of file fs_api.c.

References GNUNET_FS_PublishContext::all_done, cleanup(), GNUNET_FS_PublishContext::fi, GNUNET_FS_PublishContext::fi_pos, get_write_handle(), GNUNET_BIO_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_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, 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().

1707 {
1708  struct GNUNET_BIO_WriteHandle *wh;
1709  int32_t have_ns;
1710 
1711  if (NULL == pc->serialization)
1712  pc->serialization =
1714  if (NULL == pc->serialization)
1715  return;
1716  if (NULL == pc->fi)
1717  return;
1718  if (NULL == pc->fi->serialization)
1719  {
1720  GNUNET_break (0);
1721  return;
1722  }
1723  wh = get_write_handle (pc->h,
1725  pc->serialization);
1726  if (NULL == wh)
1727  {
1728  GNUNET_break (0);
1729  goto cleanup;
1730  }
1731  have_ns = (NULL != pc->ns) ? GNUNET_YES : GNUNET_NO;
1732  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nid)) ||
1733  (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nuid)) ||
1734  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->options)) ||
1735  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->all_done)) ||
1736  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, have_ns)) ||
1739  (NULL == pc->fi_pos)
1740  ? NULL
1741  : pc->fi_pos->serialization)) ||
1742  ((NULL != pc->ns) &&
1743  (GNUNET_OK !=
1744  GNUNET_BIO_write (wh,
1745  pc->ns,
1746  sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)))))
1747  {
1748  GNUNET_break (0);
1749  goto cleanup;
1750  }
1751  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
1752  {
1753  wh = NULL;
1754  GNUNET_break (0);
1755  goto cleanup;
1756  }
1757  return;
1758 cleanup:
1759  if (NULL != wh)
1760  (void) GNUNET_BIO_write_close (wh);
1763  pc->serialization);
1764  GNUNET_free (pc->serialization);
1765  pc->serialization = NULL;
1766 }
char * nid
ID of the content in the namespace, NULL if we have no namespace.
Definition: fs_api.h:1203
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:286
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
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:694
enum GNUNET_FS_PublishOptions options
Options for publishing.
Definition: fs_api.h:1274
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
char * serialization
Filename used for serializing information about this operation (should be determined using &#39;mktemp&#39;)...
Definition: fs_api.h:1214
Private ECC key encoded for transmission.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
char * nuid
ID for future updates, NULL if we have no namespace or no updates.
Definition: fs_api.h:1208
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for buffered writing.
Definition: bio.c:379
int all_done
Set to GNUNET_YES if all processing has completed.
Definition: fs_api.h:1291
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1193
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:1204
struct GNUNET_CRYPTO_EcdsaPrivateKey * ns
Namespace that we are publishing in, NULL if we have no namespace.
Definition: fs_api.h:1198
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH
Name of the directory with publishing operations.
Definition: fs_api.h:76
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
#define GNUNET_YES
Definition: gnunet_common.h:77
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: bio.c:483
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:744
#define GNUNET_free(ptr)
Wrapper around free.
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 1778 of file fs_api.c.

References GNUNET_FS_UnindexContext::chk, cleanup(), GNUNET_FS_UnindexContext::emsg, GNUNET_FS_UnindexContext::file_id, GNUNET_FS_UnindexContext::file_size, GNUNET_FS_UnindexContext::filename, get_write_handle(), GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_int64(), 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, 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().

1779 {
1780  struct GNUNET_BIO_WriteHandle *wh;
1781  char *uris;
1782 
1783  if (NULL == uc->serialization)
1784  uc->serialization =
1786  if (NULL == uc->serialization)
1787  return;
1788  wh = get_write_handle (uc->h,
1790  uc->serialization);
1791  if (NULL == wh)
1792  {
1793  GNUNET_break (0);
1794  goto cleanup;
1795  }
1796  if (NULL != uc->ksk_uri)
1797  uris = GNUNET_FS_uri_to_string (uc->ksk_uri);
1798  else
1799  uris = NULL;
1800  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uc->filename)) ||
1801  (GNUNET_OK != GNUNET_BIO_write_int64 (wh, uc->file_size)) ||
1802  (GNUNET_OK != write_start_time (wh, uc->start_time)) ||
1803  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) uc->state)) ||
1804  (GNUNET_OK !=
1805  GNUNET_BIO_write (wh, &uc->chk, sizeof(struct ContentHashKey))) ||
1806  (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
1807  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) uc->ksk_offset)) ||
1808  ((uc->state == UNINDEX_STATE_FS_NOTIFY) &&
1809  (GNUNET_OK != GNUNET_BIO_write (wh,
1810  &uc->file_id,
1811  sizeof(struct GNUNET_HashCode)))) ||
1812  ((uc->state == UNINDEX_STATE_ERROR) &&
1813  (GNUNET_OK != GNUNET_BIO_write_string (wh, uc->emsg))))
1814  {
1815  GNUNET_break (0);
1816  goto cleanup;
1817  }
1818  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
1819  {
1820  wh = NULL;
1821  GNUNET_break (0);
1822  goto cleanup;
1823  }
1824  return;
1825 cleanup:
1826  if (NULL != wh)
1827  (void) GNUNET_BIO_write_close (wh);
1830  uc->serialization);
1831  GNUNET_free (uc->serialization);
1832  uc->serialization = NULL;
1833 }
char * serialization
Short name under which we are serializing the state of this operation.
Definition: fs_api.h:1390
content hash key
Definition: fs.h:53
uint32_t ksk_offset
Current offset in KSK removal.
Definition: fs_api.h:1380
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
int GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, int64_t i)
Write an (u)int64_t.
Definition: bio.c:599
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:694
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_HashCode file_id
Hash of the file&#39;s contents (once computed).
Definition: fs_api.h:1458
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1463
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
We&#39;re notifying the FS service about the unindexing.
Definition: fs_api.h:1332
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2028
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
Definition: fs_api.h:86
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1453
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
Handle for buffered writing.
Definition: bio.c:379
We&#39;ve encountered a fatal error.
Definition: fs_api.h:1342
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1375
A 512-bit hashcode.
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
static int write_start_time(struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_TIME_Absolute timestamp)
Serialize a start-time.
Definition: fs_api.c:836
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
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:1204
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:1355
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1438
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: bio.c:483
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
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:744
#define GNUNET_free(ptr)
Wrapper around free.
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1448
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 2167 of file fs_api.c.

References GNUNET_FS_SearchContext::anonymity, cleanup(), GNUNET_FS_SearchContext::emsg, get_write_handle(), GNUNET_assert, GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_string(), GNUNET_break, GNUNET_free, GNUNET_free_non_null, 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, 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().

2168 {
2169  struct GNUNET_BIO_WriteHandle *wh;
2170  char *uris;
2171  char in_pause;
2172  const char *category;
2173 
2174  category = (NULL == sc->psearch_result) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH
2176  if (NULL == sc->serialization)
2177  sc->serialization = make_serialization_file_name (sc->h, category);
2178  if (NULL == sc->serialization)
2179  return;
2180  uris = NULL;
2181  wh = get_write_handle (sc->h, category, sc->serialization);
2182  if (NULL == wh)
2183  {
2184  GNUNET_break (0);
2185  goto cleanup;
2186  }
2189  uris = GNUNET_FS_uri_to_string (sc->uri);
2190  in_pause = (sc->task != NULL) ? 'r' : '\0';
2191  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
2192  (GNUNET_OK != write_start_time (wh, sc->start_time)) ||
2193  (GNUNET_OK != GNUNET_BIO_write_string (wh, sc->emsg)) ||
2194  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) sc->options)) ||
2195  (GNUNET_OK != GNUNET_BIO_write (wh, &in_pause, sizeof(in_pause))) ||
2197  {
2198  GNUNET_break (0);
2199  goto cleanup;
2200  }
2201  GNUNET_free (uris);
2202  uris = NULL;
2203  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
2204  {
2205  wh = NULL;
2206  GNUNET_break (0);
2207  goto cleanup;
2208  }
2209  return;
2210 cleanup:
2211  if (NULL != wh)
2212  (void) GNUNET_BIO_write_close (wh);
2213  GNUNET_free_non_null (uris);
2214  GNUNET_FS_remove_sync_file_ (sc->h, category, sc->serialization);
2215  GNUNET_free (sc->serialization);
2216  sc->serialization = NULL;
2217 }
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1335
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:1582
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:1530
enum GNUNET_FS_SearchOptions options
Options for the search.
Definition: fs_api.h:1597
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:1550
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1569
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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:694
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
Definition: fs_uri.c:1282
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
uint32_t anonymity
Anonymity level for the search.
Definition: fs_api.h:1587
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2028
char * serialization
Name of the file on disk we use for persistence.
Definition: fs_api.h:1545
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
Handle for buffered writing.
Definition: bio.c:379
#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH
Name of the directory with sub-searches (namespace-updates).
Definition: fs_api.h:59
static int write_start_time(struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_TIME_Absolute timestamp)
Serialize a start-time.
Definition: fs_api.c:836
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH
Name of the directory with top-level searches.
Definition: fs_api.h:54
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:1204
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
#define GNUNET_YES
Definition: gnunet_common.h:77
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: bio.c:483
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:744
#define GNUNET_free(ptr)
Wrapper around free.
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 2076 of file fs_api.c.

References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, cleanup(), GNUNET_FS_Uri::data, GNUNET_FS_SearchResult::download, get_write_handle_in_dir(), GNUNET_BIO_write(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_meta_data(), GNUNET_BIO_write_string(), GNUNET_break, GNUNET_free, GNUNET_free_non_null, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, GNUNET_FS_URI_KSK, GNUNET_FS_uri_to_string(), 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_download_stop(), GNUNET_FS_search_probe_progress_(), probe_failure_handler(), probe_success_handler(), process_ksk_result(), and process_sks_result().

2077 {
2078  struct GNUNET_BIO_WriteHandle *wh;
2079  char *uris;
2080 
2081  if (NULL == sr->sc)
2082  return;
2083  uris = NULL;
2084  if (NULL == sr->serialization)
2085  sr->serialization =
2087  (sr->sc->psearch_result == NULL)
2090  sr->sc->serialization);
2091  if (NULL == sr->serialization)
2092  return;
2093  wh = get_write_handle_in_dir (sr->h,
2094  (sr->sc->psearch_result == NULL)
2097  sr->sc->serialization,
2098  sr->serialization);
2099  if (NULL == wh)
2100  {
2101  GNUNET_break (0);
2102  goto cleanup;
2103  }
2104  uris = GNUNET_FS_uri_to_string (sr->uri);
2105  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
2107  (sr->download != NULL)
2108  ? sr->download->serialization
2109  : NULL)) ||
2110  (GNUNET_OK !=
2112  (sr->update_search != NULL)
2114  : NULL)) ||
2115  (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, sr->meta)) ||
2116  (GNUNET_OK !=
2117  GNUNET_BIO_write (wh, &sr->key, sizeof(struct GNUNET_HashCode))) ||
2122  {
2123  GNUNET_break (0);
2124  goto cleanup;
2125  }
2126  if ((NULL != sr->uri) && (GNUNET_FS_URI_KSK == sr->sc->uri->type) &&
2127  (GNUNET_OK !=
2128  GNUNET_BIO_write (wh,
2129  sr->keyword_bitmap,
2130  (sr->sc->uri->data.ksk.keywordCount + 7) / 8)))
2131  {
2132  GNUNET_break (0);
2133  goto cleanup;
2134  }
2135  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
2136  {
2137  wh = NULL;
2138  GNUNET_break (0);
2139  goto cleanup;
2140  }
2141  GNUNET_free_non_null (uris);
2142  return;
2143 cleanup:
2144  GNUNET_free_non_null (uris);
2145  if (NULL != wh)
2146  (void) GNUNET_BIO_write_close (wh);
2148  (NULL == sr->sc->psearch_result)
2151  sr->sc->serialization,
2152  sr->serialization);
2153  GNUNET_free (sr->serialization);
2154  sr->serialization = NULL;
2155 }
uint32_t optional_support
Number of optional keywords under which this result was also found.
Definition: fs_api.h:601
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m)
Write metadata container to a file.
Definition: bio.c:544
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:545
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:1530
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:1240
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
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:518
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:561
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:774
Keyword search key (query with keywords).
Definition: fs_api.h:153
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
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:719
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
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:551
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2028
char * serialization
Name of the file on disk we use for persistence.
Definition: fs_api.h:1545
char * serialization
Random portion of filename we use for syncing state of this download.
Definition: fs_api.h:1815
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:612
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Definition: fs_api.h:606
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
Handle for buffered writing.
Definition: bio.c:379
A 512-bit hashcode.
#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH
Name of the directory with sub-searches (namespace-updates).
Definition: fs_api.h:59
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
struct GNUNET_HashCode key
Key for the search result based on the URI.
Definition: fs_api.h:566
union GNUNET_FS_Uri::@13 data
#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH
Name of the directory with top-level searches.
Definition: fs_api.h:54
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:595
struct GNUNET_FS_Uri::@13::@14 ksk
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: bio.c:483
char * serialization
Name under which this search result is stored on disk.
Definition: fs_api.h:556
#define GNUNET_free(ptr)
Wrapper around free.
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 1972 of file fs_api.c.

References GNUNET_FS_DownloadContext::anonymity, cleanup(), GNUNET_FS_DownloadContext::completed, dir, GNUNET_FS_DownloadContext::emsg, GNUNET_FS_DownloadContext::filename, fn, get_download_sync_filename(), get_serialization_short_name(), GNUNET_assert, GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_int64(), GNUNET_BIO_write_meta_data(), GNUNET_BIO_write_open(), GNUNET_BIO_write_string(), GNUNET_break, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_mktemp(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_free_non_null, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_uri_test_chk(), GNUNET_FS_uri_test_loc(), GNUNET_FS_uri_to_string(), 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().

1973 {
1974  struct GNUNET_BIO_WriteHandle *wh;
1975  char *uris;
1976  char *fn;
1977  char *dir;
1978 
1979  if (0 != (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
1980  return; /* we don't sync probes */
1981  if (NULL == dc->serialization)
1982  {
1983  dir = get_download_sync_filename (dc, "", "");
1984  if (NULL == dir)
1985  return;
1987  {
1988  GNUNET_free (dir);
1989  return;
1990  }
1991  fn = GNUNET_DISK_mktemp (dir);
1992  GNUNET_free (dir);
1993  if (NULL == fn)
1994  return;
1996  }
1997  else
1998  {
1999  fn = get_download_sync_filename (dc, dc->serialization, "");
2000  if (NULL == fn)
2001  {
2002  GNUNET_free (dc->serialization);
2003  dc->serialization = NULL;
2004  GNUNET_free (fn);
2005  return;
2006  }
2007  }
2008  wh = GNUNET_BIO_write_open (fn);
2009  if (NULL == wh)
2010  {
2011  GNUNET_free (dc->serialization);
2012  dc->serialization = NULL;
2013  GNUNET_free (fn);
2014  return;
2015  }
2018  uris = GNUNET_FS_uri_to_string (dc->uri);
2019  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) ||
2020  (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, dc->meta)) ||
2021  (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->emsg)) ||
2022  (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->filename)) ||
2025  (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->offset)) ||
2026  (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->length)) ||
2027  (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->completed)) ||
2028  (GNUNET_OK != write_start_time (wh, dc->start_time)) ||
2029  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dc->anonymity)) ||
2030  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->options)) ||
2031  (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->has_finished)))
2032  {
2033  GNUNET_break (0);
2034  goto cleanup;
2035  }
2036  if (NULL == dc->emsg)
2037  {
2038  GNUNET_assert (dc->top_request != NULL);
2040  {
2041  GNUNET_break (0);
2042  goto cleanup;
2043  }
2044  }
2045  GNUNET_free_non_null (uris);
2046  uris = NULL;
2047  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
2048  {
2049  wh = NULL;
2050  GNUNET_break (0);
2051  goto cleanup;
2052  }
2053  GNUNET_free (fn);
2054  return;
2055 cleanup:
2056  if (NULL != wh)
2057  (void) GNUNET_BIO_write_close (wh);
2058  GNUNET_free_non_null (uris);
2059  if (0 != unlink (fn))
2061  GNUNET_free (fn);
2062  GNUNET_free (dc->serialization);
2063  dc->serialization = NULL;
2064 }
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m)
Write metadata container to a file.
Definition: bio.c:544
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
enum GNUNET_FS_DownloadOptions options
Options for the download.
Definition: fs_api.h:1922
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, int64_t i)
Write an (u)int64_t.
Definition: bio.c:599
struct DownloadRequest * top_request
Top-level download request.
Definition: fs_api.h:1855
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:684
char * filename
Where are we writing the data (name of the file, can be NULL!).
Definition: fs_api.h:1821
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
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:1828
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint64_t old_file_size
What was the size of the file on disk that we&#39;re downloading before we started? Used to detect if the...
Definition: fs_api.h:1897
int GNUNET_FS_uri_test_loc(const struct GNUNET_FS_Uri *uri)
Is this a location URI?
Definition: fs_uri.c:1395
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2028
uint64_t length
How many bytes starting from offset are desired? This is NOT the overall length of the file! ...
Definition: fs_api.h:1883
char * GNUNET_DISK_mktemp(const char *t)
Create an (empty) temporary file on disk.
Definition: disk.c:468
char * serialization
Random portion of filename we use for syncing state of this download.
Definition: fs_api.h:1815
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
Internal option used to flag this download as a &#39;probe&#39; for a search result.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
Handle for buffered writing.
Definition: bio.c:379
uint64_t offset
What is the first offset that we&#39;re interested in?
Definition: fs_api.h:1877
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
Definition: fs_uri.c:1357
char * emsg
Error message, NULL if we&#39;re doing OK.
Definition: fs_api.h:1809
int has_finished
Flag set upon transitive completion (includes child downloads).
Definition: fs_api.h:1929
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:1939
static int write_start_time(struct GNUNET_BIO_WriteHandle *wh, struct GNUNET_TIME_Absolute timestamp)
Serialize a start-time.
Definition: fs_api.c:836
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
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:1170
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open(const char *fn)
Open a file for writing.
Definition: bio.c:410
static int write_download_request(struct GNUNET_BIO_WriteHandle *wh, struct DownloadRequest *dr)
Serialize a download request.
Definition: fs_api.c:1844
uint32_t anonymity
Desired level of anonymity.
Definition: fs_api.h:1912
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
struct GNUNET_CONTAINER_MetaData * meta
Known meta-data for the file (can be NULL).
Definition: fs_api.h:1804
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_TIME_Absolute start_time
Time download was started.
Definition: fs_api.h:1902
uint64_t completed
How many bytes have we already received within the specified range (DBlocks only).
Definition: fs_api.h:1889
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
Definition: fs_api.h:1799
#define GNUNET_free(ptr)
Wrapper around free.
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 1354 of file fs_publish.c.

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

1355 {
1356  struct GNUNET_FS_PublishContext *pc = cls;
1357 
1358  if (NULL != pc->upload_task)
1359  {
1361  pc->upload_task = NULL;
1362  }
1365  suspend_operation (pc->fi, pc);
1366  GNUNET_FS_end_top (pc->h, pc->top);
1367  pc->top = NULL;
1368  publish_cleanup (pc);
1369 }
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
static void publish_cleanup(struct GNUNET_FS_PublishContext *pc)
Cleanup the publish context, we&#39;re done with it.
Definition: fs_publish.c:78
Handle for controlling a publication process.
Definition: fs_api.h:1178
static void suspend_operation(struct GNUNET_FS_FileInformation *fi, struct GNUNET_FS_PublishContext *pc)
Actually signal the FS&#39;s progress function that we are suspending an upload.
Definition: fs_publish.c:1266
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1188
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1193
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.
#define GNUNET_YES
Definition: gnunet_common.h:77
static int fip_signal_suspend(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS&#39;s progress function that we are suspending an upload.
Definition: fs_publish.c:1319
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:1298
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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
clsthe struct GNUNET_FS_SearchContext to signal for

Definition at line 1567 of file fs_search.c.

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_free_non_null, 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, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, search_result_suspend(), GNUNET_FS_SearchContext::serialization, GNUNET_FS_ProgressInfo::status, 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().

1568 {
1569  struct GNUNET_FS_SearchContext *sc = cls;
1570  struct GNUNET_FS_ProgressInfo pi;
1571  unsigned int i;
1572 
1573  GNUNET_FS_end_top (sc->h, sc->top);
1575  &search_result_suspend, sc);
1577  sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
1578  GNUNET_break (NULL == sc->client_info);
1579  if (sc->task != NULL)
1580  {
1582  sc->task = NULL;
1583  }
1584  if (NULL != sc->mq)
1585  {
1586  GNUNET_MQ_destroy (sc->mq);
1587  sc->mq = NULL;
1588  }
1590  if (NULL != sc->requests)
1591  {
1593  for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1594  {
1596  GNUNET_free (sc->requests[i].keyword);
1597  }
1598  }
1600  GNUNET_free_non_null (sc->emsg);
1601  GNUNET_FS_uri_destroy (sc->uri);
1603  GNUNET_free (sc);
1604 }
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1335
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:1582
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1519
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:1550
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
char * serialization
Name of the file on disk we use for persistence.
Definition: fs_api.h:1545
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:1558
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
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:1496
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
Last event when a search is being suspended; note that "GNUNET_FS_SEARCH_STOPPED" will not be generat...
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
union GNUNET_FS_Uri::@13 data
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_FS_Uri::@13::@14 ksk
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:1522
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
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:48
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * client_info
Pointer we keep for the client.
Definition: fs_api.h:1540
char * keyword
The original keyword, used to derive the key (for decrypting the UBlock).
Definition: fs_api.h:1486
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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
clsthe 'struct GNUNET_FS_DownloadContext' to signal for

Definition at line 1968 of file fs_download.c.

References GNUNET_FS_DownloadContext::active, GNUNET_FS_DownloadContext::child_head, GNUNET_FS_DownloadContext::child_tail, GNUNET_FS_SearchResult::download, GNUNET_FS_DownloadContext::filename, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_DISK_file_close(), GNUNET_free, GNUNET_free_non_null, GNUNET_FS_dequeue_(), GNUNET_FS_download_make_status_(), GNUNET_FS_end_top(), GNUNET_FS_free_download_request_(), 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, GNUNET_FS_DownloadContext::rfh, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::serialization, GNUNET_FS_ProgressInfo::status, 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_start(), search_result_stop(), and search_result_suspend().

1969 {
1970  struct GNUNET_FS_DownloadContext *dc = cls;
1971  struct GNUNET_FS_ProgressInfo pi;
1972 
1973  if (NULL != dc->top)
1974  GNUNET_FS_end_top (dc->h, dc->top);
1975  while (NULL != dc->child_head)
1977  if (NULL != dc->search)
1978  {
1979  dc->search->download = NULL;
1980  dc->search = NULL;
1981  }
1982  if (NULL != dc->job_queue)
1983  {
1985  dc->job_queue = NULL;
1986  }
1987  if (NULL != dc->parent)
1989  dc->parent->child_tail,
1990  dc);
1991  if (NULL != dc->task)
1992  {
1994  dc->task = NULL;
1995  }
1998  if (NULL != dc->te)
1999  {
2000  GNUNET_FS_tree_encoder_finish (dc->te, NULL);
2001  dc->te = NULL;
2002  }
2003  if (NULL != dc->rfh)
2004  {
2006  dc->rfh = NULL;
2007  }
2009  if (NULL != dc->active)
2010  {
2012  dc->active = NULL;
2013  }
2016  GNUNET_FS_uri_destroy (dc->uri);
2019  GNUNET_assert (NULL == dc->job_queue);
2020  GNUNET_free (dc);
2021 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Context for controlling a download.
Definition: fs_api.h:1742
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:545
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1747
Notification that this download was suspended.
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:103
struct GNUNET_FS_DownloadContext * child_head
Head of list of child downloads.
Definition: fs_api.h:1774
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct DownloadRequest * top_request
Top-level download request.
Definition: fs_api.h:1855
struct GNUNET_FS_DownloadContext * parent
Parent download (used when downloading files in directories).
Definition: fs_api.h:1763
char * filename
Where are we writing the data (name of the file, can be NULL!).
Definition: fs_api.h:1821
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
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:1828
void GNUNET_FS_dequeue_(struct GNUNET_FS_QueueEntry *qe)
Dequeue a job from the queue.
Definition: fs_api.c:366
char * serialization
Random portion of filename we use for syncing state of this download.
Definition: fs_api.h:1815
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
struct GNUNET_CONTAINER_MultiHashMap * active
Map of active requests (those waiting for a response).
Definition: fs_api.h:1850
struct GNUNET_FS_TreeEncoder * te
Tree encoder used for the reconstruction.
Definition: fs_api.h:1838
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1752
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
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:1871
struct GNUNET_DISK_FileHandle * rfh
File handle for reading data from an existing file (to pass to tree encoder).
Definition: fs_api.h:1844
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none...
Definition: fs_api.h:1769
void GNUNET_FS_free_download_request_(struct DownloadRequest *dr)
(recursively) free download request structure
Definition: fs_download.c:996
struct GNUNET_FS_DownloadContext * child_tail
Tail of list of child downloads.
Definition: fs_api.h:1779
struct GNUNET_CONTAINER_MetaData * meta
Known meta-data for the file (can be NULL).
Definition: fs_api.h:1804
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:1968
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:443
struct GNUNET_FS_Uri * uri
URI that identifies the file that we are downloading.
Definition: fs_api.h:1799
static struct GNUNET_FS_DownloadContext * dc
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
struct GNUNET_FS_QueueEntry * job_queue
Our entry in the job queue.
Definition: fs_api.h:1833
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 727 of file fs_unindex.c.

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_free_non_null, 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, GNUNET_FS_UnindexContext::serialization, GNUNET_FS_UnindexContext::state, GNUNET_FS_ProgressInfo::status, GNUNET_FS_UnindexContext::tc, GNUNET_FS_UnindexContext::top, uc, and UNINDEX_STATE_COMPLETE.

Referenced by deserialize_unindex_file(), and GNUNET_FS_unindex_start().

728 {
729  struct GNUNET_FS_UnindexContext *uc = cls;
730  struct GNUNET_FS_ProgressInfo pi;
731 
732  /* FIXME: lots of duplication with unindex_stop here! */
733  if (uc->dscan != NULL)
734  {
736  uc->dscan = NULL;
737  }
738  if (NULL != uc->dqe)
739  {
741  uc->dqe = NULL;
742  }
743  if (uc->fhc != NULL)
744  {
746  uc->fhc = NULL;
747  }
748  if (NULL != uc->ksk_uri)
749  {
751  uc->ksk_uri = NULL;
752  }
753  if (NULL != uc->mq)
754  {
755  GNUNET_MQ_destroy (uc->mq);
756  uc->mq = NULL;
757  }
758  if (NULL != uc->dsh)
759  {
761  uc->dsh = NULL;
762  }
763  if (NULL != uc->tc)
764  {
765  GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
766  uc->tc = NULL;
767  }
768  if (uc->fh != NULL)
769  {
771  uc->fh = NULL;
772  }
773  GNUNET_FS_end_top (uc->h, uc->top);
776  (uc->state ==
777  UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
778  GNUNET_break (NULL == uc->client_info);
779  GNUNET_free (uc->filename);
782  GNUNET_free (uc);
783 }
char * serialization
Short name under which we are serializing the state of this operation.
Definition: fs_api.h:1390
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
struct GNUNET_FS_TreeEncoder * tc
Merkle-ish tree encoder context.
Definition: fs_api.h:1412
We&#39;re done.
Definition: fs_api.h:1337
static struct GNUNET_FS_UnindexContext * uc
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Notification that we suspended unindexing a file.
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1463
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
Handle for controlling an unindexing operation.
Definition: fs_api.h:1349
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase...
Definition: fs_api.h:1402
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1443
struct TopLevelActivity * top
Our top-level activity entry.
Definition: fs_api.h:1365
struct GNUNET_DISK_FileHandle * fh
Handle used to read the file.
Definition: fs_api.h:1417
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1375
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
struct GNUNET_DATASTORE_QueueEntry * dqe
Handle to datastore &#39;get_key&#39; operation issued for obtaining KBlocks.
Definition: fs_api.h:1423
struct GNUNET_MQ_Handle * mq
Connection to the FS service, only valid during the UNINDEX_STATE_FS_NOTIFY phase.
Definition: fs_api.h:1396
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:84
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct GNUNET_FS_DirScanner * dscan
Directory scanner to find keywords (KBlock removal).
Definition: fs_api.h:1370
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1438
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:443
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1407
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1448
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 391 of file fs_api.c.

References GNUNET_CONTAINER_DLL_insert, GNUNET_new, ret, TopLevelActivity::ssf, TopLevelActivity::ssf_cls, GNUNET_FS_Handle::top_head, and GNUNET_FS_Handle::top_tail.

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

394 {
395  struct TopLevelActivity *ret;
396 
397  ret = GNUNET_new (struct TopLevelActivity);
398  ret->ssf = ssf;
399  ret->ssf_cls = ssf_cls;
401  return ret;
402 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct TopLevelActivity * top_tail
Tail of DLL of top-level activities.
Definition: fs_api.h:1098
struct TopLevelActivity * top_head
Head of DLL of top-level activities.
Definition: fs_api.h:1093
void * ssf_cls
Closure for &#39;ssf&#39; (some struct GNUNET_FS_XXXHandle*)
Definition: fs_api.h:1036
We track all of the top-level activities of FS so that we can signal &#39;suspend&#39; on shutdown...
Definition: fs_api.h:1016
SuspendSignalFunction ssf
Function to call for suspend-signalling and clean up.
Definition: fs_api.h:1031
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 412 of file fs_api.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_FS_Handle::top_head, and GNUNET_FS_Handle::top_tail.

Referenced by GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_stop(), GNUNET_FS_publish_signal_suspend_(), GNUNET_FS_publish_stop(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop(), GNUNET_FS_unindex_signal_suspend_(), and GNUNET_FS_unindex_stop().

413 {
415  GNUNET_free (top);
416 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TopLevelActivity * top_tail
Tail of DLL of top-level activities.
Definition: fs_api.h:1098
struct TopLevelActivity * top_head
Head of DLL of top-level activities.
Definition: fs_api.h:1093
#define GNUNET_free(ptr)
Wrapper around free.
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 996 of file fs_download.c.

References DownloadRequest::children, GNUNET_free, GNUNET_free_non_null, and DownloadRequest::num_children.

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

997 {
998  if (NULL == dr)
999  return;
1000  for (unsigned int i = 0; i < dr->num_children; i++)
1003  GNUNET_free (dr);
1004 }
struct DownloadRequest ** children
Array (!) of child-requests, or NULL for the bottom of the tree.
Definition: fs_api.h:1684
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
unsigned int num_children
Number of entries in children array.
Definition: fs_api.h:1702
void GNUNET_FS_free_download_request_(struct DownloadRequest *dr)
(recursively) free download request structure
Definition: fs_download.c:996
#define GNUNET_free(ptr)
Wrapper around free.
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 409 of file fs_search.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_SCHEDULER_cancel(), h, GNUNET_FS_SearchResult::h, GNUNET_FS_Handle::probe_ping_task, GNUNET_FS_Handle::probes_head, and GNUNET_FS_Handle::probes_tail.

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

410 {
411  struct GNUNET_FS_Handle *h = sr->h;
412 
414  h->probes_tail,
415  sr);
416  if (NULL == h->probes_head)
417  {
419  h->probe_ping_task = NULL;
420  }
421 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Master context for most FS operations.
Definition: fs_api.h:1068
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
struct GNUNET_SCHEDULER_Task * probe_ping_task
Task we use to report periodically to the application that certain search probes (from probes_head) a...
Definition: fs_api.h:1140
struct GNUNET_FS_SearchResult * probes_head
Head of active probes.
Definition: fs_api.h:1123
struct GNUNET_FS_SearchResult * probes_tail
Tail of active probes.
Definition: fs_api.h:1128
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function: