2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/fs_publish.c
23 * @brief publish a file or directory in GNUnet
24 * @see https://gnunet.org/encoding
25 * @author Krista Bennett
26 * @author Christian Grothoff
30 #include "gnunet_constants.h"
31 #include "gnunet_signatures.h"
32 #include "gnunet_util_lib.h"
33 #include "gnunet_fs_service.h"
37 #define DEBUG_PUBLISH GNUNET_EXTRA_LOGGING
40 * Maximum legal size for a kblock.
42 #define MAX_KBLOCK_SIZE (60 * 1024)
46 * Fill in all of the generic fields for
47 * a publish event and call the callback.
49 * @param pi structure to fill in
50 * @param pc overall publishing context
51 * @param p file information for the file being published
52 * @param offset where in the file are we so far
53 * @return value returned from callback
56 GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
57 struct GNUNET_FS_PublishContext *pc,
58 const struct GNUNET_FS_FileInformation *p,
61 pi->value.publish.pc = pc;
62 pi->value.publish.fi = p;
63 pi->value.publish.cctx = p->client_info;
64 pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info;
65 pi->value.publish.filename = p->filename;
66 pi->value.publish.size =
67 (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size;
68 pi->value.publish.eta =
69 GNUNET_TIME_calculate_eta (p->start_time, offset, pi->value.publish.size);
70 pi->value.publish.completed = offset;
71 pi->value.publish.duration =
72 GNUNET_TIME_absolute_get_duration (p->start_time);
73 pi->value.publish.anonymity = p->bo.anonymity_level;
74 return pc->h->upcb (pc->h->upcb_cls, pi);
79 * Cleanup the publish context, we're done with it.
81 * @param cls struct to clean up after
82 * @param tc scheduler context
85 publish_cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
87 struct GNUNET_FS_PublishContext *pc = cls;
90 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up publish context (done!)\n");
94 GNUNET_CRYPTO_hash_file_cancel (pc->fhc);
97 GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL);
98 if (pc->namespace != NULL)
100 GNUNET_FS_namespace_delete (pc->namespace, GNUNET_NO);
101 pc->namespace = NULL;
103 GNUNET_free_non_null (pc->nid);
104 GNUNET_free_non_null (pc->nuid);
105 GNUNET_free_non_null (pc->serialization);
108 GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO);
111 if (pc->client != NULL)
113 GNUNET_CLIENT_disconnect (pc->client, GNUNET_NO);
116 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
122 * Function called by the datastore API with
123 * the result from the PUT request.
125 * @param cls the 'struct GNUNET_FS_PublishContext'
126 * @param success GNUNET_OK on success
127 * @param msg error message (or NULL)
130 ds_put_cont (void *cls, int success, const char *msg)
132 struct GNUNET_FS_PublishContext *pc = cls;
133 struct GNUNET_FS_ProgressInfo pi;
136 if (GNUNET_SYSERR == pc->in_network_wait)
138 /* we were aborted in the meantime, finish shutdown! */
139 GNUNET_SCHEDULER_add_continuation (&publish_cleanup, pc,
140 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
143 GNUNET_assert (GNUNET_YES == pc->in_network_wait);
144 pc->in_network_wait = GNUNET_NO;
145 if (GNUNET_SYSERR == success)
147 GNUNET_asprintf (&pc->fi_pos->emsg, _("Publishing failed: %s"), msg);
148 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
149 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
150 pi.value.publish.specifics.error.message = pc->fi_pos->emsg;
151 pc->fi_pos->client_info =
152 GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi_pos, 0);
153 if ((pc->fi_pos->is_directory == GNUNET_NO) &&
154 (pc->fi_pos->filename != NULL) &&
155 (pc->fi_pos->data.file.do_index == GNUNET_YES))
157 /* run unindex to clean up */
158 GNUNET_FS_unindex_start (pc->h, pc->fi_pos->filename, NULL);
161 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
163 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
164 &GNUNET_FS_publish_main_, pc);
169 * Generate the callback that signals clients
170 * that a file (or directory) has been completely
173 * @param p the completed upload
174 * @param pc context of the publication
177 signal_publish_completion (struct GNUNET_FS_FileInformation *p,
178 struct GNUNET_FS_PublishContext *pc)
180 struct GNUNET_FS_ProgressInfo pi;
182 pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED;
183 pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO;
184 pi.value.publish.specifics.completed.chk_uri = p->chk_uri;
186 GNUNET_FS_publish_make_status_ (&pi, pc, p,
187 GNUNET_ntohll (p->chk_uri->data.
193 * Generate the callback that signals clients
194 * that a file (or directory) has encountered
195 * a problem during publication.
197 * @param p the upload that had trouble
198 * @param pc context of the publication
199 * @param emsg error message
202 signal_publish_error (struct GNUNET_FS_FileInformation *p,
203 struct GNUNET_FS_PublishContext *pc, const char *emsg)
205 struct GNUNET_FS_ProgressInfo pi;
207 p->emsg = GNUNET_strdup (emsg);
208 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
209 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
210 pi.value.publish.specifics.error.message = emsg;
211 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
212 if ((p->is_directory == GNUNET_NO) && (p->filename != NULL) &&
213 (p->data.file.do_index == GNUNET_YES))
215 /* run unindex to clean up */
216 GNUNET_FS_unindex_start (pc->h, p->filename, NULL);
223 * Datastore returns from reservation cancel request.
225 * @param cls the 'struct GNUNET_FS_PublishContext'
226 * @param success success code (not used)
227 * @param msg error message (typically NULL, not used)
230 finish_release_reserve (void *cls, int success, const char *msg)
232 struct GNUNET_FS_PublishContext *pc = cls;
236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Releasing reserve done!\n");
238 signal_publish_completion (pc->fi, pc);
239 pc->all_done = GNUNET_YES;
240 GNUNET_FS_publish_sync_ (pc);
245 * We've finished publishing the SBlock as part of a larger upload.
246 * Check the result and complete the larger upload.
248 * @param cls the "struct GNUNET_FS_PublishContext*" of the larger upload
249 * @param uri URI of the published SBlock
250 * @param emsg NULL on success, otherwise error message
253 publish_sblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri,
256 struct GNUNET_FS_PublishContext *pc = cls;
260 signal_publish_error (pc->fi, pc, emsg);
261 GNUNET_FS_publish_sync_ (pc);
264 GNUNET_assert (pc->qre == NULL);
265 if ((pc->dsh != NULL) && (pc->rid != 0))
268 GNUNET_DATASTORE_release_reserve (pc->dsh, pc->rid, UINT_MAX, UINT_MAX,
269 GNUNET_TIME_UNIT_FOREVER_REL,
270 &finish_release_reserve, pc);
274 finish_release_reserve (pc, GNUNET_OK, NULL);
280 * We are almost done publishing the structure,
281 * add SBlocks (if needed).
283 * @param pc overall upload data
286 publish_sblock (struct GNUNET_FS_PublishContext *pc)
288 if (NULL != pc->namespace)
289 GNUNET_FS_publish_sks (pc->h, pc->namespace, pc->nid, pc->nuid,
290 pc->fi->meta, pc->fi->chk_uri, &pc->fi->bo,
291 pc->options, &publish_sblocks_cont, pc);
293 publish_sblocks_cont (pc, NULL, NULL);
298 * We've finished publishing a KBlock as part of a larger upload.
299 * Check the result and continue the larger upload.
301 * @param cls the "struct GNUNET_FS_PublishContext*"
302 * of the larger upload
303 * @param uri URI of the published blocks
304 * @param emsg NULL on success, otherwise error message
307 publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri,
310 struct GNUNET_FS_PublishContext *pc = cls;
311 struct GNUNET_FS_FileInformation *p = pc->fi_pos;
316 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error uploading KSK blocks: %s\n",
319 signal_publish_error (p, pc, emsg);
320 GNUNET_FS_file_information_sync_ (p);
321 GNUNET_FS_publish_sync_ (pc);
322 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
324 GNUNET_SCHEDULER_add_with_priority
325 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc);
329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
330 "KSK blocks published, moving on to next file\n");
333 signal_publish_completion (p, pc);
334 /* move on to next file */
336 pc->fi_pos = p->next;
339 GNUNET_FS_publish_sync_ (pc);
340 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
342 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
343 &GNUNET_FS_publish_main_, pc);
348 * Function called by the tree encoder to obtain
349 * a block of plaintext data (for the lowest level
352 * @param cls our publishing context
353 * @param offset identifies which block to get
354 * @param max (maximum) number of bytes to get; returning
355 * fewer will also cause errors
356 * @param buf where to copy the plaintext buffer
357 * @param emsg location to store an error message (on error)
358 * @return number of bytes copied to buf, 0 on error
361 block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
363 struct GNUNET_FS_PublishContext *pc = cls;
364 struct GNUNET_FS_FileInformation *p;
371 pt_size = GNUNET_MIN (max, p->data.dir.dir_size - offset);
372 dd = p->data.dir.dir_data;
373 memcpy (buf, &dd[offset], pt_size);
377 pt_size = GNUNET_MIN (max, p->data.file.file_size - offset);
379 return 0; /* calling reader with pt_size==0
380 * might free buf, so don't! */
382 p->data.file.reader (p->data.file.reader_cls, offset, pt_size, buf,
391 * The tree encoder has finished processing a
392 * file. Call it's finish method and deal with
395 * @param cls our publishing context
396 * @param tc scheduler's task context (not used)
399 encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
401 struct GNUNET_FS_PublishContext *pc = cls;
402 struct GNUNET_FS_FileInformation *p;
403 struct GNUNET_FS_ProgressInfo pi;
408 GNUNET_FS_tree_encoder_finish (p->te, &p->chk_uri, &emsg);
413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error during tree walk: %s\n", emsg);
415 GNUNET_asprintf (&p->emsg, _("Publishing failed: %s"), emsg);
417 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
418 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
419 pi.value.publish.specifics.error.message = p->emsg;
420 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished with tree encoder\n");
425 /* final progress event */
426 flen = GNUNET_FS_uri_chk_get_file_size (p->chk_uri);
427 pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS;
428 pi.value.publish.specifics.progress.data = NULL;
429 pi.value.publish.specifics.progress.offset = flen;
430 pi.value.publish.specifics.progress.data_len = 0;
431 pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen);
432 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, flen);
434 /* continue with main */
435 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
437 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
438 &GNUNET_FS_publish_main_, pc);
443 * Function called asking for the current (encoded)
444 * block to be processed. After processing the
445 * client should either call "GNUNET_FS_tree_encode_next"
446 * or (on error) "GNUNET_FS_tree_encode_finish".
449 * @param chk content hash key for the block
450 * @param offset offset of the block in the file
451 * @param depth depth of the block in the file, 0 for DBLOCK
452 * @param type type of the block (IBLOCK or DBLOCK)
453 * @param block the (encrypted) block
454 * @param block_size size of block (in bytes)
457 block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset,
458 unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block,
461 struct GNUNET_FS_PublishContext *pc = cls;
462 struct GNUNET_FS_FileInformation *p;
463 struct OnDemandBlock odb;
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for datastore connection\n");
471 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
473 GNUNET_SCHEDULER_add_with_priority
474 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc);
478 GNUNET_assert (GNUNET_NO == pc->in_network_wait);
479 pc->in_network_wait = GNUNET_YES;
480 if ((!p->is_directory) && (GNUNET_YES == p->data.file.do_index) &&
481 (type == GNUNET_BLOCK_TYPE_FS_DBLOCK))
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
485 "Indexing block `%s' for offset %llu with index size %u\n",
486 GNUNET_h2s (&chk->query), (unsigned long long) offset,
487 sizeof (struct OnDemandBlock));
489 odb.offset = GNUNET_htonll (offset);
490 odb.file_id = p->data.file.file_id;
491 GNUNET_assert (pc->qre == NULL);
493 GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid,
494 &chk->query, sizeof (struct OnDemandBlock), &odb,
495 GNUNET_BLOCK_TYPE_FS_ONDEMAND,
496 p->bo.content_priority, p->bo.anonymity_level,
497 p->bo.replication_level, p->bo.expiration_time,
498 -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT,
503 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
504 "Publishing block `%s' for offset %llu with size %u\n",
505 GNUNET_h2s (&chk->query), (unsigned long long) offset,
506 (unsigned int) block_size);
508 GNUNET_assert (pc->qre == NULL);
510 GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid,
511 &chk->query, block_size, block, type,
512 p->bo.content_priority, p->bo.anonymity_level,
513 p->bo.replication_level, p->bo.expiration_time, -2,
514 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont,
520 * Function called with information about our
521 * progress in computing the tree encoding.
524 * @param offset where are we in the file
525 * @param pt_block plaintext of the currently processed block
526 * @param pt_size size of pt_block
527 * @param depth depth of the block in the tree, 0 for DBLOCK
530 progress_proc (void *cls, uint64_t offset, const void *pt_block, size_t pt_size,
533 struct GNUNET_FS_PublishContext *pc = cls;
534 struct GNUNET_FS_FileInformation *p;
535 struct GNUNET_FS_ProgressInfo pi;
538 pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS;
539 pi.value.publish.specifics.progress.data = pt_block;
540 pi.value.publish.specifics.progress.offset = offset;
541 pi.value.publish.specifics.progress.data_len = pt_size;
542 pi.value.publish.specifics.progress.depth = depth;
543 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, offset);
548 * We are uploading a file or directory; load (if necessary) the next
549 * block into memory, encrypt it and send it to the FS service. Then
550 * continue with the main task.
552 * @param pc overall upload data
555 publish_content (struct GNUNET_FS_PublishContext *pc)
557 struct GNUNET_FS_FileInformation *p;
559 struct GNUNET_FS_DirectoryBuilder *db;
560 struct GNUNET_FS_FileInformation *dirpos;
565 GNUNET_assert (p != NULL);
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n");
573 db = GNUNET_FS_directory_builder_create (p->meta);
574 dirpos = p->data.dir.entries;
575 while (NULL != dirpos)
577 if (dirpos->is_directory)
579 raw_data = dirpos->data.dir.dir_data;
580 dirpos->data.dir.dir_data = NULL;
585 if ((dirpos->data.file.file_size < MAX_INLINE_SIZE) &&
586 (dirpos->data.file.file_size > 0))
588 raw_data = GNUNET_malloc (dirpos->data.file.file_size);
590 if (dirpos->data.file.file_size !=
591 dirpos->data.file.reader (dirpos->data.file.reader_cls, 0,
592 dirpos->data.file.file_size, raw_data,
595 GNUNET_free_non_null (emsg);
596 GNUNET_free (raw_data);
601 GNUNET_FS_directory_builder_add (db, dirpos->chk_uri, dirpos->meta,
603 GNUNET_free_non_null (raw_data);
604 dirpos = dirpos->next;
606 GNUNET_free_non_null (p->data.dir.dir_data);
607 p->data.dir.dir_data = NULL;
608 p->data.dir.dir_size = 0;
609 GNUNET_FS_directory_builder_finish (db, &p->data.dir.dir_size,
610 &p->data.dir.dir_data);
611 GNUNET_FS_file_information_sync_ (p);
613 size = (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size;
615 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tree encoder\n");
618 GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader,
619 &block_proc, &progress_proc,
624 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing next block from tree\n");
626 GNUNET_FS_tree_encoder_next (p->te);
631 * Process the response (or lack thereof) from
632 * the "fs" service to our 'start index' request.
634 * @param cls closure (of type "struct GNUNET_FS_PublishContext*"_)
635 * @param msg the response we got
638 process_index_start_response (void *cls, const struct GNUNET_MessageHeader *msg)
640 struct GNUNET_FS_PublishContext *pc = cls;
641 struct GNUNET_FS_FileInformation *p;
645 GNUNET_CLIENT_disconnect (pc->client, GNUNET_NO);
650 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
652 ("Can not index file `%s': %s. Will try to insert instead.\n"),
654 _("timeout on index-start request to `fs' service"));
655 p->data.file.do_index = GNUNET_NO;
656 GNUNET_FS_file_information_sync_ (p);
657 publish_content (pc);
660 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK)
662 msize = ntohs (msg->size);
663 emsg = (const char *) &msg[1];
664 if ((msize <= sizeof (struct GNUNET_MessageHeader)) ||
665 (emsg[msize - sizeof (struct GNUNET_MessageHeader) - 1] != '\0'))
666 emsg = gettext_noop ("unknown error");
667 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
669 ("Can not index file `%s': %s. Will try to insert instead.\n"),
670 p->filename, gettext (emsg));
671 p->data.file.do_index = GNUNET_NO;
672 GNUNET_FS_file_information_sync_ (p);
673 publish_content (pc);
676 p->data.file.index_start_confirmed = GNUNET_YES;
677 /* success! continue with indexing */
678 GNUNET_FS_file_information_sync_ (p);
679 publish_content (pc);
684 * Function called once the hash computation over an
685 * indexed file has completed.
687 * @param cls closure, our publishing context
688 * @param res resulting hash, NULL on error
691 hash_for_index_cb (void *cls, const GNUNET_HashCode * res)
693 struct GNUNET_FS_PublishContext *pc = cls;
694 struct GNUNET_FS_FileInformation *p;
695 struct IndexStartMessage *ism;
697 struct GNUNET_CLIENT_Connection *client;
706 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
708 ("Can not index file `%s': %s. Will try to insert instead.\n"),
709 p->filename, _("failed to compute hash"));
710 p->data.file.do_index = GNUNET_NO;
711 GNUNET_FS_file_information_sync_ (p);
712 publish_content (pc);
715 if (GNUNET_YES == p->data.file.index_start_confirmed)
717 publish_content (pc);
720 fn = GNUNET_STRINGS_filename_expand (p->filename);
721 GNUNET_assert (fn != NULL);
722 slen = strlen (fn) + 1;
724 GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage))
726 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
728 ("Can not index file `%s': %s. Will try to insert instead.\n"),
729 fn, _("filename too long"));
731 p->data.file.do_index = GNUNET_NO;
732 GNUNET_FS_file_information_sync_ (p);
733 publish_content (pc);
737 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hash of indexed file `%s' is `%s'\n",
738 p->filename, GNUNET_h2s (res));
740 if (0 != (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
742 p->data.file.file_id = *res;
743 p->data.file.have_hash = GNUNET_YES;
744 p->data.file.index_start_confirmed = GNUNET_YES;
745 GNUNET_FS_file_information_sync_ (p);
746 publish_content (pc);
750 client = GNUNET_CLIENT_connect ("fs", pc->h->cfg);
753 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
755 ("Can not index file `%s': %s. Will try to insert instead.\n"),
756 p->filename, _("could not connect to `fs' service"));
757 p->data.file.do_index = GNUNET_NO;
758 publish_content (pc);
762 if (p->data.file.have_hash != GNUNET_YES)
764 p->data.file.file_id = *res;
765 p->data.file.have_hash = GNUNET_YES;
766 GNUNET_FS_file_information_sync_ (p);
768 ism = GNUNET_malloc (sizeof (struct IndexStartMessage) + slen);
769 ism->header.size = htons (sizeof (struct IndexStartMessage) + slen);
770 ism->header.type = htons (GNUNET_MESSAGE_TYPE_FS_INDEX_START);
771 if (GNUNET_OK == GNUNET_DISK_file_get_identifiers (p->filename, &dev, &ino))
773 ism->device = GNUNET_htonll (dev);
774 ism->inode = GNUNET_htonll (ino);
779 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
780 _("Failed to get file identifiers for `%s'\n"), p->filename);
784 memcpy (&ism[1], fn, slen);
787 GNUNET_break (GNUNET_YES ==
788 GNUNET_CLIENT_transmit_and_get_response (client, &ism->header,
789 GNUNET_TIME_UNIT_FOREVER_REL,
791 &process_index_start_response,
798 * Main function that performs the upload.
800 * @param cls "struct GNUNET_FS_PublishContext" identifies the upload
801 * @param tc task context
804 GNUNET_FS_publish_main_ (void *cls,
805 const struct GNUNET_SCHEDULER_TaskContext *tc)
807 struct GNUNET_FS_PublishContext *pc = cls;
808 struct GNUNET_FS_ProgressInfo pi;
809 struct GNUNET_FS_FileInformation *p;
810 struct GNUNET_FS_Uri *loc;
813 pc->upload_task = GNUNET_SCHEDULER_NO_TASK;
818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
819 "Publishing complete, now publishing SKS and KSK blocks.\n");
821 /* upload of entire hierarchy complete,
822 * publish namespace entries */
823 GNUNET_FS_publish_sync_ (pc);
827 /* find starting position */
828 while ((p->is_directory) && (NULL != p->data.dir.entries) && (NULL == p->emsg)
829 && (NULL == p->data.dir.entries->chk_uri))
831 p = p->data.dir.entries;
833 GNUNET_FS_publish_sync_ (pc);
839 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error uploading: %s\n", p->emsg);
841 /* error with current file, abort all
842 * related files as well! */
843 while (NULL != p->dir)
845 fn = GNUNET_CONTAINER_meta_data_get_by_type (p->meta,
846 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
850 GNUNET_asprintf (&p->emsg, _("Recursive upload failed at `%s': %s"), fn,
856 GNUNET_asprintf (&p->emsg, _("Recursive upload failed: %s"), p->emsg);
858 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
859 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
860 pi.value.publish.specifics.error.message = p->emsg;
861 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
863 pc->all_done = GNUNET_YES;
864 GNUNET_FS_publish_sync_ (pc);
867 /* handle completion */
868 if (NULL != p->chk_uri)
871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
872 "File upload complete, now publishing KSK blocks.\n");
874 if (0 == p->bo.anonymity_level)
876 /* zero anonymity, box CHK URI in LOC URI */
878 GNUNET_FS_uri_loc_create (p->chk_uri, pc->h->cfg,
879 p->bo.expiration_time);
880 GNUNET_FS_uri_destroy (p->chk_uri);
883 GNUNET_FS_publish_sync_ (pc);
884 /* upload of "p" complete, publish KBlocks! */
885 if (p->keywords != NULL)
887 GNUNET_FS_publish_ksk (pc->h, p->keywords, p->meta, p->chk_uri, &p->bo,
888 pc->options, &publish_kblocks_cont, pc);
892 publish_kblocks_cont (pc, p->chk_uri, NULL);
896 if ((!p->is_directory) && (p->data.file.do_index))
898 if (NULL == p->filename)
900 p->data.file.do_index = GNUNET_NO;
901 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
903 ("Can not index file `%s': %s. Will try to insert instead.\n"),
904 "<no-name>", _("needs to be an actual file"));
905 GNUNET_FS_file_information_sync_ (p);
906 publish_content (pc);
909 if (p->data.file.have_hash)
911 hash_for_index_cb (pc, &p->data.file.file_id);
915 p->start_time = GNUNET_TIME_absolute_get ();
917 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, p->filename,
918 HASHING_BLOCKSIZE, &hash_for_index_cb, pc);
922 publish_content (pc);
927 * Signal the FS's progress function that we are starting
930 * @param cls closure (of type "struct GNUNET_FS_PublishContext*")
931 * @param fi the entry in the publish-structure
932 * @param length length of the file or directory
933 * @param meta metadata for the file or directory (can be modified)
934 * @param uri pointer to the keywords that will be used for this entry (can be modified)
935 * @param bo block options
936 * @param do_index should we index?
937 * @param client_info pointer to client context set upon creation (can be modified)
938 * @return GNUNET_OK to continue (always)
941 fip_signal_start (void *cls, struct GNUNET_FS_FileInformation *fi,
942 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
943 struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo,
944 int *do_index, void **client_info)
946 struct GNUNET_FS_PublishContext *pc = cls;
947 struct GNUNET_FS_ProgressInfo pi;
952 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting publish operation\n");
956 /* space for on-demand blocks */
958 ((length + DBLOCK_SIZE -
959 1) / DBLOCK_SIZE) * sizeof (struct OnDemandBlock);
963 /* space for DBlocks */
964 pc->reserve_space += length;
966 /* entries for IBlocks and DBlocks, space for IBlocks */
970 left = (left + DBLOCK_SIZE - 1) / DBLOCK_SIZE;
971 pc->reserve_entries += left;
974 left = left * sizeof (struct ContentHashKey);
975 pc->reserve_space += left;
977 pc->reserve_entries++;
978 /* entries and space for keywords */
981 kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri);
982 pc->reserve_entries += kc;
983 pc->reserve_space += GNUNET_SERVER_MAX_MESSAGE_SIZE * kc;
985 pi.status = GNUNET_FS_STATUS_PUBLISH_START;
986 *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0);
987 GNUNET_FS_file_information_sync_ (fi);
993 * Signal the FS's progress function that we are suspending
996 * @param cls closure (of type "struct GNUNET_FS_PublishContext*")
997 * @param fi the entry in the publish-structure
998 * @param length length of the file or directory
999 * @param meta metadata for the file or directory (can be modified)
1000 * @param uri pointer to the keywords that will be used for this entry (can be modified)
1001 * @param bo block options
1002 * @param do_index should we index?
1003 * @param client_info pointer to client context set upon creation (can be modified)
1004 * @return GNUNET_OK to continue (always)
1007 fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi,
1008 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
1009 struct GNUNET_FS_Uri **uri,
1010 struct GNUNET_FS_BlockOptions *bo, int *do_index,
1013 struct GNUNET_FS_PublishContext *pc = cls;
1014 struct GNUNET_FS_ProgressInfo pi;
1018 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending publish operation\n");
1020 GNUNET_free_non_null (fi->serialization);
1021 fi->serialization = NULL;
1022 off = (fi->chk_uri == NULL) ? 0 : length;
1023 pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND;
1024 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1025 *client_info = NULL;
1026 if (NULL != pc->qre)
1028 GNUNET_DATASTORE_cancel (pc->qre);
1031 if (NULL != pc->dsh)
1033 GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO);
1042 * Create SUSPEND event for the given publish operation
1043 * and then clean up our state (without stop signal).
1045 * @param cls the 'struct GNUNET_FS_PublishContext' to signal for
1048 GNUNET_FS_publish_signal_suspend_ (void *cls)
1050 struct GNUNET_FS_PublishContext *pc = cls;
1052 if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task)
1054 GNUNET_SCHEDULER_cancel (pc->upload_task);
1055 pc->upload_task = GNUNET_SCHEDULER_NO_TASK;
1057 GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_suspend, pc);
1058 GNUNET_FS_end_top (pc->h, pc->top);
1060 publish_cleanup (pc, NULL);
1065 * We have gotten a reply for our space reservation request.
1066 * Either fail (insufficient space) or start publishing for good.
1068 * @param cls the 'struct GNUNET_FS_PublishContext*'
1069 * @param success positive reservation ID on success
1070 * @param msg error message on error, otherwise NULL
1073 finish_reserve (void *cls, int success, const char *msg)
1075 struct GNUNET_FS_PublishContext *pc = cls;
1079 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reservation complete (%d)!\n", success);
1081 if ((msg != NULL) || (success <= 0))
1083 GNUNET_asprintf (&pc->fi->emsg, _("Insufficient space for publishing: %s"),
1085 signal_publish_error (pc->fi, pc, pc->fi->emsg);
1089 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
1091 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
1092 &GNUNET_FS_publish_main_, pc);
1097 * Publish a file or directory.
1099 * @param h handle to the file sharing subsystem
1100 * @param fi information about the file or directory structure to publish
1101 * @param namespace namespace to publish the file in, NULL for no namespace
1102 * @param nid identifier to use for the publishd content in the namespace
1103 * (can be NULL, must be NULL if namespace is NULL)
1104 * @param nuid update-identifier that will be used for future updates
1105 * (can be NULL, must be NULL if namespace or nid is NULL)
1106 * @param options options for the publication
1107 * @return context that can be used to control the publish operation
1109 struct GNUNET_FS_PublishContext *
1110 GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1111 struct GNUNET_FS_FileInformation *fi,
1112 struct GNUNET_FS_Namespace *namespace, const char *nid,
1114 enum GNUNET_FS_PublishOptions options)
1116 struct GNUNET_FS_PublishContext *ret;
1117 struct GNUNET_DATASTORE_Handle *dsh;
1119 GNUNET_assert (NULL != h);
1120 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
1122 dsh = GNUNET_DATASTORE_connect (h->cfg);
1130 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishContext));
1134 ret->namespace = namespace;
1135 ret->options = options;
1136 if (namespace != NULL)
1139 GNUNET_assert (NULL != nid);
1140 ret->nid = GNUNET_strdup (nid);
1142 ret->nuid = GNUNET_strdup (nuid);
1145 GNUNET_FS_file_information_inspect (ret->fi, &fip_signal_start, ret);
1146 ret->fi_pos = ret->fi;
1147 ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_publish_signal_suspend_, ret);
1148 GNUNET_FS_publish_sync_ (ret);
1149 if (NULL != ret->dsh)
1151 GNUNET_assert (NULL == ret->qre);
1152 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1154 ("Reserving space for %u entries and %llu bytes for publication\n"),
1155 (unsigned int) ret->reserve_entries,
1156 (unsigned long long) ret->reserve_space);
1158 GNUNET_DATASTORE_reserve (ret->dsh, ret->reserve_space,
1159 ret->reserve_entries, UINT_MAX, UINT_MAX,
1160 GNUNET_TIME_UNIT_FOREVER_REL, &finish_reserve,
1165 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ret->upload_task);
1167 GNUNET_SCHEDULER_add_with_priority
1168 (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, ret);
1175 * Signal the FS's progress function that we are stopping
1178 * @param cls closure (of type "struct GNUNET_FS_PublishContext*")
1179 * @param fi the entry in the publish-structure
1180 * @param length length of the file or directory
1181 * @param meta metadata for the file or directory (can be modified)
1182 * @param uri pointer to the keywords that will be used for this entry (can be modified)
1183 * @param bo block options (can be modified)
1184 * @param do_index should we index?
1185 * @param client_info pointer to client context set upon creation (can be modified)
1186 * @return GNUNET_OK to continue (always)
1189 fip_signal_stop (void *cls, struct GNUNET_FS_FileInformation *fi,
1190 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
1191 struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo,
1192 int *do_index, void **client_info)
1194 struct GNUNET_FS_PublishContext *pc = cls;
1195 struct GNUNET_FS_ProgressInfo pi;
1198 if (fi->serialization != NULL)
1200 GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO,
1202 GNUNET_free (fi->serialization);
1203 fi->serialization = NULL;
1205 off = (fi->chk_uri == NULL) ? 0 : length;
1206 pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED;
1207 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1208 *client_info = NULL;
1214 * Stop an upload. Will abort incomplete uploads (but
1215 * not remove blocks that have already been publishd) or
1216 * simply clean up the state for completed uploads.
1217 * Must NOT be called from within the event callback!
1219 * @param pc context for the upload to stop
1222 GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc)
1225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publish stop called\n");
1227 GNUNET_FS_end_top (pc->h, pc->top);
1228 if (NULL != pc->qre)
1230 GNUNET_DATASTORE_cancel (pc->qre);
1233 if (NULL != pc->dsh)
1235 GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO);
1238 if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task)
1240 GNUNET_SCHEDULER_cancel (pc->upload_task);
1241 pc->upload_task = GNUNET_SCHEDULER_NO_TASK;
1243 if (pc->serialization != NULL)
1245 GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH,
1247 GNUNET_free (pc->serialization);
1248 pc->serialization = NULL;
1250 GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_stop, pc);
1251 if (GNUNET_YES == pc->in_network_wait)
1253 pc->in_network_wait = GNUNET_SYSERR;
1256 publish_cleanup (pc, NULL);
1261 * Context for the KSK publication.
1263 struct PublishKskContext
1269 struct GNUNET_FS_Uri *ksk_uri;
1272 * Global FS context.
1274 struct GNUNET_FS_Handle *h;
1277 * The master block that we are sending
1278 * (in plaintext), has "mdsize+slen" more
1279 * bytes than the struct would suggest.
1284 * Buffer of the same size as "kb" for
1285 * the encrypted version.
1290 * Handle to the datastore, NULL if we are just
1293 struct GNUNET_DATASTORE_Handle *dsh;
1296 * Handle to datastore PUT request.
1298 struct GNUNET_DATASTORE_QueueEntry *qre;
1301 * Function to call once we're done.
1303 GNUNET_FS_PublishContinuation cont;
1311 * When should the KBlocks expire?
1313 struct GNUNET_FS_BlockOptions bo;
1316 * Size of the serialized metadata.
1321 * Size of the (CHK) URI as a string.
1326 * Keyword that we are currently processing.
1334 * Continuation of "GNUNET_FS_publish_ksk" that performs
1335 * the actual publishing operation (iterating over all
1338 * @param cls closure of type "struct PublishKskContext*"
1342 publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
1346 * Function called by the datastore API with
1347 * the result from the PUT request.
1349 * @param cls closure of type "struct PublishKskContext*"
1350 * @param success GNUNET_OK on success
1351 * @param msg error message (or NULL)
1354 kb_put_cont (void *cls, int success, const char *msg)
1356 struct PublishKskContext *pkc = cls;
1359 if (GNUNET_OK != success)
1362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "KB PUT operation complete\n");
1364 if (NULL != pkc->dsh)
1366 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
1369 GNUNET_free (pkc->cpy);
1370 GNUNET_free (pkc->kb);
1371 pkc->cont (pkc->cont_cls, NULL, msg);
1372 GNUNET_FS_uri_destroy (pkc->ksk_uri);
1376 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc,
1377 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1382 * Continuation of "GNUNET_FS_publish_ksk" that performs the actual
1383 * publishing operation (iterating over all of the keywords).
1385 * @param cls closure of type "struct PublishKskContext*"
1389 publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1391 struct PublishKskContext *pkc = cls;
1392 const char *keyword;
1393 GNUNET_HashCode key;
1394 GNUNET_HashCode query;
1395 struct GNUNET_CRYPTO_AesSessionKey skey;
1396 struct GNUNET_CRYPTO_AesInitializationVector iv;
1397 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
1400 if ((pkc->i == pkc->ksk_uri->data.ksk.keywordCount) || (NULL == pkc->dsh))
1403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "KSK PUT operation complete\n");
1405 if (NULL != pkc->dsh)
1407 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
1410 GNUNET_free (pkc->cpy);
1411 GNUNET_free (pkc->kb);
1412 pkc->cont (pkc->cont_cls, pkc->ksk_uri, NULL);
1413 GNUNET_FS_uri_destroy (pkc->ksk_uri);
1417 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++];
1419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing under keyword `%s'\n",
1422 /* first character of keyword indicates if it is
1423 * mandatory or not -- ignore for hashing */
1424 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key);
1425 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
1426 GNUNET_CRYPTO_aes_encrypt (&pkc->kb[1], pkc->slen + pkc->mdsize, &skey, &iv,
1428 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
1429 GNUNET_assert (NULL != pk);
1430 GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace);
1431 GNUNET_CRYPTO_hash (&pkc->cpy->keyspace,
1432 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1434 GNUNET_assert (GNUNET_OK ==
1435 GNUNET_CRYPTO_rsa_sign (pk, &pkc->cpy->purpose,
1436 &pkc->cpy->signature));
1437 GNUNET_CRYPTO_rsa_key_free (pk);
1439 GNUNET_DATASTORE_put (pkc->dsh, 0, &query,
1440 pkc->mdsize + sizeof (struct KBlock) + pkc->slen,
1441 pkc->cpy, GNUNET_BLOCK_TYPE_FS_KBLOCK,
1442 pkc->bo.content_priority, pkc->bo.anonymity_level,
1443 pkc->bo.replication_level, pkc->bo.expiration_time,
1444 -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1450 * Publish a CHK under various keywords on GNUnet.
1452 * @param h handle to the file sharing subsystem
1453 * @param ksk_uri keywords to use
1454 * @param meta metadata to use
1455 * @param uri URI to refer to in the KBlock
1456 * @param bo per-block options
1457 * @param options publication options
1458 * @param cont continuation
1459 * @param cont_cls closure for cont
1462 GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
1463 const struct GNUNET_FS_Uri *ksk_uri,
1464 const struct GNUNET_CONTAINER_MetaData *meta,
1465 const struct GNUNET_FS_Uri *uri,
1466 const struct GNUNET_FS_BlockOptions *bo,
1467 enum GNUNET_FS_PublishOptions options,
1468 GNUNET_FS_PublishContinuation cont, void *cont_cls)
1470 struct PublishKskContext *pkc;
1476 GNUNET_assert (NULL != uri);
1477 pkc = GNUNET_malloc (sizeof (struct PublishKskContext));
1481 pkc->cont_cls = cont_cls;
1482 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
1484 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
1485 if (pkc->dsh == NULL)
1487 cont (cont_cls, NULL, _("Could not connect to datastore."));
1495 pkc->mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
1496 GNUNET_assert (pkc->mdsize >= 0);
1497 uris = GNUNET_FS_uri_to_string (uri);
1498 pkc->slen = strlen (uris) + 1;
1499 size = pkc->mdsize + sizeof (struct KBlock) + pkc->slen;
1500 if (size > MAX_KBLOCK_SIZE)
1502 size = MAX_KBLOCK_SIZE;
1503 pkc->mdsize = size - sizeof (struct KBlock) - pkc->slen;
1505 pkc->kb = GNUNET_malloc (size);
1506 kbe = (char *) &pkc->kb[1];
1507 memcpy (kbe, uris, pkc->slen);
1509 sptr = &kbe[pkc->slen];
1512 GNUNET_CONTAINER_meta_data_serialize (meta, &sptr, pkc->mdsize,
1513 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
1514 if (pkc->mdsize == -1)
1517 GNUNET_free (pkc->kb);
1518 if (pkc->dsh != NULL)
1520 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
1523 cont (cont_cls, NULL, _("Internal error."));
1527 size = sizeof (struct KBlock) + pkc->slen + pkc->mdsize;
1529 pkc->cpy = GNUNET_malloc (size);
1530 pkc->cpy->purpose.size =
1531 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
1532 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
1533 pkc->mdsize + pkc->slen);
1534 pkc->cpy->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK);
1535 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
1536 GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc,
1537 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1541 /* end of fs_publish.c */