GNUnet 0.22.2
fs_publish.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
27#include "platform.h"
28#include "gnunet_constants.h"
29#include "gnunet_signatures.h"
30#include "gnunet_util_lib.h"
31
32#include "gnunet_fs_service.h"
33#include "fs_api.h"
34#include "fs_tree.h"
35
36
47void *
50 const struct GNUNET_FS_FileInformation *p,
51 uint64_t offset)
52{
53 pi->value.publish.pc = pc;
54 pi->value.publish.fi = p;
55 pi->value.publish.cctx = p->client_info;
56 pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info;
57 pi->value.publish.filename = p->filename;
58 pi->value.publish.size =
59 (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size :
60 p->data.file.file_size;
61 pi->value.publish.eta =
62 GNUNET_TIME_calculate_eta (p->start_time, offset,
63 pi->value.publish.size);
64 pi->value.publish.completed = offset;
65 pi->value.publish.duration =
67 pi->value.publish.anonymity = p->bo.anonymity_level;
68 pi->fsh = pc->h;
69 return pc->h->upcb (pc->h->upcb_cls, pi);
70}
71
72
78static void
80{
82 "Cleaning up publish context (done!)\n");
83 if (NULL != pc->fhc)
84 {
86 pc->fhc = NULL;
87 }
92 if (NULL != pc->dsh)
93 {
95 pc->dsh = NULL;
96 }
97 if (NULL != pc->mq)
98 {
100 pc->mq = NULL;
101 }
102 GNUNET_assert (NULL == pc->upload_task);
103 GNUNET_free (pc);
104}
105
106
116static void
117ds_put_cont (void *cls,
118 int success,
120 const char *msg)
121{
122 struct GNUNET_FS_PublishContext *pc = cls;
123 struct GNUNET_FS_ProgressInfo pi;
124
125 pc->qre = NULL;
126 if (GNUNET_SYSERR == success)
127 {
129 _ ("Publishing failed: %s"),
130 msg);
133 pi.value.publish.specifics.error.message = pc->fi_pos->emsg;
136 if ((GNUNET_YES != pc->fi_pos->is_directory) &&
137 (NULL != pc->fi_pos->filename) &&
138 (GNUNET_YES == pc->any_done) &&
140 {
141 /* run unindex to clean up */
144 NULL);
145 }
146 return;
147 }
149 GNUNET_assert (NULL == pc->upload_task);
150 pc->upload_task =
153}
154
155
164static void
167{
168 struct GNUNET_FS_ProgressInfo pi;
169
172 pi.value.publish.specifics.completed.chk_uri = p->chk_uri;
173 pi.value.publish.specifics.completed.sks_uri = p->sks_uri;
174 p->client_info =
176 p->data.file.file_size);
177}
178
179
189static void
192 const char *emsg)
193{
194 struct GNUNET_FS_ProgressInfo pi;
195
196 p->emsg = GNUNET_strdup (emsg);
199 pi.value.publish.specifics.error.message = emsg;
200 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
201 if ((p->is_directory != GNUNET_YES) &&
202 (NULL != p->filename) &&
203 (GNUNET_YES == pc->any_done) &&
204 (p->data.file.do_index == GNUNET_YES))
205 {
206 /* run unindex to clean up */
208 p->filename,
209 NULL);
210 }
211}
212
213
222static void
223finish_release_reserve (void *cls, int success,
225 const char *msg)
226{
227 struct GNUNET_FS_PublishContext *pc = cls;
228
229 pc->qre = NULL;
231 "Releasing reserve done!\n");
235}
236
237
246static void
248 const struct GNUNET_FS_Uri *uri,
249 const char *emsg)
250{
251 struct GNUNET_FS_PublishContext *pc = cls;
252
253 pc->sks_pc = NULL;
254 if (NULL != emsg)
255 {
256 signal_publish_error (pc->fi, pc, emsg);
258 return;
259 }
260 if (NULL != uri)
261 {
262 /* sks publication, remember namespace URI */
264 }
265 GNUNET_assert (pc->qre == NULL);
266 if ((pc->dsh != NULL) && (pc->rid != 0))
267 {
268 pc->qre =
269 GNUNET_DATASTORE_release_reserve (pc->dsh, pc->rid, UINT_MAX, UINT_MAX,
271 }
272 else
273 {
275 }
276}
277
278
285static void
287{
288 if (NULL != pc->ns)
290 pc->ns,
291 pc->nid,
292 pc->nuid,
293 pc->fi->meta,
294 pc->fi->chk_uri,
295 &pc->fi->bo,
296 pc->options,
298 else
299 publish_sblocks_cont (pc, NULL, NULL);
300}
301
302
312static void
314 const struct GNUNET_FS_Uri *uri,
315 const char *emsg)
316{
317 struct GNUNET_FS_PublishContext *pc = cls;
319
320 pc->ksk_pc = NULL;
321 if (NULL != emsg)
322 {
324 "Error uploading KSK blocks: %s\n",
325 emsg);
329 GNUNET_assert (NULL == pc->upload_task);
330 pc->upload_task =
334 pc);
335 return;
336 }
338 "KSK blocks published, moving on to next file\n");
339 if (NULL != p->dir)
341 /* move on to next file */
342 if (NULL != p->next)
343 pc->fi_pos = p->next;
344 else
345 pc->fi_pos = p->dir;
347 GNUNET_assert (NULL == pc->upload_task);
348 pc->upload_task =
351}
352
353
367static size_t
368block_reader (void *cls,
369 uint64_t offset,
370 size_t max,
371 void *buf,
372 char **emsg)
373{
374 struct GNUNET_FS_PublishContext *pc = cls;
376 const char *dd;
377 size_t pt_size;
378
379 p = pc->fi_pos;
380 if (GNUNET_YES == p->is_directory)
381 {
382 pt_size = GNUNET_MIN (max, p->data.dir.dir_size - offset);
383 dd = p->data.dir.dir_data;
384 GNUNET_memcpy (buf, &dd[offset], pt_size);
385 }
386 else
387 {
388 if (UINT64_MAX == offset)
389 {
390 if (&GNUNET_FS_data_reader_file_ == p->data.file.reader)
391 {
392 /* force closing the file to avoid keeping too many files open */
393 p->data.file.reader (p->data.file.reader_cls, offset, 0, NULL, NULL);
394 }
395 return 0;
396 }
397 pt_size = GNUNET_MIN (max, p->data.file.file_size - offset);
398 if (0 == pt_size)
399 return 0; /* calling reader with pt_size==0
400 * might free buf, so don't! */
401 if (pt_size !=
402 p->data.file.reader (p->data.file.reader_cls, offset, pt_size, buf,
403 emsg))
404 return 0;
405 }
406 return pt_size;
407}
408
409
417static void
418encode_cont (void *cls)
419{
420 struct GNUNET_FS_PublishContext *pc = cls;
422 struct GNUNET_FS_ProgressInfo pi;
423 char *emsg;
424 uint64_t flen;
425
427 "Finished with tree encoder\n");
428 p = pc->fi_pos;
429 p->chk_uri = GNUNET_FS_tree_encoder_get_uri (p->te);
431 GNUNET_FS_tree_encoder_finish (p->te, &emsg);
432 p->te = NULL;
433 if (NULL != emsg)
434 {
436 "Error during tree walk: %s\n",
437 emsg);
438 GNUNET_asprintf (&p->emsg,
439 _ ("Publishing failed: %s"),
440 emsg);
441 GNUNET_free (emsg);
444 pi.value.publish.specifics.error.message = p->emsg;
445 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
446 }
447 else
448 {
449 /* final progress event */
450 GNUNET_assert (NULL != p->chk_uri);
451 flen = GNUNET_FS_uri_chk_get_file_size (p->chk_uri);
453 pi.value.publish.specifics.progress.data = NULL;
454 pi.value.publish.specifics.progress.offset = flen;
455 pi.value.publish.specifics.progress.data_len = 0;
456 pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen);
457 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, flen);
458 }
459 /* continue with main */ /* continue with main */
460 GNUNET_assert (NULL == pc->upload_task);
461 pc->upload_task =
464}
465
466
481static void
482block_proc (void *cls,
483 const struct ContentHashKey *chk,
484 uint64_t offset,
485 unsigned int depth,
487 const void *block,
488 uint16_t block_size)
489{
490 struct GNUNET_FS_PublishContext *pc = cls;
492 struct OnDemandBlock odb;
493
494 p = pc->fi_pos;
495 if (NULL == pc->dsh)
496 {
498 "Waiting for datastore connection\n");
499 GNUNET_assert (NULL == pc->upload_task);
500 pc->upload_task =
503 return;
504 }
505
506 if ((GNUNET_YES != p->is_directory) &&
507 (GNUNET_YES == p->data.file.do_index) &&
509 {
511 "Indexing block `%s' for offset %llu with index size %u\n",
512 GNUNET_h2s (&chk->query),
513 (unsigned long long) offset,
514 (unsigned int) sizeof(struct OnDemandBlock));
516 odb.file_id = p->data.file.file_id;
517 GNUNET_assert (pc->qre == NULL);
518 pc->qre =
520 (p->is_directory == GNUNET_YES) ? 0 : pc->rid,
521 &chk->query,
522 sizeof(struct OnDemandBlock),
523 &odb,
525 p->bo.content_priority,
526 p->bo.anonymity_level,
527 p->bo.replication_level,
528 p->bo.expiration_time,
529 -2, 1,
530 &ds_put_cont, pc);
531 return;
532 }
534 "Publishing block `%s' for offset %llu with size %u\n",
535 GNUNET_h2s (&chk->query),
536 (unsigned long long) offset,
537 (unsigned int) block_size);
538 GNUNET_assert (pc->qre == NULL);
539 pc->qre =
540 GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 :
541 pc->rid,
542 &chk->query,
543 block_size,
544 block,
545 type,
546 p->bo.content_priority,
547 p->bo.anonymity_level,
548 p->bo.replication_level,
549 p->bo.expiration_time,
550 -2, 1,
552 pc);
553}
554
555
566static void
567progress_proc (void *cls, uint64_t offset,
568 const void *pt_block,
569 size_t pt_size,
570 unsigned int depth)
571{
572 struct GNUNET_FS_PublishContext *pc = cls;
574 struct GNUNET_FS_FileInformation *par;
575 struct GNUNET_FS_ProgressInfo pi;
576
577 p = pc->fi_pos;
579 pi.value.publish.specifics.progress.data = pt_block;
580 pi.value.publish.specifics.progress.offset = offset;
581 pi.value.publish.specifics.progress.data_len = pt_size;
582 pi.value.publish.specifics.progress.depth = depth;
583 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, offset);
584 if ((0 != depth) ||
585 (GNUNET_YES == p->is_directory))
586 return;
587 while (NULL != (par = p->dir))
588 {
589 p = par;
591 p->data.dir.contents_completed += pt_size;
593 pi.value.publish.specifics.progress_directory.completed =
594 p->data.dir.contents_completed;
595 pi.value.publish.specifics.progress_directory.total =
596 p->data.dir.contents_size;
597 pi.value.publish.specifics.progress_directory.eta =
598 GNUNET_TIME_calculate_eta (p->start_time,
599 p
600 ->data.dir.contents_completed,
601 p
602 ->data.dir.contents_size);
603 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
604 }
605}
606
607
615static void
617{
619 char *emsg;
621 struct GNUNET_FS_FileInformation *dirpos;
622 void *raw_data;
623 uint64_t size;
624
625 p = pc->fi_pos;
626 GNUNET_assert (NULL != p);
627 if (NULL == p->te)
628 {
629 if (GNUNET_YES == p->is_directory)
630 {
631 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n");
633 dirpos = p->data.dir.entries;
634 while (NULL != dirpos)
635 {
636 if (GNUNET_YES == dirpos->is_directory)
637 {
638 raw_data = dirpos->data.dir.dir_data;
639 dirpos->data.dir.dir_data = NULL;
640 }
641 else
642 {
643 raw_data = NULL;
644 if ((dirpos->data.file.file_size < MAX_INLINE_SIZE) &&
645 (dirpos->data.file.file_size > 0))
646 {
647 raw_data = GNUNET_malloc (dirpos->data.file.file_size);
648 emsg = NULL;
649 if (dirpos->data.file.file_size !=
650 dirpos->data.file.reader (dirpos->data.file.reader_cls, 0,
651 dirpos->data.file.file_size, raw_data,
652 &emsg))
653 {
655 GNUNET_free (raw_data);
656 raw_data = NULL;
657 }
658 dirpos->data.file.reader (dirpos->data.file.reader_cls, UINT64_MAX,
659 0, 0, NULL);
660 }
661 }
663 raw_data);
664 GNUNET_free (raw_data);
665 dirpos = dirpos->next;
666 }
667 GNUNET_free (p->data.dir.dir_data);
668 p->data.dir.dir_data = NULL;
669 p->data.dir.dir_size = 0;
670 GNUNET_FS_directory_builder_finish (db, &p->data.dir.dir_size,
671 &p->data.dir.dir_data);
673 }
674 size = (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size :
675 p->data.file.file_size;
677 "Creating tree encoder\n");
678 p->te =
681 &encode_cont);
682 }
684 "Processing next block from tree\n");
686}
687
688
696static int
698 const struct GNUNET_MessageHeader *msg)
699{
700 size_t msize = ntohs (msg->size) - sizeof(*msg);
701 const char *emsg = (const char *) &msg[1];
702
703 if (emsg[msize - 1] != '\0')
704 {
705 GNUNET_break (0);
706 return GNUNET_SYSERR;
707 }
708 return GNUNET_OK;
709}
710
711
719static void
721 const struct GNUNET_MessageHeader *msg)
722{
723 struct GNUNET_FS_PublishContext *pc = cls;
725 const char *emsg = (const char *) &msg[1];
726 char *msgtxt;
727
729 pc->mq = NULL;
730 p = pc->fi_pos;
731 GNUNET_asprintf (&msgtxt,
732 _ ("Can not index file `%s': %s.\n"),
733 p->filename,
734 gettext (emsg));
736 pc,
737 msgtxt);
738 GNUNET_free (msgtxt);
741}
742
743
751static void
753 const struct GNUNET_MessageHeader *msg)
754{
755 struct GNUNET_FS_PublishContext *pc = cls;
757
759 pc->mq = NULL;
760 p = pc->fi_pos;
761 p->data.file.index_start_confirmed = GNUNET_YES;
764}
765
766
775static void
777 enum GNUNET_MQ_Error error)
778{
779 struct GNUNET_FS_PublishContext *pc = cls;
781
782 if (NULL != pc->mq)
783 {
785 pc->mq = NULL;
786 }
787 p = pc->fi_pos;
789 _ ("Can not index file `%s': %s. Will try to insert instead.\n"),
790 p->filename,
791 _ ("error on index-start request to `fs' service"));
792 p->data.file.do_index = GNUNET_NO;
795}
796
797
805static void
807 const struct GNUNET_HashCode *res)
808{
809 struct GNUNET_FS_PublishContext *pc = cls;
811 GNUNET_MQ_hd_fixed_size (index_start_ok,
814 pc),
815 GNUNET_MQ_hd_var_size (index_start_failed,
818 pc),
820 };
822 struct GNUNET_MQ_Envelope *env;
823 struct IndexStartMessage *ism;
824 size_t slen;
825 uint64_t dev;
826 uint64_t ino;
827 char *fn;
828
829 pc->fhc = NULL;
830 p = pc->fi_pos;
831 if (NULL == res)
832 {
834 _ (
835 "Can not index file `%s': %s. Will try to insert instead.\n"),
836 p->filename,
837 _ ("failed to compute hash"));
838 p->data.file.do_index = GNUNET_NO;
841 return;
842 }
843 if (GNUNET_YES == p->data.file.index_start_confirmed)
844 {
846 return;
847 }
848 fn = GNUNET_STRINGS_filename_expand (p->filename);
849 GNUNET_assert (fn != NULL);
850 slen = strlen (fn) + 1;
851 if (slen >=
853 {
855 _
856 ("Can not index file `%s': %s. Will try to insert instead.\n"),
857 fn, _ ("filename too long"));
858 GNUNET_free (fn);
859 p->data.file.do_index = GNUNET_NO;
862 return;
863 }
865 "Hash of indexed file `%s' is `%s'\n",
866 p->filename,
867 GNUNET_h2s (res));
869 {
870 p->data.file.file_id = *res;
871 p->data.file.have_hash = GNUNET_YES;
872 p->data.file.index_start_confirmed = GNUNET_YES;
875 GNUNET_free (fn);
876 return;
877 }
879 "fs",
880 handlers,
882 pc);
883 if (NULL == pc->mq)
884 {
886 _ (
887 "Can not index file `%s': %s. Will try to insert instead.\n"),
888 p->filename,
889 _ ("could not connect to `fs' service"));
890 p->data.file.do_index = GNUNET_NO;
892 GNUNET_free (fn);
893 return;
894 }
895 if (p->data.file.have_hash != GNUNET_YES)
896 {
897 p->data.file.file_id = *res;
898 p->data.file.have_hash = GNUNET_YES;
900 }
902 slen,
904 if (GNUNET_OK ==
906 &dev,
907 &ino))
908 {
909 ism->device = GNUNET_htonll (dev);
910 ism->inode = GNUNET_htonll (ino);
911 }
912 else
913 {
915 _ ("Failed to get file identifiers for `%s'\n"),
916 p->filename);
917 }
918 ism->file_id = *res;
919 GNUNET_memcpy (&ism[1],
920 fn,
921 slen);
922 GNUNET_free (fn);
924 env);
925}
926
927
933static void
935{
937
938 p = pc->fi_pos;
939 /* upload of "p" complete, publish KBlocks! */
940 if (NULL != p->keywords)
941 {
943 p->keywords,
944 p->meta,
945 p->chk_uri,
946 &p->bo,
947 pc->options,
949 pc);
950 }
951 else
952 {
953 publish_kblocks_cont (pc, p->chk_uri, NULL);
954 }
955}
956
957
964static void
966 const struct ResponseLocSignatureMessage *sig)
967{
968 struct GNUNET_FS_PublishContext *pc = cls;
970
971 p = pc->fi_pos;
972 p->chk_uri->type = GNUNET_FS_URI_LOC;
973 /* p->data.loc.fi kept from CHK before */
974 p->chk_uri->data.loc.peer = sig->peer;
975 p->chk_uri->data.loc.expirationTime
977 p->chk_uri->data.loc.contentSignature = sig->signature;
981}
982
983
992static void
994 enum GNUNET_MQ_Error error)
995{
996 struct GNUNET_FS_PublishContext *pc = cls;
997
998 if (NULL != pc->mq)
999 {
1001 pc->mq = NULL;
1002 }
1004 _ ("Can not create LOC URI. Will continue with CHK instead.\n"));
1006}
1007
1008
1016static void
1018{
1020 GNUNET_MQ_hd_fixed_size (signature_response,
1023 pc),
1025 };
1026 struct GNUNET_MQ_Envelope *env;
1027 struct RequestLocSignatureMessage *req;
1029
1030 if (NULL != pc->mq)
1033 "fs",
1034 handlers,
1036 pc);
1037 if (NULL == pc->mq)
1038 {
1040 _ (
1041 "Can not create LOC URI. Will continue with CHK instead.\n"));
1043 return;
1044 }
1045 p = pc->fi_pos;
1046 env = GNUNET_MQ_msg (req,
1049 req->expiration_time = GNUNET_TIME_absolute_hton (p->bo.expiration_time);
1050 req->chk = p->chk_uri->data.chk.chk;
1051 req->file_length = GNUNET_htonll (p->chk_uri->data.chk.file_length);
1053 env);
1054}
1055
1056
1062void
1064{
1065 struct GNUNET_FS_PublishContext *pc = cls;
1066 struct GNUNET_FS_ProgressInfo pi;
1068 char *fn;
1069
1070 pc->upload_task = NULL;
1071 p = pc->fi_pos;
1072 if (NULL == p)
1073 {
1075 "Publishing complete, now publishing SKS and KSK blocks.\n");
1076 /* upload of entire hierarchy complete,
1077 * publish namespace entries */
1080 return;
1081 }
1082 /* find starting position */
1083 while ((GNUNET_YES == p->is_directory) &&
1084 (NULL != p->data.dir.entries) &&
1085 (NULL == p->emsg) &&
1086 (NULL == p->data.dir.entries->chk_uri))
1087 {
1088 p = p->data.dir.entries;
1089 pc->fi_pos = p;
1091 }
1092 /* abort on error */
1093 if (NULL != p->emsg)
1094 {
1096 "Error uploading: %s\n",
1097 p->emsg);
1098 /* error with current file, abort all
1099 * related files as well! */
1100 while (NULL != p->dir)
1101 {
1104 p = p->dir;
1105 if (fn != NULL)
1106 {
1107 GNUNET_asprintf (&p->emsg,
1108 _ ("Recursive upload failed at `%s': %s"),
1109 fn,
1110 p->emsg);
1111 GNUNET_free (fn);
1112 }
1113 else
1114 {
1115 GNUNET_asprintf (&p->emsg,
1116 _ ("Recursive upload failed: %s"),
1117 p->emsg);
1118 }
1121 pi.value.publish.specifics.error.message = p->emsg;
1122 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0);
1123 }
1126 return;
1127 }
1128 /* handle completion */
1129 if (NULL != p->chk_uri)
1130 {
1132 "File upload complete, now publishing KSK blocks.\n");
1134
1135 if ((0 == p->bo.anonymity_level) &&
1136 (GNUNET_YES !=
1137 GNUNET_FS_uri_test_loc (p->chk_uri)))
1138 {
1139 /* zero anonymity, box CHK URI in LOC URI */
1141 }
1142 else
1143 {
1145 }
1146 return;
1147 }
1148 if ((GNUNET_YES != p->is_directory) && (p->data.file.do_index))
1149 {
1150 if (NULL == p->filename)
1151 {
1152 p->data.file.do_index = GNUNET_NO;
1154 _ (
1155 "Can not index file `%s': %s. Will try to insert instead.\n"),
1156 "<no-name>",
1157 _ ("needs to be an actual file"));
1160 return;
1161 }
1162 if (p->data.file.have_hash)
1163 {
1164 hash_for_index_cb (pc, &p->data.file.file_id);
1165 }
1166 else
1167 {
1168 p->start_time = GNUNET_TIME_absolute_get ();
1169 pc->fhc =
1172 }
1173 return;
1174 }
1176}
1177
1178
1193static int
1195 struct GNUNET_FS_FileInformation *fi,
1196 uint64_t length,
1197 struct GNUNET_FS_MetaData *meta,
1198 struct GNUNET_FS_Uri **uri,
1199 struct GNUNET_FS_BlockOptions *bo,
1200 int *do_index,
1201 void **client_info)
1202{
1203 struct GNUNET_FS_PublishContext *pc = cls;
1204 struct GNUNET_FS_ProgressInfo pi;
1205 unsigned int kc;
1206 uint64_t left;
1207
1209 {
1211 return GNUNET_OK;
1212 }
1214 "Starting publish operation\n");
1215 if (*do_index)
1216 {
1217 /* space for on-demand blocks */
1218 pc->reserve_space +=
1219 ((length + DBLOCK_SIZE
1220 - 1) / DBLOCK_SIZE) * sizeof(struct OnDemandBlock);
1221 }
1222 else
1223 {
1224 /* space for DBlocks */
1225 pc->reserve_space += length;
1226 }
1227 /* entries for IBlocks and DBlocks, space for IBlocks */
1228 left = length;
1229 while (1)
1230 {
1231 left = (left + DBLOCK_SIZE - 1) / DBLOCK_SIZE;
1232 pc->reserve_entries += left;
1233 if (left <= 1)
1234 break;
1235 left = left * sizeof(struct ContentHashKey);
1236 pc->reserve_space += left;
1237 }
1239 /* entries and space for keywords */
1240 if (NULL != *uri)
1241 {
1243 pc->reserve_entries += kc;
1245 }
1247 *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0);
1249 if ((fi->is_directory) && (fi->dir != NULL))
1250 {
1251 /* We are a directory, and we are not top-level; process entries in directory */
1254 }
1255 return GNUNET_OK;
1256}
1257
1258
1266static void
1269{
1270 struct GNUNET_FS_ProgressInfo pi;
1271 uint64_t off;
1272
1273 if (NULL != pc->ksk_pc)
1274 {
1276 pc->ksk_pc = NULL;
1277 }
1278 if (NULL != pc->sks_pc)
1279 {
1281 pc->sks_pc = NULL;
1282 }
1284 "Suspending publish operation\n");
1286 fi->serialization = NULL;
1287 off = (NULL == fi->chk_uri) ? 0 : (GNUNET_YES == fi->is_directory) ?
1290 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1291 if (NULL != pc->qre)
1292 {
1294 pc->qre = NULL;
1295 }
1296 if (NULL != pc->dsh)
1297 {
1299 pc->dsh = NULL;
1300 }
1301 pc->rid = 0;
1302}
1303
1304
1319static int
1322 uint64_t length,
1323 struct GNUNET_FS_MetaData *meta,
1324 struct GNUNET_FS_Uri **uri,
1325 struct GNUNET_FS_BlockOptions *bo,
1326 int *do_index,
1327 void **client_info)
1328{
1329 struct GNUNET_FS_PublishContext *pc = cls;
1330
1332 {
1334 return GNUNET_OK;
1335 }
1337 {
1338 /* process entries in directory */
1341 }
1343 *client_info = NULL;
1344 return GNUNET_OK;
1345}
1346
1347
1354void
1356{
1357 struct GNUNET_FS_PublishContext *pc = cls;
1358
1359 if (NULL != pc->upload_task)
1360 {
1362 pc->upload_task = NULL;
1363 }
1368 pc->top = NULL;
1370}
1371
1372
1382static void
1384 int success,
1386 const char *msg)
1387{
1388 struct GNUNET_FS_PublishContext *pc = cls;
1389
1390 pc->qre = NULL;
1392 "Reservation complete (%d)!\n",
1393 success);
1394 if ((msg != NULL) || (success <= 0))
1395 {
1397 _ ("Datastore failure: %s"),
1398 msg);
1400 return;
1401 }
1402 pc->rid = success;
1403 GNUNET_assert (NULL == pc->upload_task);
1404 pc->upload_task =
1407}
1408
1409
1415static uint64_t
1417{
1418 struct GNUNET_FS_FileInformation *ent;
1419
1420 if (GNUNET_YES != fi->is_directory)
1421 return fi->data.file.file_size;
1422 fi->data.dir.contents_size = 0;
1423 for (ent = fi->data.dir.entries; NULL != ent; ent = ent->next)
1425 return fi->data.dir.contents_size;
1426}
1427
1428
1445 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
1446 const char *nid,
1447 const char *nuid,
1449{
1452
1453 GNUNET_assert (NULL != h);
1456 {
1458 if (NULL == dsh)
1459 return NULL;
1460 }
1461 else
1462 {
1463 dsh = NULL;
1464 }
1466 ret->dsh = dsh;
1467 ret->h = h;
1468 ret->fi = fi;
1469 if (NULL != ns)
1470 {
1472 *ret->ns = *ns;
1473 GNUNET_assert (NULL != nid);
1474 ret->nid = GNUNET_strdup (nid);
1475 if (NULL != nuid)
1476 ret->nuid = GNUNET_strdup (nuid);
1477 }
1478 ret->options = options;
1479 /* signal start */
1481 ret->fi_pos = ret->fi;
1484 if (NULL != ret->dsh)
1485 {
1486 GNUNET_assert (NULL == ret->qre);
1488 _ (
1489 "Reserving space for %u entries and %llu bytes for publication\n"),
1490 (unsigned int) ret->reserve_entries,
1491 (unsigned long long) ret->reserve_space);
1492 ret->qre =
1493 GNUNET_DATASTORE_reserve (ret->dsh, ret->reserve_space,
1494 ret->reserve_entries,
1496 ret);
1497 }
1498 else
1499 {
1500 GNUNET_assert (NULL == ret->upload_task);
1501 ret->upload_task =
1504 }
1505 return ret;
1506}
1507
1508
1523static int
1525 struct GNUNET_FS_FileInformation *fi,
1526 uint64_t length,
1527 struct GNUNET_FS_MetaData *meta,
1528 struct GNUNET_FS_Uri **uri,
1529 struct GNUNET_FS_BlockOptions *bo,
1530 int *do_index, void **client_info)
1531{
1532 struct GNUNET_FS_PublishContext *pc = cls;
1533 struct GNUNET_FS_ProgressInfo pi;
1534 uint64_t off;
1535
1537 {
1539 return GNUNET_OK;
1540 }
1542 {
1543 /* process entries in directory first */
1546 }
1547 if (NULL != fi->serialization)
1548 {
1550 fi->serialization);
1552 fi->serialization = NULL;
1553 }
1554 off = (fi->chk_uri == NULL) ? 0 : length;
1556 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1557 *client_info = NULL;
1558 return GNUNET_OK;
1559}
1560
1561
1570void
1572{
1573 struct GNUNET_FS_ProgressInfo pi;
1574 uint64_t off;
1575
1577 "Publish stop called\n");
1579 if (NULL != pc->ksk_pc)
1580 {
1582 pc->ksk_pc = NULL;
1583 }
1584 if (NULL != pc->sks_pc)
1585 {
1587 pc->sks_pc = NULL;
1588 }
1589 if (NULL != pc->upload_task)
1590 {
1592 pc->upload_task = NULL;
1593 }
1596
1597 if (NULL != pc->fi->serialization)
1598 {
1600 pc->fi->serialization);
1602 pc->fi->serialization = NULL;
1603 }
1604 off = (NULL == pc->fi->chk_uri) ? 0 : GNUNET_ntohll (
1606
1607 if (NULL != pc->serialization)
1608 {
1610 pc->serialization);
1612 pc->serialization = NULL;
1613 }
1614 if (NULL != pc->qre)
1615 {
1617 pc->qre = NULL;
1618 }
1620 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi, off));
1622}
1623
1624
1625/* end of fs_publish.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:48
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:41
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
Definition: fs_api.c:728
struct TopLevelActivity * GNUNET_FS_make_top(struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, void *ssf_cls)
Create a top-level activity entry.
Definition: fs_api.c:381
void GNUNET_FS_file_information_sync_(struct GNUNET_FS_FileInformation *fi)
Create a temporary file on disk to store the current state of fi in.
Definition: fs_api.c:1328
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:447
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:402
void GNUNET_FS_publish_sync_(struct GNUNET_FS_PublishContext *pc)
Synchronize this publishing struct with its mirror on disk.
Definition: fs_api.c:1753
shared definitions for the FS library
#define MAX_INLINE_SIZE
Maximum size for a file to be considered for inlining in a directory.
Definition: fs_api.h:50
@ GNUNET_FS_URI_LOC
Location (chk with identity of hosting peer).
Definition: fs_api.h:159
#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH
Name of the directory with publishing operations.
Definition: fs_api.h:77
#define GNUNET_FS_SYNC_PATH_FILE_INFO
Name of the directory with files that are being published.
Definition: fs_api.h:82
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.
Definition: fs_publish.c:697
static int fip_signal_suspend(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS's progress function that we are suspending an upload.
Definition: fs_publish.c:1320
static int fip_signal_stop(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS's progress function that we are stopping an upload.
Definition: fs_publish.c:1524
static void encode_cont(void *cls)
The tree encoder has finished processing a file.
Definition: fs_publish.c:418
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:567
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.
Definition: fs_publish.c:752
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...
Definition: fs_publish.c:1355
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.
Definition: fs_publish.c:720
static void publish_cleanup(struct GNUNET_FS_PublishContext *pc)
Cleanup the publish context, we're done with it.
Definition: fs_publish.c:79
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:368
static void publish_content(struct GNUNET_FS_PublishContext *pc)
We are uploading a file or directory; load (if necessary) the next block into memory,...
Definition: fs_publish.c:616
static void 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:223
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.
Definition: fs_publish.c:313
void * GNUNET_FS_publish_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_PublishContext *pc, const struct GNUNET_FS_FileInformation *p, uint64_t offset)
Fill in all of the generic fields for a publish event and call the callback.
Definition: fs_publish.c:48
static 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:776
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:190
static void create_loc_uri(struct GNUNET_FS_PublishContext *pc)
We're publishing without anonymity.
Definition: fs_publish.c:1017
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:247
static void publish_sblock(struct GNUNET_FS_PublishContext *pc)
We are almost done publishing the structure, add SBlocks (if needed).
Definition: fs_publish.c:286
static void publish_kblocks(struct GNUNET_FS_PublishContext *pc)
We've computed the CHK/LOC URI, now publish the KSKs (if applicable).
Definition: fs_publish.c:934
static void 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:117
static void handle_signature_response(void *cls, const struct ResponseLocSignatureMessage *sig)
Process the response from the "fs" service to our LOC sign request.
Definition: fs_publish.c:965
static void hash_for_index_cb(void *cls, const struct GNUNET_HashCode *res)
Function called once the hash computation over an indexed file has completed.
Definition: fs_publish.c:806
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:482
static int fip_signal_start(void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
Signal the FS's progress function that we are starting an upload.
Definition: fs_publish.c:1194
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:1416
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:993
static void suspend_operation(struct GNUNET_FS_FileInformation *fi, struct GNUNET_FS_PublishContext *pc)
Actually signal the FS's progress function that we are suspending an upload.
Definition: fs_publish.c:1267
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.
Definition: fs_publish.c:1383
void GNUNET_FS_publish_main_(void *cls)
Main function that performs the upload.
Definition: fs_publish.c:1063
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:165
void GNUNET_FS_tree_encoder_next(struct GNUNET_FS_TreeEncoder *te)
Encrypt the next block of the file (and call proc and progress accordingly; or of course "cont" if we...
Definition: fs_tree.c:320
unsigned int GNUNET_FS_compute_depth(uint64_t flen)
Compute the depth of the CHK tree.
Definition: fs_tree.c:125
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
Definition: fs_tree.c:432
struct GNUNET_FS_TreeEncoder * GNUNET_FS_tree_encoder_create(struct GNUNET_FS_Handle *h, uint64_t size, void *cls, GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_TaskCallback cont)
Initialize a tree encoder.
Definition: fs_tree.c:258
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:413
Merkle-tree-ish-CHK file encoding for GNUnet.
#define gettext(Msgid)
Definition: gettext.h:50
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
static int ret
Final status code.
Definition: gnunet-arm.c:93
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
static char * res
Currently read line or NULL on EOF.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static struct GNUNET_FS_DirectoryBuilder * db
static struct GNUNET_TIME_Absolute min_expiration
Minimum time that content should have to not be discarded instantly (time stamp of any content that w...
static struct GNUNET_DATASTORE_Handle * dsh
Datastore handle.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_FS_DBLOCK
Data block (leaf) in the CHK tree.
@ GNUNET_BLOCK_TYPE_FS_ONDEMAND
Type of a block representing a block to be encoded on demand from disk.
API for file sharing via GNUnet.
#define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT
Signature by which a peer affirms that it is providing a certain bit of content for use in LOCation U...
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
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:1060
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_reserve(struct GNUNET_DATASTORE_Handle *h, uint64_t amount, uint32_t entries, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Reserve space in the datastore.
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
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.
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...
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
enum GNUNET_GenericReturnValue 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:241
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:987
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
struct GNUNET_FS_PublishContext * GNUNET_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.
Definition: fs_publish.c:1443
int GNUNET_FS_directory_builder_finish(struct GNUNET_FS_DirectoryBuilder *bld, size_t *rsize, void **rdata)
Finish building the directory.
Definition: fs_directory.c:578
void GNUNET_FS_publish_ksk_cancel(struct GNUNET_FS_PublishKskContext *pkc)
Abort the KSK publishing operation.
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
Definition: fs_uri.c:1360
struct GNUNET_FS_PublishKskContext * GNUNET_FS_publish_ksk(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_FS_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 KBlock on GNUnet.
void GNUNET_FS_file_information_inspect(struct GNUNET_FS_FileInformation *dir, GNUNET_FS_FileInformationProcessor proc, void *proc_cls)
Inspect a file or directory in a publish-structure.
int GNUNET_FS_uri_test_loc(const struct GNUNET_FS_Uri *uri)
Is this a location URI?
Definition: fs_uri.c:1401
GNUNET_FS_PublishOptions
Options for publishing.
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_FS_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:432
struct GNUNET_FS_DirectoryBuilder * GNUNET_FS_directory_builder_create(const struct GNUNET_FS_MetaData *mdir)
Create a directory builder.
Definition: fs_directory.c:366
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_FS_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:55
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:711
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop an upload.
Definition: fs_publish.c:1571
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:796
void GNUNET_FS_file_information_destroy(struct GNUNET_FS_FileInformation *fi, GNUNET_FS_FileInformationProcessor cleaner, void *cleaner_cls)
Destroy publish-structure.
void GNUNET_FS_directory_builder_add(struct GNUNET_FS_DirectoryBuilder *bld, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *md, const void *data)
Add an entry to a directory.
Definition: fs_directory.c:392
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:495
@ GNUNET_FS_STATUS_PUBLISH_STOPPED
Notification that we have stopped the process of uploading a file structure; no further events will b...
@ GNUNET_FS_STATUS_PUBLISH_ERROR
Notification that an error was encountered sharing a file structure.
@ GNUNET_FS_STATUS_PUBLISH_SUSPEND
Notification that we have suspended sharing a file structure.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS
Notification that we are making progress sharing a file structure.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY
Notification that we are making progress sharing a directory.
@ GNUNET_FS_STATUS_PUBLISH_START
Notification that we have started to publish a file structure.
@ GNUNET_FS_STATUS_PUBLISH_COMPLETED
Notification that we completed sharing a file structure.
@ GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
Simulate publishing.
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.
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MIN(a, b)
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
@ GNUNET_SCHEDULER_PRIORITY_BACKGROUND
Run as background job (higher than idle, lower than default).
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_FS_meta_data_get_by_type(const struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type)
Get the first MD entry of the given type.
Definition: meta_data.c:438
GNUNET_MQ_Error
Error codes for the queue.
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:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#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:61
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START
Message sent by fs client to start indexing.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED
Response to a request for start indexing that refuses.
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN
Message sent by fs client to request LOC signature.
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE
Reply sent by fs service with LOC signature.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK
Affirmative response to a request for start indexing.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
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:1231
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:504
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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:438
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:741
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
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:566
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define _(String)
GNU gettext support macro.
Definition: platform.h:179
content hash key
Definition: fs.h:55
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Definition: fs.h:64
uint64_t file_length
Total size of the file in bytes.
Definition: fs_api.h:99
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Private ECC key encoded for transmission.
Handle to the datastore service.
Settings for publishing a block (which may of course also apply to an entire directory or file).
Internal state of a directory builder.
Definition: fs_directory.c:342
Information for a file or directory that is about to be published.
Definition: fs_api.h:228
char * serialization
Under what filename is this struct serialized (for operational persistence).
Definition: fs_api.h:287
char * filename
Name of the file or directory (must be an absolute path).
Definition: fs_api.h:302
size_t dir_size
Size of the directory itself (in bytes); 0 if the size has not yet been calculated.
Definition: fs_api.h:368
struct GNUNET_FS_FileInformation::@52::@53 file
Data for a file.
GNUNET_FS_DataReader reader
Function that can be used to read the data for the file.
Definition: fs_api.h:317
uint64_t file_size
Size of the file (in bytes).
Definition: fs_api.h:334
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:297
void * client_info
Pointer kept for the client.
Definition: fs_api.h:248
struct GNUNET_FS_FileInformation * next
Files in a directory are kept as a linked list.
Definition: fs_api.h:232
struct GNUNET_FS_BlockOptions bo
Block options for the file.
Definition: fs_api.h:275
struct GNUNET_FS_MetaData * meta
Metadata to use for the file.
Definition: fs_api.h:253
union GNUNET_FS_FileInformation::@52 data
Data describing either the file or the directory.
struct GNUNET_FS_Uri * sks_uri
SKS URI for this file or directory.
Definition: fs_api.h:270
void * dir_data
Pointer to the data for the directory (or NULL if not available).
Definition: fs_api.h:374
uint64_t contents_size
Sum of all of the sizes of all of the files in the directory.
Definition: fs_api.h:384
int do_index
Should the file be indexed or inserted?
Definition: fs_api.h:339
void * reader_cls
Closure for reader.
Definition: fs_api.h:322
struct GNUNET_FS_FileInformation * entries
Linked list of entries in the directory.
Definition: fs_api.h:362
struct GNUNET_FS_FileInformation * dir
If this is a file in a directory, "dir" refers to the directory; otherwise NULL.
Definition: fs_api.h:238
struct GNUNET_FS_Uri * chk_uri
CHK for this file or directory.
Definition: fs_api.h:264
int is_directory
Is this struct for a file or directory?
Definition: fs_api.h:391
Master context for most FS operations.
Definition: fs_api.h:1070
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1089
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1084
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1074
Meta data to associate with a file, directory or namespace.
Definition: meta_data.c:92
Argument given to the progress callback with information about what is going on.
struct GNUNET_FS_ProgressInfo::@21::GNUNET_FS_PublishStatusEvent publish
unsigned int depth
Depth of the given block in the tree; 0 would be the lowest level (DBLOCKs).
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
enum GNUNET_FS_Status status
Specific status code (determines the event type).
uint64_t offset
At what offset in the file is "data"?
union GNUNET_FS_ProgressInfo::@21 value
Values that depend on the event type.
const struct GNUNET_FS_FileInformation * fi
Information about the file that is being published.
Handle for controlling a publication process.
Definition: fs_api.h:1180
int skip_next_fi_callback
Flag set to GNUNET_YES if the next callback from GNUNET_FS_file_information_inspect should be skipped...
Definition: fs_api.h:1299
struct 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:1253
uint32_t reserve_entries
Overall number of entries to reserve for the publish operation.
Definition: fs_api.h:1270
enum GNUNET_FS_PublishOptions options
Options for publishing.
Definition: fs_api.h:1275
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service.
Definition: fs_api.h:1236
struct GNUNET_CRYPTO_FileHashContext * fhc
Non-null if we are currently hashing a file.
Definition: fs_api.h:1231
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1189
struct GNUNET_FS_FileInformation * fi_pos
Current position in the file-tree for the upload.
Definition: fs_api.h:1226
char * nuid
ID for future updates, NULL if we have no namespace or no updates.
Definition: fs_api.h:1209
int any_done
Set to GNUNET_YES if we were able to publish any block.
Definition: fs_api.h:1287
int all_done
Set to GNUNET_YES if all processing has completed.
Definition: fs_api.h:1292
struct GNUNET_DATASTORE_QueueEntry * qre
Queue entry for reservation/unreservation.
Definition: fs_api.h:1241
struct GNUNET_FS_FileInformation * fi
File-structure that is being shared.
Definition: fs_api.h:1194
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:1221
uint64_t reserve_space
Storage space to reserve for the operation.
Definition: fs_api.h:1264
char * nid
ID of the content in the namespace, NULL if we have no namespace.
Definition: fs_api.h:1204
struct GNUNET_FS_Handle * h
Handle to the global fs context.
Definition: fs_api.h:1184
struct GNUNET_CRYPTO_EcdsaPrivateKey * ns
Namespace that we are publishing in, NULL if we have no namespace.
Definition: fs_api.h:1199
struct GNUNET_SCHEDULER_Task * upload_task
ID of the task performing the upload.
Definition: fs_api.h:1259
int rid
Space reservation ID with datastore service for this upload.
Definition: fs_api.h:1281
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:1247
char * serialization
Filename used for serializing information about this operation (should be determined using 'mktemp').
Definition: fs_api.h:1215
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167
union GNUNET_FS_Uri::@49 data
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:212
A 512-bit hashcode.
Message handler for a specific message type.
Header for all communications.
Time for absolute times used by GNUnet, in microseconds.
Message sent from a GNUnet (fs) publishing activity to the gnunet-fs-service to initiate indexing of ...
Definition: fs.h:153
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:179
struct GNUNET_HashCode file_id
Hash of the file that we would like to index.
Definition: fs.h:184
uint64_t device
ID of device containing the file, as seen by the client.
Definition: fs.h:171
index block (indexing a DBlock that can be obtained directly from reading the plaintext file)
Definition: block_fs.h:86
uint64_t offset
At which offset should we be able to find this on-demand encoded block? (in NBO)
Definition: block_fs.h:98
struct GNUNET_HashCode file_id
Hash code of the entire content of the file that was indexed (used to uniquely identify the plaintext...
Definition: block_fs.h:92
Message sent from a GNUnet (fs) publishing activity to sign a LOC URI.
Definition: fs.h:76
uint64_t file_length
Size of the shared file (to be signed).
Definition: fs.h:101
uint32_t purpose
Requested signature purpose.
Definition: fs.h:86
struct GNUNET_TIME_AbsoluteNBO expiration_time
Requested expiration time.
Definition: fs.h:91
struct ContentHashKey chk
Information about the shared file (to be signed).
Definition: fs.h:96
Message sent from the service with the signed LOC URI.
Definition: fs.h:109
struct GNUNET_CRYPTO_EddsaSignature signature
The requested signature.
Definition: fs.h:130
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs.h:135
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time that was actually used (rounded!).
Definition: fs.h:125