GNUnet  0.11.x
Functions
fs_publish.c File Reference

publish a file or directory in GNUnet More...

#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_util_lib.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_tree.h"
Include dependency graph for fs_publish.c:

Go to the source code of this file.

Functions

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...
 
static void publish_cleanup (struct GNUNET_FS_PublishContext *pc)
 Cleanup the publish context, we're done with it. More...
 
static void ds_put_cont (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
 Function called by the datastore API with the result from the PUT request. More...
 
static void signal_publish_completion (struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc)
 Generate the callback that signals clients that a file (or directory) has been completely published. More...
 
static void signal_publish_error (struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc, const char *emsg)
 Generate the callback that signals clients that a file (or directory) has encountered a problem during publication. More...
 
static void finish_release_reserve (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
 Datastore returns from reservation cancel request. More...
 
static void publish_sblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
 We've finished publishing the SBlock as part of a larger upload. More...
 
static void publish_sblock (struct GNUNET_FS_PublishContext *pc)
 We are almost done publishing the structure, add SBlocks (if needed). More...
 
static void publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
 We've finished publishing a KBlock as part of a larger upload. More...
 
static size_t block_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 tree). More...
 
static void encode_cont (void *cls)
 The tree encoder has finished processing a file. More...
 
static void block_proc (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. More...
 
static void progress_proc (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. More...
 
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. More...
 
static int check_index_start_failed (void *cls, const struct GNUNET_MessageHeader *msg)
 Check the response from the "fs" service to our 'start index' request. More...
 
static void handle_index_start_failed (void *cls, const struct GNUNET_MessageHeader *msg)
 Process the response from the "fs" service to our 'start index' request. More...
 
static void handle_index_start_ok (void *cls, const struct GNUNET_MessageHeader *msg)
 Process the response from the "fs" service to our 'start index' request. More...
 
static void index_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
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. More...
 
static void publish_kblocks (struct GNUNET_FS_PublishContext *pc)
 We've computed the CHK/LOC URI, now publish the KSKs (if applicable). More...
 
static void handle_signature_response (void *cls, const struct ResponseLocSignatureMessage *sig)
 Process the response from the "fs" service to our LOC sign request. More...
 
static void loc_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void create_loc_uri (struct GNUNET_FS_PublishContext *pc)
 We're publishing without anonymity. More...
 
void GNUNET_FS_publish_main_ (void *cls)
 Main function that performs the upload. More...
 
static int fip_signal_start (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's progress function that we are starting an upload. More...
 
static void suspend_operation (struct GNUNET_FS_FileInformation *fi, struct GNUNET_FS_PublishContext *pc)
 Actually signal the FS's progress function that we are suspending an upload. More...
 
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's progress function that we are suspending an upload. 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...
 
static void finish_reserve (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
 We have gotten a reply for our space reservation request. More...
 
static uint64_t compute_contents_size (struct GNUNET_FS_FileInformation *fi)
 Calculate the total size of all of the files in the directory structure. More...
 
struct GNUNET_FS_PublishContextGNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, struct GNUNET_FS_FileInformation *fi, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *nid, const char *nuid, enum GNUNET_FS_PublishOptions options)
 Publish a file or directory. More...
 
static int fip_signal_stop (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's progress function that we are stopping an upload. More...
 
void GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc)
 Stop an upload. More...
 

Detailed Description

publish a file or directory in GNUnet

See also
https://gnunet.org/encoding
Author
Krista Bennett
Christian Grothoff

Definition in file fs_publish.c.

Function Documentation

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

◆ publish_cleanup()

static void publish_cleanup ( struct GNUNET_FS_PublishContext pc)
static

Cleanup the publish context, we're done with it.

Parameters
pcstruct to clean up

Definition at line 78 of file fs_publish.c.

References GNUNET_FS_PublishContext::dsh, GNUNET_FS_PublishContext::fhc, GNUNET_FS_PublishContext::fi, GNUNET_assert, GNUNET_CRYPTO_hash_file_cancel(), GNUNET_DATASTORE_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_FS_file_information_destroy(), GNUNET_log, GNUNET_MQ_destroy(), GNUNET_NO, GNUNET_FS_PublishContext::mq, GNUNET_FS_PublishContext::nid, GNUNET_FS_PublishContext::nuid, GNUNET_FS_PublishContext::serialization, and GNUNET_FS_PublishContext::upload_task.

Referenced by GNUNET_FS_publish_signal_suspend_(), and GNUNET_FS_publish_stop().

79 {
81  "Cleaning up publish context (done!)\n");
82  if (NULL != pc->fhc)
83  {
85  pc->fhc = NULL;
86  }
87  GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL);
91  if (NULL != pc->dsh)
92  {
94  pc->dsh = NULL;
95  }
96  if (NULL != pc->mq)
97  {
98  GNUNET_MQ_destroy (pc->mq);
99  pc->mq = NULL;
100  }
101  GNUNET_assert (NULL == pc->upload_task);
102  GNUNET_free (pc);
103 }
char * nid
ID of the content in the namespace, NULL if we have no namespace.
Definition: fs_api.h:1203
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#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
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service.
Definition: fs_api.h:1235
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * serialization
Filename used for serializing information about this operation (should be determined using 'mktemp')...
Definition: fs_api.h:1214
char * nuid
ID for future updates, NULL if we have no namespace or no updates.
Definition: fs_api.h:1208
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file...
Definition: fs_api.h:1220
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1193
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
#define GNUNET_log(kind,...)
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ds_put_cont()

static void ds_put_cont ( void *  cls,
int  success,
struct GNUNET_TIME_Absolute  min_expiration,
const char *  msg 
)
static

Function called by the datastore API with the result from the PUT request.

Parameters
clsthe struct GNUNET_FS_PublishContext *
successGNUNET_OK on success
min_expirationminimum expiration time required for content to be stored
msgerror message (or NULL)

Definition at line 116 of file fs_publish.c.

References _, GNUNET_FS_PublishContext::any_done, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::emsg, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_FS_publish_main_(), GNUNET_FS_publish_make_status_(), GNUNET_FS_STATUS_PUBLISH_ERROR, GNUNET_FS_unindex_start(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GNUNET_FS_PublishContext::h, GNUNET_FS_FileInformation::is_directory, pc, GNUNET_FS_ProgressInfo::publish, GNUNET_FS_PublishContext::qre, GNUNET_FS_ProgressInfo::status, GNUNET_FS_PublishContext::upload_task, and GNUNET_FS_ProgressInfo::value.

Referenced by block_proc().

120 {
121  struct GNUNET_FS_PublishContext *pc = cls;
122  struct GNUNET_FS_ProgressInfo pi;
123 
124  pc->qre = NULL;
125  if (GNUNET_SYSERR == success)
126  {
127  GNUNET_asprintf (&pc->fi_pos->emsg,
128  _ ("Publishing failed: %s"),
129  msg);
131  pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
132  pi.value.publish.specifics.error.message = pc->fi_pos->emsg;
133  pc->fi_pos->client_info =
135  if ((GNUNET_YES != pc->fi_pos->is_directory) &&
136  (NULL != pc->fi_pos->filename) &&
137  (GNUNET_YES == pc->any_done) &&
138  (GNUNET_YES == pc->fi_pos->data.file.do_index))
139  {
140  /* run unindex to clean up */
142  pc->fi_pos->filename,
143  NULL);
144  }
145  return;
146  }
147  pc->any_done = GNUNET_YES;
148  GNUNET_assert (NULL == pc->upload_task);
149  pc->upload_task =
152 }
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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
Run as background job (higher than idle, lower than default).
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1062
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1207
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
struct GNUNET_FS_UnindexContext * GNUNET_FS_unindex_start(struct GNUNET_FS_Handle *h, const char *filename, void *cctx)
Unindex a file.
Definition: fs_unindex.c:795
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
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
Notification that an error was encountered sharing a file structure.
#define GNUNET_YES
Definition: gnunet_common.h:77
int any_done
Set to GNUNET_YES if we were able to publish any block.
Definition: fs_api.h:1286
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:

◆ signal_publish_completion()

static void signal_publish_completion ( struct GNUNET_FS_FileInformation p,
struct GNUNET_FS_PublishContext pc 
)
static

Generate the callback that signals clients that a file (or directory) has been completely published.

Parameters
pthe completed upload
pccontext of the publication

Definition at line 164 of file fs_publish.c.

References GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::file, GNUNET_FS_publish_make_status_(), GNUNET_FS_STATUS_PUBLISH_COMPLETED, GNUNET_TIME_UNIT_ZERO, GNUNET_FS_ProgressInfo::publish, GNUNET_FS_FileInformation::sks_uri, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.

Referenced by finish_release_reserve(), and publish_kblocks_cont().

166 {
167  struct GNUNET_FS_ProgressInfo pi;
168 
170  pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO;
171  pi.value.publish.specifics.completed.chk_uri = p->chk_uri;
172  pi.value.publish.specifics.completed.sks_uri = p->sks_uri;
173  p->client_info =
175  p->data.file.file_size);
176 }
void * client_info
Pointer kept for the client.
Definition: fs_api.h:247
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:263
Notification that we completed sharing a file structure.
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
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_FS_Uri * sks_uri
SKS URI for this file or directory.
Definition: fs_api.h:269
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:

◆ signal_publish_error()

static void signal_publish_error ( struct GNUNET_FS_FileInformation p,
struct GNUNET_FS_PublishContext pc,
const char *  emsg 
)
static

Generate the callback that signals clients that a file (or directory) has encountered a problem during publication.

Parameters
pthe upload that had trouble
pccontext of the publication
emsgerror message

Definition at line 189 of file fs_publish.c.

References GNUNET_FS_PublishContext::any_done, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::emsg, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::filename, GNUNET_FS_publish_make_status_(), GNUNET_FS_STATUS_PUBLISH_ERROR, GNUNET_FS_unindex_start(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GNUNET_FS_PublishContext::h, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_ProgressInfo::publish, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.

Referenced by finish_reserve(), handle_index_start_failed(), publish_kblocks_cont(), and publish_sblocks_cont().

192 {
193  struct GNUNET_FS_ProgressInfo pi;
194 
195  p->emsg = GNUNET_strdup (emsg);
197  pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
198  pi.value.publish.specifics.error.message = emsg;
200  if ((p->is_directory != GNUNET_YES) &&
201  (NULL != p->filename) &&
202  (GNUNET_YES == pc->any_done) &&
203  (p->data.file.do_index == GNUNET_YES))
204  {
205  /* run unindex to clean up */
207  p->filename,
208  NULL);
209  }
210 }
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
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.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
struct GNUNET_FS_UnindexContext * GNUNET_FS_unindex_start(struct GNUNET_FS_Handle *h, const char *filename, void *cctx)
Unindex a file.
Definition: fs_unindex.c:795
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".
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
Notification that an error was encountered sharing a file structure.
#define GNUNET_YES
Definition: gnunet_common.h:77
int any_done
Set to GNUNET_YES if we were able to publish any block.
Definition: fs_api.h:1286
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:

◆ finish_release_reserve()

static void finish_release_reserve ( void *  cls,
int  success,
struct GNUNET_TIME_Absolute  min_expiration,
const char *  msg 
)
static

Datastore returns from reservation cancel request.

Parameters
clsthe struct GNUNET_FS_PublishContext *
successsuccess code (not used)
min_expirationminimum expiration time required for content to be stored
msgerror message (typically NULL, not used)

Definition at line 222 of file fs_publish.c.

References GNUNET_FS_PublishContext::all_done, GNUNET_FS_PublishContext::fi, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_publish_sync_(), GNUNET_log, GNUNET_YES, pc, GNUNET_FS_PublishContext::qre, and signal_publish_completion().

Referenced by publish_sblocks_cont().

225 {
226  struct GNUNET_FS_PublishContext *pc = cls;
227 
228  pc->qre = NULL;
230  "Releasing reserve done!\n");
231  signal_publish_completion (pc->fi, pc);
232  pc->all_done = GNUNET_YES;
234 }
static void signal_publish_completion(struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc)
Generate the callback that signals clients that a file (or directory) has been completely published...
Definition: fs_publish.c:164
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1706
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
int all_done
Set to GNUNET_YES if all processing has completed.
Definition: fs_api.h:1291
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
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_sblocks_cont()

static void publish_sblocks_cont ( void *  cls,
const struct GNUNET_FS_Uri uri,
const char *  emsg 
)
static

We've finished publishing the SBlock as part of a larger upload.

Check the result and complete the larger upload.

Parameters
clsthe struct GNUNET_FS_PublishContext * of the larger upload
uriURI of the published SBlock
emsgNULL on success, otherwise error message

Definition at line 246 of file fs_publish.c.

References GNUNET_FS_PublishContext::dsh, GNUNET_FS_PublishContext::fi, finish_release_reserve(), GNUNET_assert, GNUNET_DATASTORE_release_reserve(), GNUNET_FS_publish_sync_(), GNUNET_FS_uri_dup(), GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, pc, GNUNET_FS_PublishContext::qre, GNUNET_FS_PublishContext::rid, signal_publish_error(), GNUNET_FS_PublishContext::sks_pc, and GNUNET_FS_FileInformation::sks_uri.

Referenced by publish_sblock().

249 {
250  struct GNUNET_FS_PublishContext *pc = cls;
251 
252  pc->sks_pc = NULL;
253  if (NULL != emsg)
254  {
255  signal_publish_error (pc->fi, pc, emsg);
257  return;
258  }
259  if (NULL != uri)
260  {
261  /* sks publication, remember namespace URI */
262  pc->fi->sks_uri = GNUNET_FS_uri_dup (uri);
263  }
264  GNUNET_assert (pc->qre == NULL);
265  if ((pc->dsh != NULL) && (pc->rid != 0))
266  {
267  pc->qre =
268  GNUNET_DATASTORE_release_reserve (pc->dsh, pc->rid, UINT_MAX, UINT_MAX,
270  }
271  else
272  {
274  }
275 }
int rid
Space reservation ID with datastore service for this upload.
Definition: fs_api.h:1280
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
static void finish_release_reserve(void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Datastore returns from reservation cancel request.
Definition: fs_publish.c:222
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service.
Definition: fs_api.h:1235
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_release_reserve(struct GNUNET_DATASTORE_Handle *h, uint32_t rid, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Signal that all of the data for which a reservation was made has been stored and that whatever excess...
static void signal_publish_error(struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc, const char *emsg)
Generate the callback that signals clients that a file (or directory) has encountered a problem durin...
Definition: fs_publish.c:189
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1706
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
struct GNUNET_FS_PublishSksContext * sks_pc
Context for SKS publishing operation that is part of this publishing operation (NULL if not active)...
Definition: fs_api.h:1246
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
struct GNUNET_FS_Uri * sks_uri
SKS URI for this file or directory.
Definition: fs_api.h:269
Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_sblock()

static void publish_sblock ( struct GNUNET_FS_PublishContext pc)
static

We are almost done publishing the structure, add SBlocks (if needed).

Parameters
pcoverall upload data

Definition at line 285 of file fs_publish.c.

References GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_PublishContext::fi, GNUNET_FS_publish_sks(), GNUNET_FS_PublishContext::h, GNUNET_FS_FileInformation::meta, GNUNET_FS_PublishContext::nid, GNUNET_FS_PublishContext::ns, GNUNET_FS_PublishContext::nuid, GNUNET_FS_PublishContext::options, publish_sblocks_cont(), and GNUNET_FS_PublishContext::sks_pc.

Referenced by GNUNET_FS_publish_main_().

286 {
287  if (NULL != pc->ns)
288  pc->sks_pc = GNUNET_FS_publish_sks (pc->h,
289  pc->ns,
290  pc->nid,
291  pc->nuid,
292  pc->fi->meta,
293  pc->fi->chk_uri,
294  &pc->fi->bo,
295  pc->options,
296  &publish_sblocks_cont, pc);
297  else
298  publish_sblocks_cont (pc, NULL, NULL);
299 }
char * nid
ID of the content in the namespace, NULL if we have no namespace.
Definition: fs_api.h:1203
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
struct GNUNET_FS_PublishSksContext * GNUNET_FS_publish_sks(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *identifier, const char *update, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish an SBlock on GNUnet.
Definition: fs_namespace.c:433
enum GNUNET_FS_PublishOptions options
Options for publishing.
Definition: fs_api.h:1274
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
char * nuid
ID for future updates, NULL if we have no namespace or no updates.
Definition: fs_api.h:1208
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:263
struct GNUNET_FS_PublishSksContext * sks_pc
Context for SKS publishing operation that is part of this publishing operation (NULL if not active)...
Definition: fs_api.h:1246
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1193
struct GNUNET_CRYPTO_EcdsaPrivateKey * ns
Namespace that we are publishing in, NULL if we have no namespace.
Definition: fs_api.h:1198
static void publish_sblocks_cont(void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
We've finished publishing the SBlock as part of a larger upload.
Definition: fs_publish.c:246
Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish_kblocks_cont()

static void publish_kblocks_cont ( void *  cls,
const struct GNUNET_FS_Uri uri,
const char *  emsg 
)
static

We've finished publishing a KBlock as part of a larger upload.

Check the result and continue the larger upload.

Parameters
clsthe struct GNUNET_FS_PublishContext * of the larger upload
uriURI of the published blocks
emsgNULL on success, otherwise error message

Definition at line 312 of file fs_publish.c.

References GNUNET_FS_FileInformation::dir, GNUNET_FS_PublishContext::fi_pos, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_main_(), GNUNET_FS_publish_sync_(), GNUNET_log, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_FS_PublishContext::ksk_pc, GNUNET_FS_FileInformation::next, p, pc, signal_publish_completion(), signal_publish_error(), and GNUNET_FS_PublishContext::upload_task.

Referenced by publish_kblocks().

315 {
316  struct GNUNET_FS_PublishContext *pc = cls;
317  struct GNUNET_FS_FileInformation *p = pc->fi_pos;
318 
319  pc->ksk_pc = NULL;
320  if (NULL != emsg)
321  {
323  "Error uploading KSK blocks: %s\n",
324  emsg);
325  signal_publish_error (p, pc, emsg);
328  GNUNET_assert (NULL == pc->upload_task);
329  pc->upload_task =
333  pc);
334  return;
335  }
337  "KSK blocks published, moving on to next file\n");
338  if (NULL != p->dir)
340  /* move on to next file */
341  if (NULL != p->next)
342  pc->fi_pos = p->next;
343  else
344  pc->fi_pos = p->dir;
346  GNUNET_assert (NULL == pc->upload_task);
347  pc->upload_task =
350 }
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
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
static void signal_publish_completion(struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc)
Generate the callback that signals clients that a file (or directory) has been completely published...
Definition: fs_publish.c:164
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
Run as background job (higher than idle, lower than default).
static void signal_publish_error(struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc, const char *emsg)
Generate the callback that signals clients that a file (or directory) has encountered a problem durin...
Definition: fs_publish.c:189
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1062
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1706
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1207
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
struct GNUNET_FS_PublishKskContext * ksk_pc
Context for KSK publishing operation that is part of this publishing operation (NULL if not active)...
Definition: fs_api.h:1252
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:231
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ block_reader()

static size_t block_reader ( void *  cls,
uint64_t  offset,
size_t  max,
void *  buf,
char **  emsg 
)
static

Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the tree).

Parameters
clsour publishing context
offsetidentifies which block to get
max(maximum) number of bytes to get; returning fewer will also cause errors
bufwhere to copy the plaintext buffer
emsglocation to store an error message (on error)
Returns
number of bytes copied to buf, 0 on error

Definition at line 367 of file fs_publish.c.

References GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_data, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::file, GNUNET_FS_data_reader_file_(), GNUNET_memcpy, GNUNET_MIN, GNUNET_YES, GNUNET_FS_FileInformation::is_directory, p, and pc.

Referenced by publish_content().

372 {
373  struct GNUNET_FS_PublishContext *pc = cls;
375  const char *dd;
376  size_t pt_size;
377 
378  p = pc->fi_pos;
379  if (GNUNET_YES == p->is_directory)
380  {
381  pt_size = GNUNET_MIN (max, p->data.dir.dir_size - offset);
382  dd = p->data.dir.dir_data;
383  GNUNET_memcpy (buf, &dd[offset], pt_size);
384  }
385  else
386  {
387  if (UINT64_MAX == offset)
388  {
389  if (&GNUNET_FS_data_reader_file_ == p->data.file.reader)
390  {
391  /* force closing the file to avoid keeping too many files open */
392  p->data.file.reader (p->data.file.reader_cls, offset, 0, NULL, NULL);
393  }
394  return 0;
395  }
396  pt_size = GNUNET_MIN (max, p->data.file.file_size - offset);
397  if (0 == pt_size)
398  return 0; /* calling reader with pt_size==0
399  * might free buf, so don't! */
400  if (pt_size !=
401  p->data.file.reader (p->data.file.reader_cls, offset, pt_size, buf,
402  emsg))
403  return 0;
404  }
405  return pt_size;
406 }
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
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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.
Definition: fs_api.c:457
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
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
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
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:80
static char buf[2048]
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#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:

◆ encode_cont()

static void encode_cont ( void *  cls)
static

The tree encoder has finished processing a file.

Call it's finish method and deal with the final result.

Parameters
clsour publishing context

Definition at line 417 of file fs_publish.c.

References _, GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_FileInformation::client_info, GNUNET_FS_FileInformation::emsg, GNUNET_FS_PublishContext::fi_pos, GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_FS_compute_depth(), GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_main_(), GNUNET_FS_publish_make_status_(), GNUNET_FS_STATUS_PUBLISH_ERROR, GNUNET_FS_STATUS_PUBLISH_PROGRESS, GNUNET_FS_tree_encoder_finish(), GNUNET_FS_tree_encoder_get_uri(), GNUNET_FS_uri_chk_get_file_size(), GNUNET_log, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_TIME_UNIT_FOREVER_REL, p, pc, GNUNET_FS_ProgressInfo::publish, GNUNET_FS_ProgressInfo::status, GNUNET_FS_FileInformation::te, GNUNET_FS_PublishContext::upload_task, and GNUNET_FS_ProgressInfo::value.

Referenced by publish_content().

418 {
419  struct GNUNET_FS_PublishContext *pc = cls;
421  struct GNUNET_FS_ProgressInfo pi;
422  char *emsg;
423  uint64_t flen;
424 
426  "Finished with tree encoder\n");
427  p = pc->fi_pos;
430  GNUNET_FS_tree_encoder_finish (p->te, &emsg);
431  p->te = NULL;
432  if (NULL != emsg)
433  {
435  "Error during tree walk: %s\n",
436  emsg);
437  GNUNET_asprintf (&p->emsg,
438  _ ("Publishing failed: %s"),
439  emsg);
440  GNUNET_free (emsg);
442  pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
443  pi.value.publish.specifics.error.message = p->emsg;
445  }
446  else
447  {
448  /* final progress event */
449  GNUNET_assert (NULL != p->chk_uri);
452  pi.value.publish.specifics.progress.data = NULL;
453  pi.value.publish.specifics.progress.offset = flen;
454  pi.value.publish.specifics.progress.data_len = 0;
455  pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen);
456  p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, flen);
457  }
458  /* continue with main */ /* continue with main */
459  GNUNET_assert (NULL == pc->upload_task);
460  pc->upload_task =
463 }
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
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
Notification that we are making progress sharing a file structure.
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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
Run as background job (higher than idle, lower than default).
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_FS_Uri * GNUNET_FS_tree_encoder_get_uri(struct GNUNET_FS_TreeEncoder *te)
Get the resulting URI from the encoding.
Definition: fs_tree.c:424
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1062
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
unsigned int GNUNET_FS_compute_depth(uint64_t flen)
Compute the depth of the CHK tree.
Definition: fs_tree.c:125
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_FS_TreeEncoder * te
Encoder being used to publish this file.
Definition: fs_api.h:291
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1207
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
#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
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
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
Notification that an error was encountered sharing a file structure.
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,...)
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
#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:

◆ block_proc()

static void block_proc ( void *  cls,
const struct ContentHashKey chk,
uint64_t  offset,
unsigned int  depth,
enum GNUNET_BLOCK_Type  type,
const void *  block,
uint16_t  block_size 
)
static

Function called asking for the current (encoded) block to be processed.

After processing the client should either call GNUNET_FS_tree_encoder_next or (on error) GNUNET_FS_tree_encoder_finish.

Parameters
clsclosure
chkcontent hash key for the block
offsetoffset of the block in the file
depthdepth of the block in the file, 0 for DBLOCK
typetype of the block (IBLOCK or DBLOCK)
blockthe (encrypted) block
block_sizesize of block (in bytes)

Definition at line 481 of file fs_publish.c.

References ds_put_cont(), GNUNET_FS_PublishContext::dsh, GNUNET_FS_PublishContext::fi_pos, OnDemandBlock::file_id, GNUNET_assert, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_BLOCK_TYPE_FS_ONDEMAND, GNUNET_DATASTORE_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_publish_main_(), GNUNET_h2s(), GNUNET_htonll(), GNUNET_log, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_YES, OnDemandBlock::offset, p, pc, GNUNET_FS_PublishContext::qre, ContentHashKey::query, GNUNET_FS_PublishContext::rid, and GNUNET_FS_PublishContext::upload_task.

Referenced by publish_content().

488 {
489  struct GNUNET_FS_PublishContext *pc = cls;
491  struct OnDemandBlock odb;
492 
493  p = pc->fi_pos;
494  if (NULL == pc->dsh)
495  {
497  "Waiting for datastore connection\n");
498  GNUNET_assert (NULL == pc->upload_task);
499  pc->upload_task =
502  return;
503  }
504 
505  if ((GNUNET_YES != p->is_directory) &&
506  (GNUNET_YES == p->data.file.do_index) &&
508  {
510  "Indexing block `%s' for offset %llu with index size %u\n",
511  GNUNET_h2s (&chk->query),
512  (unsigned long long) offset,
513  (unsigned int) sizeof(struct OnDemandBlock));
514  odb.offset = GNUNET_htonll (offset);
515  odb.file_id = p->data.file.file_id;
516  GNUNET_assert (pc->qre == NULL);
517  pc->qre =
519  (p->is_directory == GNUNET_YES) ? 0 : pc->rid,
520  &chk->query,
521  sizeof(struct OnDemandBlock),
522  &odb,
524  p->bo.content_priority,
525  p->bo.anonymity_level,
526  p->bo.replication_level,
527  p->bo.expiration_time,
528  -2, 1,
529  &ds_put_cont, pc);
530  return;
531  }
533  "Publishing block `%s' for offset %llu with size %u\n",
534  GNUNET_h2s (&chk->query),
535  (unsigned long long) offset,
536  (unsigned int) block_size);
537  GNUNET_assert (pc->qre == NULL);
538  pc->qre =
539  GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 :
540  pc->rid,
541  &chk->query,
542  block_size,
543  block,
544  type,
545  p->bo.content_priority,
546  p->bo.anonymity_level,
547  p->bo.replication_level,
548  p->bo.expiration_time,
549  -2, 1,
550  &ds_put_cont,
551  pc);
552 }
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
int rid
Space reservation ID with datastore service for this upload.
Definition: fs_api.h:1280
static void ds_put_cont(void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Function called by the datastore API with the result from the PUT request.
Definition: fs_publish.c:116
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_put(struct GNUNET_DATASTORE_Handle *h, uint32_t rid, 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, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the datastore.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service.
Definition: fs_api.h:1235
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
Run as background job (higher than idle, lower than default).
Type of a block representing a block to be encoded on demand from disk.
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1062
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1207
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Definition: fs.h:63
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#define GNUNET_log(kind,...)
uint64_t offset
At which offset should we be able to find this on-demand encoded block? (in NBO)
Definition: block_fs.h:94
Data block (leaf) in the CHK tree.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
index block (indexing a DBlock that can be obtained directly from reading the plaintext file) ...
Definition: block_fs.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ progress_proc()

static void progress_proc ( void *  cls,
uint64_t  offset,
const void *  pt_block,
size_t  pt_size,
unsigned int  depth 
)
static

Function called with information about our progress in computing the tree encoding.

Parameters
clsclosure
offsetwhere are we in the file
pt_blockplaintext of the currently processed block
pt_sizesize of pt_block
depthdepth of the block in the tree, 0 for DBLOCK

Definition at line 566 of file fs_publish.c.

References GNUNET_FS_ProgressInfo::depth, GNUNET_FS_FileInformation::dir, GNUNET_FS_PublishContext::fi_pos, GNUNET_assert, GNUNET_FS_publish_make_status_(), GNUNET_FS_STATUS_PUBLISH_PROGRESS, GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY, GNUNET_TIME_calculate_eta(), GNUNET_YES, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_ProgressInfo::offset, p, pc, GNUNET_FS_ProgressInfo::publish, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.

Referenced by publish_content().

570 {
571  struct GNUNET_FS_PublishContext *pc = cls;
573  struct GNUNET_FS_FileInformation *par;
574  struct GNUNET_FS_ProgressInfo pi;
575 
576  p = pc->fi_pos;
578  pi.value.publish.specifics.progress.data = pt_block;
579  pi.value.publish.specifics.progress.offset = offset;
580  pi.value.publish.specifics.progress.data_len = pt_size;
581  pi.value.publish.specifics.progress.depth = depth;
582  p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, offset);
583  if ((0 != depth) ||
584  (GNUNET_YES == p->is_directory))
585  return;
586  while (NULL != (par = p->dir))
587  {
588  p = par;
590  p->data.dir.contents_completed += pt_size;
592  pi.value.publish.specifics.progress_directory.completed =
593  p->data.dir.contents_completed;
594  pi.value.publish.specifics.progress_directory.total =
595  p->data.dir.contents_size;
596  pi.value.publish.specifics.progress_directory.eta =
597  GNUNET_TIME_calculate_eta (p->start_time,
598  p
599  ->data.dir.contents_completed,
600  p
601  ->data.dir.contents_size);
602  p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
603  }
604 }
unsigned int depth
Depth of the given block in the tree; 0 would be the lowest level (DBLOCKs).
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
Notification that we are making progress sharing a file structure.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint64_t offset
At what offset in the file is "data"?
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
Notification that we are making progress sharing a directory.
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
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
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
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
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:

◆ publish_content()

static void publish_content ( struct GNUNET_FS_PublishContext pc)
static

We are uploading a file or directory; load (if necessary) the next block into memory, encrypt it and send it to the FS service.

Then continue with the main task.

Parameters
pcoverall upload data

Definition at line 615 of file fs_publish.c.

References block_proc(), block_reader(), GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_FileInformation::data, db, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_data, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_FileInformation::emsg, encode_cont(), GNUNET_FS_FileInformation::entries, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::file, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_builder_create(), GNUNET_FS_directory_builder_finish(), GNUNET_FS_file_information_sync_(), GNUNET_FS_tree_encoder_create(), GNUNET_FS_tree_encoder_next(), GNUNET_log, GNUNET_malloc, GNUNET_YES, GNUNET_FS_PublishContext::h, GNUNET_FS_FileInformation::is_directory, MAX_INLINE_SIZE, GNUNET_FS_FileInformation::meta, GNUNET_FS_FileInformation::next, p, progress_proc(), size, and GNUNET_FS_FileInformation::te.

Referenced by GNUNET_FS_publish_main_(), handle_index_start_ok(), hash_for_index_cb(), and index_mq_error_handler().

616 {
618  char *emsg;
620  struct GNUNET_FS_FileInformation *dirpos;
621  void *raw_data;
622  uint64_t size;
623 
624  p = pc->fi_pos;
625  GNUNET_assert (NULL != p);
626  if (NULL == p->te)
627  {
628  if (GNUNET_YES == p->is_directory)
629  {
630  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n");
632  dirpos = p->data.dir.entries;
633  while (NULL != dirpos)
634  {
635  if (GNUNET_YES == dirpos->is_directory)
636  {
637  raw_data = dirpos->data.dir.dir_data;
638  dirpos->data.dir.dir_data = NULL;
639  }
640  else
641  {
642  raw_data = NULL;
643  if ((dirpos->data.file.file_size < MAX_INLINE_SIZE) &&
644  (dirpos->data.file.file_size > 0))
645  {
646  raw_data = GNUNET_malloc (dirpos->data.file.file_size);
647  emsg = NULL;
648  if (dirpos->data.file.file_size !=
649  dirpos->data.file.reader (dirpos->data.file.reader_cls, 0,
650  dirpos->data.file.file_size, raw_data,
651  &emsg))
652  {
653  GNUNET_free_non_null (emsg);
654  GNUNET_free (raw_data);
655  raw_data = NULL;
656  }
657  dirpos->data.file.reader (dirpos->data.file.reader_cls, UINT64_MAX,
658  0, 0, NULL);
659  }
660  }
661  GNUNET_FS_directory_builder_add (db, dirpos->chk_uri, dirpos->meta,
662  raw_data);
663  GNUNET_free_non_null (raw_data);
664  dirpos = dirpos->next;
665  }
667  p->data.dir.dir_data = NULL;
668  p->data.dir.dir_size = 0;
670  &p->data.dir.dir_data);
672  }
673  size = (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size :
674  p->data.file.file_size;
676  "Creating tree encoder\n");
677  p->te =
680  &encode_cont);
681  }
683  "Processing next block from tree\n");
685 }
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:361
int GNUNET_FS_directory_builder_finish(struct GNUNET_FS_DirectoryBuilder *bld, size_t *rsize, void **rdata)
Finish building the directory.
Definition: fs_directory.c:577
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
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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
Internal state of a directory builder.
Definition: fs_directory.c:340
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
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
#define MAX_INLINE_SIZE
Maximum size for a file to be considered for inlining in a directory.
Definition: fs_api.h:49
void GNUNET_FS_directory_builder_add(struct GNUNET_FS_DirectoryBuilder *bld, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *md, const void *data)
Add an entry to a directory.
Definition: fs_directory.c:391
struct GNUNET_FS_TreeEncoder * te
Encoder being used to publish this file.
Definition: fs_api.h:291
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static void progress_proc(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_publish.c:566
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_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
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
static size_t block_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_publish.c:367
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:231
static struct GNUNET_FS_DirectoryBuilder * db
Definition: gnunet-search.c:41
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
static void block_proc(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_publish.c:481
struct GNUNET_FS_DirectoryBuilder * GNUNET_FS_directory_builder_create(const struct GNUNET_CONTAINER_MetaData *mdir)
Create a directory builder.
Definition: fs_directory.c:365
static void encode_cont(void *cls)
The tree encoder has finished processing a file.
Definition: fs_publish.c:417
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
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_index_start_failed()

static int check_index_start_failed ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Check the response from the "fs" service to our 'start index' request.

Parameters
clsclosure (of type struct GNUNET_FS_PublishContext *)
msgthe response we got

Definition at line 696 of file fs_publish.c.

References GNUNET_FS_FileInformation::emsg, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MessageHeader::size.

698 {
699  size_t msize = ntohs (msg->size) - sizeof(*msg);
700  const char *emsg = (const char *) &msg[1];
701 
702  if (emsg[msize - sizeof(struct GNUNET_MessageHeader) - 1] != '\0')
703  {
704  GNUNET_break (0);
705  return GNUNET_SYSERR;
706  }
707  return GNUNET_OK;
708 }
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Header for all communications.

◆ handle_index_start_failed()

static void handle_index_start_failed ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Process the response from the "fs" service to our 'start index' request.

Parameters
clsclosure (of type struct GNUNET_FS_PublishContext *)
msgthe response we got

Definition at line 719 of file fs_publish.c.

References _, GNUNET_FS_FileInformation::emsg, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::filename, gettext, GNUNET_asprintf(), GNUNET_free, GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_sync_(), GNUNET_MQ_destroy(), GNUNET_FS_PublishContext::mq, p, pc, and signal_publish_error().

721 {
722  struct GNUNET_FS_PublishContext *pc = cls;
724  const char *emsg = (const char *) &msg[1];
725  char *msgtxt;
726 
727  GNUNET_MQ_destroy (pc->mq);
728  pc->mq = NULL;
729  p = pc->fi_pos;
730  GNUNET_asprintf (&msgtxt,
731  _ ("Can not index file `%s': %s.\n"),
732  p->filename,
733  gettext (emsg));
735  pc,
736  msgtxt);
737  GNUNET_free (msgtxt);
740 }
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
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
#define gettext(Msgid)
Definition: gettext.h:45
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
static void signal_publish_error(struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc, const char *emsg)
Generate the callback that signals clients that a file (or directory) has encountered a problem durin...
Definition: fs_publish.c:189
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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 * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file...
Definition: fs_api.h:1220
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ handle_index_start_ok()

static void handle_index_start_ok ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Process the response from the "fs" service to our 'start index' request.

Parameters
clsclosure (of type struct GNUNET_FS_PublishContext *)
msgthe response we got

Definition at line 751 of file fs_publish.c.

References GNUNET_FS_FileInformation::data, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::file, GNUNET_FS_file_information_sync_(), GNUNET_MQ_destroy(), GNUNET_YES, GNUNET_FS_PublishContext::mq, p, pc, and publish_content().

753 {
754  struct GNUNET_FS_PublishContext *pc = cls;
756 
757  GNUNET_MQ_destroy (pc->mq);
758  pc->mq = NULL;
759  p = pc->fi_pos;
760  p->data.file.index_start_confirmed = GNUNET_YES;
762  publish_content (pc);
763 }
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
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
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
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.
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file...
Definition: fs_api.h:1220
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:

◆ index_mq_error_handler()

static void index_mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_FS_PublishContext *
errorerror code

Definition at line 775 of file fs_publish.c.

References _, GNUNET_FS_FileInformation::data, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::file, GNUNET_FS_FileInformation::filename, GNUNET_ERROR_TYPE_WARNING, GNUNET_FS_file_information_sync_(), GNUNET_log, GNUNET_MQ_destroy(), GNUNET_NO, GNUNET_FS_PublishContext::mq, p, pc, and publish_content().

Referenced by hash_for_index_cb().

777 {
778  struct GNUNET_FS_PublishContext *pc = cls;
780 
781  if (NULL != pc->mq)
782  {
783  GNUNET_MQ_destroy (pc->mq);
784  pc->mq = NULL;
785  }
786  p = pc->fi_pos;
788  _ ("Can not index file `%s': %s. Will try to insert instead.\n"),
789  p->filename,
790  _ ("error on index-start request to `fs' service"));
791  p->data.file.do_index = GNUNET_NO;
793  publish_content (pc);
794 }
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
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
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
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
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.
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file...
Definition: fs_api.h:1220
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#define GNUNET_log(kind,...)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_for_index_cb()

static void hash_for_index_cb ( void *  cls,
const struct GNUNET_HashCode res 
)
static

Function called once the hash computation over an indexed file has completed.

Parameters
clsclosure, our publishing context
resresulting hash, NULL on error

Definition at line 805 of file fs_publish.c.

References _, GNUNET_FS_Handle::cfg, GNUNET_FS_FileInformation::data, IndexStartMessage::device, env, GNUNET_FS_PublishContext::fhc, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_FileInformation::file, IndexStartMessage::file_id, GNUNET_FS_FileInformation::filename, fn, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_DISK_file_get_identifiers(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_FS_file_information_sync_(), GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY, GNUNET_h2s(), GNUNET_htonll(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_INDEX_START, GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED, GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_filename_expand(), GNUNET_YES, GNUNET_FS_PublishContext::h, index_mq_error_handler(), IndexStartMessage::inode, GNUNET_FS_PublishContext::mq, GNUNET_FS_PublishContext::options, p, pc, publish_content(), and res.

Referenced by GNUNET_FS_publish_main_().

807 {
808  struct GNUNET_FS_PublishContext *pc = cls;
810  GNUNET_MQ_hd_fixed_size (index_start_ok,
812  struct GNUNET_MessageHeader,
813  pc),
814  GNUNET_MQ_hd_var_size (index_start_failed,
816  struct GNUNET_MessageHeader,
817  pc),
819  };
821  struct GNUNET_MQ_Envelope *env;
822  struct IndexStartMessage *ism;
823  size_t slen;
824  uint64_t dev;
825  uint64_t ino;
826  char *fn;
827 
828  pc->fhc = NULL;
829  p = pc->fi_pos;
830  if (NULL == res)
831  {
833  _ (
834  "Can not index file `%s': %s. Will try to insert instead.\n"),
835  p->filename,
836  _ ("failed to compute hash"));
837  p->data.file.do_index = GNUNET_NO;
839  publish_content (pc);
840  return;
841  }
842  if (GNUNET_YES == p->data.file.index_start_confirmed)
843  {
844  publish_content (pc);
845  return;
846  }
848  GNUNET_assert (fn != NULL);
849  slen = strlen (fn) + 1;
850  if (slen >=
852  {
854  _
855  ("Can not index file `%s': %s. Will try to insert instead.\n"),
856  fn, _ ("filename too long"));
857  GNUNET_free (fn);
858  p->data.file.do_index = GNUNET_NO;
860  publish_content (pc);
861  return;
862  }
864  "Hash of indexed file `%s' is `%s'\n",
865  p->filename,
866  GNUNET_h2s (res));
868  {
869  p->data.file.file_id = *res;
870  p->data.file.have_hash = GNUNET_YES;
871  p->data.file.index_start_confirmed = GNUNET_YES;
873  publish_content (pc);
874  GNUNET_free (fn);
875  return;
876  }
877  pc->mq = GNUNET_CLIENT_connect (pc->h->cfg,
878  "fs",
879  handlers,
881  pc);
882  if (NULL == pc->mq)
883  {
885  _ (
886  "Can not index file `%s': %s. Will try to insert instead.\n"),
887  p->filename,
888  _ ("could not connect to `fs' service"));
889  p->data.file.do_index = GNUNET_NO;
890  publish_content (pc);
891  GNUNET_free (fn);
892  return;
893  }
894  if (p->data.file.have_hash != GNUNET_YES)
895  {
896  p->data.file.file_id = *res;
897  p->data.file.have_hash = GNUNET_YES;
899  }
900  env = GNUNET_MQ_msg_extra (ism,
901  slen,
903  if (GNUNET_OK ==
905  &dev,
906  &ino))
907  {
908  ism->device = GNUNET_htonll (dev);
909  ism->inode = GNUNET_htonll (ino);
910  }
911  else
912  {
914  _ ("Failed to get file identifiers for `%s'\n"),
915  p->filename);
916  }
917  ism->file_id = *res;
918  GNUNET_memcpy (&ism[1],
919  fn,
920  slen);
921  GNUNET_free (fn);
922  GNUNET_MQ_send (pc->mq,
923  env);
924 }
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_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
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
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED
Response to a request for start indexing that refuses.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:301
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
enum GNUNET_FS_PublishOptions options
Options for publishing.
Definition: fs_api.h:1274
#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
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
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int GNUNET_DISK_file_get_identifiers(const char *filename, uint64_t *dev, uint64_t *ino)
Obtain some unique identifiers for the given file that can be used to identify it in the local system...
Definition: disk.c:291
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
Message sent from a GNUnet (fs) publishing activity to the gnunet-fs-service to initiate indexing of ...
Definition: fs.h:151
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK
Affirmative response to a request for start indexing.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_FS_FileInformation::@16::@17 file
Data for a file.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static char * fn
Filename of the unique file.
uint64_t device
ID of device containing the file, as seen by the client.
Definition: fs.h:170
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1225
Handle for controlling a publication process.
Definition: fs_api.h:1178
Message handler for a specific message type.
static int res
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START
Message sent by fs client to start indexing.
struct GNUNET_HashCode file_id
Hash of the file that we would like to index.
Definition: fs.h:183
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:603
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file...
Definition: fs_api.h:1220
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint64_t inode
Inode of the file on the given device, as seen by the client ("st_ino" field from "struct stat")...
Definition: fs.h:178
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#define GNUNET_log(kind,...)
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static void index_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: fs_publish.c:775
#define GNUNET_free(ptr)
Wrapper around free.
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:

◆ publish_kblocks()

static void publish_kblocks ( struct GNUNET_FS_PublishContext pc)
static

We've computed the CHK/LOC URI, now publish the KSKs (if applicable).

Parameters
pcpublishing context to do this for

Definition at line 933 of file fs_publish.c.

References GNUNET_FS_FileInformation::bo, GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_publish_ksk(), GNUNET_FS_PublishContext::h, GNUNET_FS_FileInformation::keywords, GNUNET_FS_PublishContext::ksk_pc, GNUNET_FS_FileInformation::meta, GNUNET_FS_PublishContext::options, p, and publish_kblocks_cont().

Referenced by create_loc_uri(), GNUNET_FS_publish_main_(), handle_signature_response(), and loc_mq_error_handler().

934 {
936 
937  p = pc->fi_pos;
938  /* upload of "p" complete, publish KBlocks! */
939  if (NULL != p->keywords)
940  {
941  pc->ksk_pc = GNUNET_FS_publish_ksk (pc->h,
942  p->keywords,
943  p->meta,
944  p->chk_uri,
945  &p->bo,
946  pc->options,
948  pc);
949  }
950  else
951  {
952  publish_kblocks_cont (pc, p->chk_uri, NULL);
953  }
954 }
static void publish_kblocks_cont(void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
We&#39;ve finished publishing a KBlock as part of a larger upload.
Definition: fs_publish.c:312
struct GNUNET_CONTAINER_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:252
enum GNUNET_FS_PublishOptions options
Options for publishing.
Definition: fs_api.h:1274
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
struct GNUNET_FS_PublishKskContext * GNUNET_FS_publish_ksk(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish a CHK under various keywords on GNUnet.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
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
struct GNUNET_FS_PublishKskContext * ksk_pc
Context for KSK publishing operation that is part of this publishing operation (NULL if not active)...
Definition: fs_api.h:1252
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
struct GNUNET_FS_Uri * keywords
Keywords to use for KBlocks.
Definition: fs_api.h:257
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_signature_response()

static void handle_signature_response ( void *  cls,
const struct ResponseLocSignatureMessage sig 
)
static

Process the response from the "fs" service to our LOC sign request.

Parameters
clsclosure (of type struct GNUNET_FS_PublishContext *)
sigthe response we got

Definition at line 964 of file fs_publish.c.

References GNUNET_FS_FileInformation::chk_uri, Location::contentSignature, GNUNET_FS_Uri::data, ResponseLocSignatureMessage::expiration_time, Location::expirationTime, GNUNET_FS_PublishContext::fi_pos, GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_sync_(), GNUNET_FS_URI_LOC, GNUNET_TIME_absolute_ntoh(), GNUNET_FS_Uri::loc, p, pc, Location::peer, ResponseLocSignatureMessage::peer, publish_kblocks(), ResponseLocSignatureMessage::signature, and GNUNET_FS_Uri::type.

966 {
967  struct GNUNET_FS_PublishContext *pc = cls;
969 
970  p = pc->fi_pos;
972  /* p->data.loc.fi kept from CHK before */
973  p->chk_uri->data.loc.peer = sig->peer;
979  publish_kblocks (pc);
980 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:673
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_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs_api.h:121
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
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
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_TIME_AbsoluteNBO expiration_time
Expiration time that was actually used (rounded!).
Definition: fs.h:124
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_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs.h:134
struct GNUNET_TIME_Absolute expirationTime
Time when this location URI expires.
Definition: fs_api.h:126
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
union GNUNET_FS_Uri::@13 data
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
struct GNUNET_CRYPTO_EddsaSignature signature
The requested signature.
Definition: fs.h:129
struct GNUNET_CRYPTO_EddsaSignature contentSignature
Signature over the GNUNET_EC_FileIdentifier, peer identity and expiration time.
Definition: fs_api.h:132
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:217
Here is the call graph for this function:

◆ loc_mq_error_handler()

static void loc_mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_FS_PublishContext *
errorerror code

Definition at line 992 of file fs_publish.c.

References _, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_FS_PublishContext::mq, pc, and publish_kblocks().

Referenced by create_loc_uri().

994 {
995  struct GNUNET_FS_PublishContext *pc = cls;
996 
997  if (NULL != pc->mq)
998  {
999  GNUNET_MQ_destroy (pc->mq);
1000  pc->mq = NULL;
1001  }
1003  _ ("Can not create LOC URI. Will continue with CHK instead.\n"));
1004  publish_kblocks (pc);
1005 }
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
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
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file...
Definition: fs_api.h:1220
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#define GNUNET_log(kind,...)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_loc_uri()

static void create_loc_uri ( struct GNUNET_FS_PublishContext pc)
static

We're publishing without anonymity.

Contact the FS service to create a signed LOC URI for further processing, then continue with KSKs.

Parameters
pcthe publishing context do to this for

Definition at line 1016 of file fs_publish.c.

References _, GNUNET_FS_FileInformation::bo, GNUNET_FS_Handle::cfg, RequestLocSignatureMessage::chk, GNUNET_FS_Uri::chk, FileIdentifier::chk, GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_Uri::data, env, RequestLocSignatureMessage::expiration_time, GNUNET_FS_BlockOptions::expiration_time, GNUNET_FS_PublishContext::fi_pos, FileIdentifier::file_length, RequestLocSignatureMessage::file_length, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_WARNING, GNUNET_htonll(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN, GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE, GNUNET_MQ_destroy(), GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT, GNUNET_TIME_absolute_hton(), GNUNET_FS_PublishContext::h, loc_mq_error_handler(), GNUNET_FS_PublishContext::mq, p, publish_kblocks(), and RequestLocSignatureMessage::purpose.

Referenced by GNUNET_FS_publish_main_().

1017 {
1018  struct GNUNET_MQ_MessageHandler handlers[] = {
1019  GNUNET_MQ_hd_fixed_size (signature_response,
1022  pc),
1024  };
1025  struct GNUNET_MQ_Envelope *env;
1026  struct RequestLocSignatureMessage *req;
1027  struct GNUNET_FS_FileInformation *p;
1028 
1029  if (NULL != pc->mq)
1030  GNUNET_MQ_destroy (pc->mq);
1031  pc->mq = GNUNET_CLIENT_connect (pc->h->cfg,
1032  "fs",
1033  handlers,
1035  pc);
1036  if (NULL == pc->mq)
1037  {
1039  _ (
1040  "Can not create LOC URI. Will continue with CHK instead.\n"));
1041  publish_kblocks (pc);
1042  return;
1043  }
1044  p = pc->fi_pos;
1045  env = GNUNET_MQ_msg (req,
1049  req->chk = p->chk_uri->data.chk.chk;
1051  GNUNET_MQ_send (pc->mq,
1052  env);
1053 }
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 ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:103
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
uint32_t purpose
Requested signature purpose.
Definition: fs.h:85
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint64_t file_length
Size of the shared file (to be signed).
Definition: fs.h:100
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1183
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE
Reply sent by fs service with LOC signature.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
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
#define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT
Signature by which a peer affirms that it is providing a certain bit of content (used in LOCation URI...
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
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
Message handler for a specific message type.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file...
Definition: fs_api.h:1220
struct ContentHashKey chk
Information about the shared file (to be signed).
Definition: fs.h:95
union GNUNET_FS_Uri::@13 data
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:274
Message sent from the service with the signed LOC URI.
Definition: fs.h:107
Message sent from a GNUnet (fs) publishing activity to sign a LOC URI.
Definition: fs.h:74
uint64_t file_length
Total size of the file in bytes.
Definition: fs_api.h:98
#define GNUNET_log(kind,...)
static void loc_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: fs_publish.c:992
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN
Message sent by fs client to request LOC signature.
struct GNUNET_TIME_AbsoluteNBO expiration_time
Requested expiration time.
Definition: fs.h:90
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:657
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
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_main_()

void GNUNET_FS_publish_main_ ( void *  cls)

Main function that performs the upload.

Parameters
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:

◆ fip_signal_start()

static int fip_signal_start ( 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 
)
static

Signal the FS's progress function that we are starting an upload.

Parameters
clsclosure (of type struct GNUNET_FS_PublishContext *)
fithe entry in the publish-structure
lengthlength of the file or directory
metametadata for the file or directory (can be modified)
uripointer to the keywords that will be used for this entry (can be modified)
boblock options
do_indexshould we index?
client_infopointer to client context set upon creation (can be modified)
Returns
GNUNET_OK to continue (always)

Definition at line 1193 of file fs_publish.c.

References DBLOCK_SIZE, GNUNET_FS_FileInformation::dir, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_file_information_inspect(), GNUNET_FS_file_information_sync_(), GNUNET_FS_publish_make_status_(), GNUNET_FS_STATUS_PUBLISH_START, GNUNET_FS_uri_ksk_get_keyword_count(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_FS_FileInformation::is_directory, pc, GNUNET_FS_PublishContext::reserve_entries, GNUNET_FS_PublishContext::reserve_space, GNUNET_FS_PublishContext::skip_next_fi_callback, and GNUNET_FS_ProgressInfo::status.

Referenced by GNUNET_FS_publish_start().

1201 {
1202  struct GNUNET_FS_PublishContext *pc = cls;
1203  struct GNUNET_FS_ProgressInfo pi;
1204  unsigned int kc;
1205  uint64_t left;
1206 
1207  if (GNUNET_YES == pc->skip_next_fi_callback)
1208  {
1210  return GNUNET_OK;
1211  }
1213  "Starting publish operation\n");
1214  if (*do_index)
1215  {
1216  /* space for on-demand blocks */
1217  pc->reserve_space +=
1218  ((length + DBLOCK_SIZE
1219  - 1) / DBLOCK_SIZE) * sizeof(struct OnDemandBlock);
1220  }
1221  else
1222  {
1223  /* space for DBlocks */
1224  pc->reserve_space += length;
1225  }
1226  /* entries for IBlocks and DBlocks, space for IBlocks */
1227  left = length;
1228  while (1)
1229  {
1230  left = (left + DBLOCK_SIZE - 1) / DBLOCK_SIZE;
1231  pc->reserve_entries += left;
1232  if (left <= 1)
1233  break;
1234  left = left * sizeof(struct ContentHashKey);
1235  pc->reserve_space += left;
1236  }
1237  pc->reserve_entries++;
1238  /* entries and space for keywords */
1239  if (NULL != *uri)
1240  {
1242  pc->reserve_entries += kc;
1244  }
1246  *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0);
1248  if ((fi->is_directory) && (fi->dir != NULL))
1249  {
1250  /* We are a directory, and we are not top-level; process entries in directory */
1253  }
1254  return GNUNET_OK;
1255 }
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
content hash key
Definition: fs.h:53
uint64_t reserve_space
Storage space to reserve for the operation.
Definition: fs_api.h:1263
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
Notification that we have started to publish a file structure.
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:390
Handle for controlling a publication process.
Definition: fs_api.h:1178
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:40
uint32_t reserve_entries
Overall number of entries to reserve for the publish operation.
Definition: fs_api.h:1269
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
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
static int fip_signal_start(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 starting an upload.
Definition: fs_publish.c:1193
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
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_log(kind,...)
unsigned int GNUNET_FS_uri_ksk_get_keyword_count(const struct GNUNET_FS_Uri *uri)
How many keywords are ANDed in this keyword URI?
Definition: fs_uri.c:712
#define GNUNET_YES
Definition: gnunet_common.h:77
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
index block (indexing a DBlock that can be obtained directly from reading the plaintext file) ...
Definition: block_fs.h:81
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:

◆ suspend_operation()

static void suspend_operation ( struct GNUNET_FS_FileInformation fi,
struct GNUNET_FS_PublishContext pc 
)
static

Actually signal the FS's progress function that we are suspending an upload.

Parameters
fithe entry in the publish-structure
pcthe publish context of which a file is being suspended

Definition at line 1266 of file fs_publish.c.

References GNUNET_FS_FileInformation::chk_uri, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::dir_size, GNUNET_FS_PublishContext::dsh, GNUNET_FS_FileInformation::file, GNUNET_break, GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free_non_null, GNUNET_FS_publish_ksk_cancel(), GNUNET_FS_publish_make_status_(), GNUNET_FS_publish_sks_cancel(), GNUNET_FS_STATUS_PUBLISH_SUSPEND, GNUNET_log, GNUNET_NO, GNUNET_YES, GNUNET_FS_FileInformation::is_directory, GNUNET_FS_PublishContext::ksk_pc, GNUNET_FS_PublishContext::qre, GNUNET_FS_PublishContext::rid, GNUNET_FS_FileInformation::serialization, GNUNET_FS_PublishContext::sks_pc, and GNUNET_FS_ProgressInfo::status.

Referenced by fip_signal_suspend(), and GNUNET_FS_publish_signal_suspend_().

1268 {
1269  struct GNUNET_FS_ProgressInfo pi;
1270  uint64_t off;
1271 
1272  if (NULL != pc->ksk_pc)
1273  {
1275  pc->ksk_pc = NULL;
1276  }
1277  if (NULL != pc->sks_pc)
1278  {
1280  pc->sks_pc = NULL;
1281  }
1283  "Suspending publish operation\n");
1285  fi->serialization = NULL;
1286  off = (NULL == fi->chk_uri) ? 0 : (GNUNET_YES == fi->is_directory) ?
1287  fi->data.dir.dir_size : fi->data.file.file_size;
1289  GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1290  if (NULL != pc->qre)
1291  {
1293  pc->qre = NULL;
1294  }
1295  if (NULL != pc->dsh)
1296  {
1298  pc->dsh = NULL;
1299  }
1300  pc->rid = 0;
1301 }
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
int rid
Space reservation ID with datastore service for this upload.
Definition: fs_api.h:1280
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:286
void GNUNET_FS_publish_ksk_cancel(struct GNUNET_FS_PublishKskContext *pkc)
Abort the KSK publishing operation.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service.
Definition: fs_api.h:1235
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
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 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
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:496
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:263
struct GNUNET_FS_PublishKskContext * ksk_pc
Context for KSK publishing operation that is part of this publishing operation (NULL if not active)...
Definition: fs_api.h:1252
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
struct GNUNET_FS_PublishSksContext * sks_pc
Context for SKS publishing operation that is part of this publishing operation (NULL if not active)...
Definition: fs_api.h:1246
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
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
Notification that we have suspended sharing a file structure.
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
#define GNUNET_log(kind,...)
#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
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:

◆ fip_signal_suspend()

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 
)
static

Signal the FS's progress function that we are suspending an upload.

Performs the recursion.

Parameters
clsclosure (of type struct GNUNET_FS_PublishContext *)
fithe entry in the publish-structure
lengthlength of the file or directory
metametadata for the file or directory (can be modified)
uripointer to the keywords that will be used for this entry (can be modified)
boblock options
do_indexshould we index?
client_infopointer to client context set upon creation (can be modified)
Returns
GNUNET_OK to continue (always)

Definition at line 1319 of file fs_publish.c.

References GNUNET_FS_file_information_inspect(), GNUNET_FS_meta_data_test_for_directory(), GNUNET_NO, GNUNET_OK, GNUNET_YES, pc, GNUNET_FS_PublishContext::skip_next_fi_callback, and suspend_operation().

Referenced by GNUNET_FS_publish_signal_suspend_().

1327 {
1328  struct GNUNET_FS_PublishContext *pc = cls;
1329 
1330  if (GNUNET_YES == pc->skip_next_fi_callback)
1331  {
1333  return GNUNET_OK;
1334  }
1336  {
1337  /* process entries in directory */
1340  }
1341  suspend_operation (fi, pc);
1342  *client_info = NULL;
1343  return GNUNET_OK;
1344 }
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_CONTAINER_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
Definition: fs_directory.c:54
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
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
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:

◆ finish_reserve()

static void finish_reserve ( void *  cls,
int  success,
struct GNUNET_TIME_Absolute  min_expiration,
const char *  msg 
)
static

We have gotten a reply for our space reservation request.

Either fail (insufficient space) or start publishing for good.

Parameters
clsthe struct GNUNET_FS_PublishContext *
successpositive reservation ID on success
min_expirationminimum expiration time required for content to be stored
msgerror message on error, otherwise NULL

Definition at line 1382 of file fs_publish.c.

References _, GNUNET_FS_FileInformation::emsg, GNUNET_FS_PublishContext::fi, GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_publish_main_(), GNUNET_log, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, pc, GNUNET_FS_PublishContext::qre, GNUNET_FS_PublishContext::rid, signal_publish_error(), and GNUNET_FS_PublishContext::upload_task.

Referenced by GNUNET_FS_publish_start().

1386 {
1387  struct GNUNET_FS_PublishContext *pc = cls;
1388 
1389  pc->qre = NULL;
1391  "Reservation complete (%d)!\n",
1392  success);
1393  if ((msg != NULL) || (success <= 0))
1394  {
1395  GNUNET_asprintf (&pc->fi->emsg,
1396  _ ("Datastore failure: %s"),
1397  msg);
1398  signal_publish_error (pc->fi, pc, pc->fi->emsg);
1399  return;
1400  }
1401  pc->rid = success;
1402  GNUNET_assert (NULL == pc->upload_task);
1403  pc->upload_task =
1406 }
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1258
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
int rid
Space reservation ID with datastore service for this upload.
Definition: fs_api.h:1280
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:296
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Run as background job (higher than idle, lower than default).
static void signal_publish_error(struct GNUNET_FS_FileInformation *p, struct GNUNET_FS_PublishContext *pc, const char *emsg)
Generate the callback that signals clients that a file (or directory) has encountered a problem durin...
Definition: fs_publish.c:189
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1062
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1207
Handle for controlling a publication process.
Definition: fs_api.h:1178
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1240
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
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_contents_size()

static uint64_t compute_contents_size ( struct GNUNET_FS_FileInformation fi)
static

Calculate the total size of all of the files in the directory structure.

Parameters
fifile structure to traverse

Definition at line 1415 of file fs_publish.c.

References GNUNET_FS_FileInformation::contents_size, GNUNET_FS_FileInformation::data, GNUNET_FS_FileInformation::dir, GNUNET_FS_FileInformation::entries, GNUNET_FS_FileInformation::file, GNUNET_YES, GNUNET_FS_FileInformation::is_directory, and GNUNET_FS_FileInformation::next.

Referenced by GNUNET_FS_publish_start().

1416 {
1417  struct GNUNET_FS_FileInformation *ent;
1418 
1419  if (GNUNET_YES != fi->is_directory)
1420  return fi->data.file.file_size;
1421  fi->data.dir.contents_size = 0;
1422  for (ent = fi->data.dir.entries; NULL != ent; ent = ent->next)
1424  return fi->data.dir.contents_size;
1425 }
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:361
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
Information for a file or directory that is about to be published.
Definition: fs_api.h:226
union GNUNET_FS_FileInformation::@16 data
Data describing either the file or the directory.
static uint64_t compute_contents_size(struct GNUNET_FS_FileInformation *fi)
Calculate the total size of all of the files in the directory structure.
Definition: fs_publish.c:1415
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
uint64_t contents_size
Sum of all of the sizes of all of the files in the directory.
Definition: fs_api.h:383
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:231
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ fip_signal_stop()

static int fip_signal_stop ( 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 
)
static

Signal the FS's progress function that we are stopping an upload.

Parameters
clsclosure (of type struct GNUNET_FS_PublishContext *)
fithe entry in the publish-structure
lengthlength of the file or directory
metametadata for the file or directory (can be modified)
uripointer to the keywords that will be used for this entry (can be modified)
boblock options (can be modified)
do_indexshould we index?
client_infopointer to client context set upon creation (can be modified)
Returns
GNUNET_OK to continue (always)

Definition at line 1523 of file fs_publish.c.

References GNUNET_FS_FileInformation::chk_uri, GNUNET_break, GNUNET_free, GNUNET_FS_file_information_inspect(), GNUNET_FS_meta_data_test_for_directory(), GNUNET_FS_publish_make_status_(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_STATUS_PUBLISH_STOPPED, GNUNET_FS_SYNC_PATH_FILE_INFO, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_FS_PublishContext::h, pc, GNUNET_FS_FileInformation::serialization, GNUNET_FS_PublishContext::skip_next_fi_callback, and GNUNET_FS_ProgressInfo::status.

Referenced by GNUNET_FS_publish_stop().

1530 {
1531  struct GNUNET_FS_PublishContext *pc = cls;
1532  struct GNUNET_FS_ProgressInfo pi;
1533  uint64_t off;
1534 
1535  if (GNUNET_YES == pc->skip_next_fi_callback)
1536  {
1538  return GNUNET_OK;
1539  }
1541  {
1542  /* process entries in directory first */
1545  }
1546  if (NULL != fi->serialization)
1547  {
1549  fi->serialization);
1550  GNUNET_free (fi->serialization);
1551  fi->serialization = NULL;
1552  }
1553  off = (fi->chk_uri == NULL) ? 0 : length;
1555  GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1556  *client_info = NULL;
1557  return GNUNET_OK;
1558 }
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:286
#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
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...
Notification that we have stopped the process of uploading a file structure; no futher events will be...
static int fip_signal_stop(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 stopping an upload.
Definition: fs_publish.c:1523
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
#define GNUNET_FS_SYNC_PATH_FILE_INFO
Name of the directory with files that are being published.
Definition: fs_api.h:81
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_CONTAINER_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
Definition: fs_directory.c:54
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
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
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
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_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.
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: