GNUnet  0.11.x
fs_unindex.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2003--2013, 2016 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  */
20 
27 #include "platform.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_fs_service.h"
30 #include "gnunet_protocols.h"
31 #include "fs_api.h"
32 #include "fs_tree.h"
33 #include "block_fs.h"
34 #include "fs_publish_ublock.h"
35 
36 
50 static size_t
51 unindex_reader (void *cls,
52  uint64_t offset,
53  size_t max,
54  void *buf,
55  char **emsg)
56 {
57  struct GNUNET_FS_UnindexContext *uc = cls;
58  size_t pt_size;
59 
60  pt_size = GNUNET_MIN (max, uc->file_size - offset);
61  if (offset != GNUNET_DISK_file_seek (uc->fh, offset, GNUNET_DISK_SEEK_SET))
62  {
63  *emsg = GNUNET_strdup (_ ("Failed to find given position in file"));
64  return 0;
65  }
66  if (pt_size != GNUNET_DISK_file_read (uc->fh, buf, pt_size))
67  {
68  *emsg = GNUNET_strdup (_ ("Failed to read file"));
69  return 0;
70  }
71  return pt_size;
72 }
73 
74 
83 void
86  uint64_t offset)
87 {
88  pi->value.unindex.uc = uc;
89  pi->value.unindex.cctx = uc->client_info;
90  pi->value.unindex.filename = uc->filename;
91  pi->value.unindex.size = uc->file_size;
92  pi->value.unindex.eta =
94  pi->value.unindex.duration =
96  pi->value.unindex.completed = offset;
97  pi->fsh = uc->h;
98  uc->client_info = uc->h->upcb (uc->h->upcb_cls, pi);
99 }
100 
101 
112 static void
113 unindex_progress (void *cls,
114  uint64_t offset,
115  const void *pt_block,
116  size_t pt_size,
117  unsigned int depth)
118 {
119  struct GNUNET_FS_UnindexContext *uc = cls;
120  struct GNUNET_FS_ProgressInfo pi;
121 
123  pi.value.unindex.specifics.progress.data = pt_block;
124  pi.value.unindex.specifics.progress.offset = offset;
125  pi.value.unindex.specifics.progress.data_len = pt_size;
126  pi.value.unindex.specifics.progress.depth = depth;
127  GNUNET_FS_unindex_make_status_ (&pi, uc, offset);
128 }
129 
130 
137 static void
139 {
140  struct GNUNET_FS_ProgressInfo pi;
141 
144  pi.value.unindex.specifics.error.message = uc->emsg;
145  GNUNET_FS_unindex_make_status_ (&pi, uc, 0);
146 }
147 
148 
158 static void
159 process_cont (void *cls,
160  int success,
162  const char *msg)
163 {
164  struct GNUNET_FS_UnindexContext *uc = cls;
165 
166  if (success == GNUNET_SYSERR)
167  {
168  uc->emsg = GNUNET_strdup (msg);
170  return;
171  }
173  "Datastore REMOVE operation succeeded\n");
175 }
176 
177 
192 static void
193 unindex_process (void *cls,
194  const struct ContentHashKey *chk,
195  uint64_t offset,
196  unsigned int depth,
197  enum GNUNET_BLOCK_Type type,
198  const void *block,
199  uint16_t block_size)
200 {
201  struct GNUNET_FS_UnindexContext *uc = cls;
202  uint32_t size;
203  const void *data;
204  struct OnDemandBlock odb;
205 
206  if (type != GNUNET_BLOCK_TYPE_FS_DBLOCK)
207  {
208  size = block_size;
209  data = block;
210  }
211  else /* on-demand encoded DBLOCK */
212  {
213  size = sizeof(struct OnDemandBlock);
214  odb.offset = GNUNET_htonll (offset);
215  odb.file_id = uc->file_id;
216  data = &odb;
217  }
219  "Sending REMOVE request to DATASTORE service\n");
220  GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1,
221  &process_cont, uc);
222  uc->chk = *chk;
223 }
224 
225 
233 static void
235  const struct GNUNET_MessageHeader *msg)
236 {
237  struct GNUNET_FS_UnindexContext *uc = cls;
238  struct GNUNET_FS_ProgressInfo pi;
239 
240  if (NULL != uc->mq)
241  {
242  GNUNET_MQ_destroy (uc->mq);
243  uc->mq = NULL;
244  }
250  uc,
251  uc->file_size);
252 }
253 
254 
263 static void
265  enum GNUNET_MQ_Error error)
266 {
267  struct GNUNET_FS_UnindexContext *uc = cls;
268 
269  if (NULL != uc->mq)
270  {
271  GNUNET_MQ_destroy (uc->mq);
272  uc->mq = NULL;
273  }
275  uc->emsg = GNUNET_strdup (_ ("Error communicating with `fs' service."));
278 }
279 
280 
288 static void
290 {
291  struct GNUNET_MQ_MessageHandler handlers[] = {
292  GNUNET_MQ_hd_fixed_size (unindex_response,
294  struct GNUNET_MessageHeader,
295  uc),
297  };
298  char *emsg;
299  struct GNUNET_MQ_Envelope *env;
300  struct UnindexMessage *req;
301 
302  /* generate final progress message */
303  unindex_progress (uc,
304  uc->file_size,
305  NULL,
306  0,
307  0);
309  &emsg);
310  uc->tc = NULL;
312  uc->fh = NULL;
314  uc->dsh = NULL;
317  uc->mq = GNUNET_CLIENT_connect (uc->h->cfg,
318  "fs",
319  handlers,
321  uc);
322  if (NULL == uc->mq)
323  {
325  uc->emsg =
326  GNUNET_strdup (_ ("Failed to connect to FS service for unindexing."));
329  return;
330  }
332  "Sending UNINDEX message to FS service\n");
333  env = GNUNET_MQ_msg (req,
335  req->reserved = 0;
336  req->file_id = uc->file_id;
337  GNUNET_MQ_send (uc->mq,
338  env);
339 }
340 
341 
353 static void
355  const char *filename,
356  int is_directory,
358 {
359  struct GNUNET_FS_UnindexContext *uc = cls;
360  static struct GNUNET_FS_ShareTreeItem *directory_scan_result;
361 
362  switch (reason)
363  {
365  directory_scan_result = GNUNET_FS_directory_scan_get_result (uc->dscan);
366  uc->dscan = NULL;
367  if (NULL != directory_scan_result->ksk_uri)
368  {
369  uc->ksk_uri = GNUNET_FS_uri_dup (directory_scan_result->ksk_uri);
373  }
374  else
375  {
376  uc->emsg = GNUNET_strdup (_ ("Failed to get KSKs from directory scan."));
378  unindex_finish (uc);
379  }
380  GNUNET_FS_share_tree_free (directory_scan_result);
381  break;
382 
385  _ ("Internal error scanning `%s'.\n"),
386  uc->filename);
388  uc->dscan = NULL;
389  uc->emsg = GNUNET_strdup (_ ("Failed to get KSKs from directory scan."));
391  unindex_finish (uc);
392  break;
393 
394  default:
395  break;
396  }
397 }
398 
399 
405 void
407 {
408  char *ex;
409 
410  if (GNUNET_OK !=
411  GNUNET_CONFIGURATION_get_value_string (uc->h->cfg, "FS", "EXTRACTORS",
412  &ex))
413  ex = NULL;
415  GNUNET_NO, ex,
417  uc);
419 }
420 
421 
435 static void
437  int32_t success,
439  const char *msg)
440 {
441  struct GNUNET_FS_UnindexContext *uc = cls;
442 
443  uc->dqe = NULL;
444  if (success != GNUNET_YES)
446  _ ("Failed to remove UBlock: %s\n"),
447  msg);
448  uc->ksk_offset++;
450 }
451 
452 
475 static void
477  const struct GNUNET_HashCode *key,
478  size_t size,
479  const void *data,
480  enum GNUNET_BLOCK_Type type,
481  uint32_t priority,
482  uint32_t anonymity,
483  uint32_t replication,
485  uint64_t uid)
486 {
487  struct GNUNET_FS_UnindexContext *uc = cls;
488  const struct UBlock *ub;
489  struct GNUNET_FS_Uri *chk_uri;
490  struct GNUNET_HashCode query;
491 
492  uc->dqe = NULL;
493  if (NULL == data)
494  {
495  /* no result */
496  uc->ksk_offset++;
498  return;
499  }
501  if (size < sizeof(struct UBlock))
502  {
503  GNUNET_break (0);
504  goto get_next;
505  }
506  ub = data;
508  sizeof(ub->verification_key),
509  &query);
510  if (0 != memcmp (&query,
511  key,
512  sizeof(struct GNUNET_HashCode)))
513  {
514  /* result does not match our keyword, skip */
515  goto get_next;
516  }
517  {
518  char pt[size - sizeof(struct UBlock)];
519  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
520  const char *keyword;
521 
524  &anon_pub);
525  keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
526  GNUNET_FS_ublock_decrypt_ (&ub[1], size - sizeof(struct UBlock),
527  &anon_pub,
528  keyword,
529  pt);
530  if (NULL == memchr (&pt[1], 0, sizeof(pt) - 1))
531  {
532  GNUNET_break_op (0); /* malformed UBlock */
533  goto get_next;
534  }
535  chk_uri = GNUNET_FS_uri_parse (&pt[1], NULL);
536  if (NULL == chk_uri)
537  {
538  GNUNET_break_op (0); /* malformed UBlock */
539  goto get_next;
540  }
541  }
542  if (0 != memcmp (&uc->chk,
543  &chk_uri->data.chk.chk,
544  sizeof(struct ContentHashKey)))
545  {
546  /* different CHK, ignore */
547  GNUNET_FS_uri_destroy (chk_uri);
548  goto get_next;
549  }
550  GNUNET_FS_uri_destroy (chk_uri);
551  /* matches! */
552  uc->dqe = GNUNET_DATASTORE_remove (uc->dsh,
553  key,
554  size,
555  data,
556  0 /* priority */,
557  1 /* queue size */,
559  uc);
560  return;
561 get_next:
562  uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
563  uid + 1 /* next_uid */,
564  false /* random */,
565  &uc->uquery,
567  0 /* priority */,
568  1 /* queue size */,
570  uc);
571 }
572 
573 
579 void
581 {
582  const char *keyword;
583  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
584  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
585  struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
586 
587  if (NULL == uc->dsh)
588  uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
589  if (NULL == uc->dsh)
590  {
592  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
595  return;
596  }
597  if ((NULL == uc->ksk_uri) ||
598  (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount))
599  {
600  unindex_finish (uc);
601  return;
602  }
605  &anon_pub);
606  keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
608  keyword,
609  "fs-ublock",
610  &dpub);
611  GNUNET_CRYPTO_hash (&dpub,
612  sizeof(dpub),
613  &uc->uquery);
614  uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
615  0 /* next_uid */,
616  false /* random */,
617  &uc->uquery,
619  0 /* priority */,
620  1 /* queue size */,
622  uc);
623 }
624 
625 
632 static void
634 {
635  struct GNUNET_FS_UnindexContext *uc = cls;
636 
640 }
641 
642 
648 void
650 {
651  if (NULL == uc->dsh)
652  uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
653  if (NULL == uc->dsh)
654  {
656  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
659  return;
660  }
661  uc->fh =
664  if (NULL == uc->fh)
665  {
667  uc->dsh = NULL;
669  uc->emsg = GNUNET_strdup (_ ("Failed to open file for unindexing."));
672  return;
673  }
674  uc->tc =
676  uc->file_size,
677  uc,
683 }
684 
685 
693 void
695  const struct GNUNET_HashCode *file_id)
696 {
697  struct GNUNET_FS_UnindexContext *uc = cls;
698 
699  uc->fhc = NULL;
700  if (uc->state != UNINDEX_STATE_HASHING)
701  {
703  return;
704  }
705  if (file_id == NULL)
706  {
708  uc->emsg = GNUNET_strdup (_ ("Failed to compute hash of file."));
711  return;
712  }
713  uc->file_id = *file_id;
717 }
718 
719 
726 void
728 {
729  struct GNUNET_FS_UnindexContext *uc = cls;
730  struct GNUNET_FS_ProgressInfo pi;
731 
732  /* FIXME: lots of duplication with unindex_stop here! */
733  if (uc->dscan != NULL)
734  {
736  uc->dscan = NULL;
737  }
738  if (NULL != uc->dqe)
739  {
741  uc->dqe = NULL;
742  }
743  if (uc->fhc != NULL)
744  {
746  uc->fhc = NULL;
747  }
748  if (NULL != uc->ksk_uri)
749  {
751  uc->ksk_uri = NULL;
752  }
753  if (NULL != uc->mq)
754  {
755  GNUNET_MQ_destroy (uc->mq);
756  uc->mq = NULL;
757  }
758  if (NULL != uc->dsh)
759  {
761  uc->dsh = NULL;
762  }
763  if (NULL != uc->tc)
764  {
765  GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
766  uc->tc = NULL;
767  }
768  if (uc->fh != NULL)
769  {
771  uc->fh = NULL;
772  }
773  GNUNET_FS_end_top (uc->h, uc->top);
776  (uc->state ==
777  UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
778  GNUNET_break (NULL == uc->client_info);
779  GNUNET_free (uc->filename);
782  GNUNET_free (uc);
783 }
784 
785 
796  const char *filename,
797  void *cctx)
798 {
800  struct GNUNET_FS_ProgressInfo pi;
801  uint64_t size;
802 
803  if (GNUNET_OK !=
804  GNUNET_DISK_file_size (filename,
805  &size,
806  GNUNET_YES,
807  GNUNET_YES))
808  return NULL;
809  uc = GNUNET_new (struct GNUNET_FS_UnindexContext);
810  uc->h = h;
811  uc->filename = GNUNET_strdup (filename);
813  uc->file_size = size;
814  uc->client_info = cctx;
818  GNUNET_FS_unindex_make_status_ (&pi, uc, 0);
819  uc->fhc =
821  filename,
824  uc->top = GNUNET_FS_make_top (h,
826  uc);
827  return uc;
828 }
829 
830 
836 void
838 {
839  struct GNUNET_FS_ProgressInfo pi;
840 
841  if (NULL != uc->dscan)
842  {
844  uc->dscan = NULL;
845  }
846  if (NULL != uc->dqe)
847  {
849  uc->dqe = NULL;
850  }
851  if (NULL != uc->fhc)
852  {
854  uc->fhc = NULL;
855  }
856  if (NULL != uc->mq)
857  {
858  GNUNET_MQ_destroy (uc->mq);
859  uc->mq = NULL;
860  }
861  if (NULL != uc->dsh)
862  {
864  uc->dsh = NULL;
865  }
866  if (NULL != uc->ksk_uri)
867  {
869  uc->ksk_uri = NULL;
870  }
871  if (NULL != uc->tc)
872  {
873  GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
874  uc->tc = NULL;
875  }
876  if (uc->fh != NULL)
877  {
879  uc->fh = NULL;
880  }
881  GNUNET_FS_end_top (uc->h, uc->top);
882  if (uc->serialization != NULL)
883  {
885  uc->serialization);
887  uc->serialization = NULL;
888  }
892  (uc->state ==
893  UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
894  GNUNET_break (NULL == uc->client_info);
896  GNUNET_free (uc->filename);
897  GNUNET_free (uc);
898 }
899 
900 
901 /* end of fs_unindex.c */
unsigned int depth
Depth of the given block in the tree; 0 would be the lowest level (DBLOCKs).
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...
Open the file for reading.
char * serialization
Short name under which we are serializing the state of this operation.
Definition: fs_api.h:1390
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:812
static void signal_unindex_error(struct GNUNET_FS_UnindexContext *uc)
We&#39;ve encountered an error during unindexing.
Definition: fs_unindex.c:138
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:103
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
Definition: crypto_ecc.c:1337
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:837
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
uint32_t reserved
Always zero.
Definition: fs.h:236
Notification that we started to unindex a file.
static void unindex_progress(void *cls, uint64_t offset, const void *pt_block, size_t pt_size, unsigned int depth)
Function called with information about our progress in computing the tree encoding.
Definition: fs_unindex.c:113
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
struct GNUNET_FS_DirScanner * GNUNET_FS_directory_scan_start(const char *filename, int disable_extractor, const char *ex, GNUNET_FS_DirScannerProgressCallback cb, void *cb_cls)
Start a directory scanner thread.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
content hash key
Definition: fs.h:53
struct GNUNET_FS_TreeEncoder * tc
Merkle-ish tree encoder context.
Definition: fs_api.h:1412
uint32_t ksk_offset
Current offset in KSK removal.
Definition: fs_api.h:1380
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:732
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:644
Notification that we made progress unindexing a file.
GNUNET_MQ_Error
Error codes for the queue.
Master context for most FS operations.
Definition: fs_api.h:1068
We&#39;re done.
Definition: fs_api.h:1337
static void continue_after_remove(void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Continuation called to notify client about result of the remove operation for the UBlock...
Definition: fs_unindex.c:436
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_FS_ublock_decrypt_(const void *input, size_t input_len, const struct GNUNET_CRYPTO_EcdsaPublicKey *ns, const char *label, void *output)
Decrypt the given UBlock, storing the result in output.
static struct GNUNET_FS_UnindexContext * uc
static unsigned int replication
Nobody is allowed to do anything to the file.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
void GNUNET_FS_tree_encoder_next(struct GNUNET_FS_TreeEncoder *te)
Encrypt the next block of the file (and call proc and progress accordingly; or of course "cont" if we...
Definition: fs_tree.c:331
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
uint64_t offset
At what offset in the file is "data"?
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:226
struct GNUNET_HashCode file_id
Hash of the file&#39;s contents (once computed).
Definition: fs_api.h:1458
Notification that we suspended unindexing a file.
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1463
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.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle for controlling an unindexing operation.
Definition: fs_api.h:1349
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase...
Definition: fs_api.h:1402
struct GNUNET_FS_ProgressInfo::@25::@29 unindex
Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
static void unindex_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_unindex.c:264
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void unindex_process(void *cls, const struct ContentHashKey *chk, uint64_t offset, unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size)
Function called asking for the current (encoded) block to be processed.
Definition: fs_unindex.c:193
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1443
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
Find out which keywords apply.
Definition: fs_api.h:1321
We&#39;re notifying the FS service about the unindexing.
Definition: fs_api.h:1332
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
void GNUNET_FS_unindex_do_extract_keywords_(struct GNUNET_FS_UnindexContext *uc)
If necessary, connect to the datastore and remove the UBlocks.
Definition: fs_unindex.c:406
struct GNUNET_HashCode uquery
Current query of &#39;get_key&#39; operation.
Definition: fs_api.h:1433
struct TopLevelActivity * top
Our top-level activity entry.
Definition: fs_api.h:1365
A node of a directory tree (produced by dirscanner)
struct GNUNET_DISK_FileHandle * fh
Handle used to read the file.
Definition: fs_api.h:1417
struct GNUNET_FS_ProgressInfo::@25::@26::@30::@35 error
These values are only valid for GNUNET_FS_STATUS_PUBLISH_ERROR events.
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
Definition: fs_api.h:86
static void handle_unindex_response(void *cls, const struct GNUNET_MessageHeader *msg)
Function called with the response from the FS service to our unindexing request.
Definition: fs_unindex.c:234
void GNUNET_FS_unindex_do_remove_(struct GNUNET_FS_UnindexContext *uc)
Connect to the datastore and remove the blocks.
Definition: fs_unindex.c:649
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
struct GNUNET_FS_UnindexContext * GNUNET_FS_unindex_start(struct GNUNET_FS_Handle *h, const char *filename, void *cctx)
Unindex a file.
Definition: fs_unindex.c:795
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
void GNUNET_FS_unindex_do_remove_kblocks_(struct GNUNET_FS_UnindexContext *uc)
If necessary, connect to the datastore and remove the KBlocks.
Definition: fs_unindex.c:580
enum GNUNET_FS_Status status
Specific status code (determines the event type).
We&#39;re telling the datastore to remove KBlocks.
Definition: fs_api.h:1326
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Definition: fs.h:63
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:80
Message sent from a GNUnet (fs) unindexing activity to the gnunet-service-fs to indicate that a file ...
Definition: fs.h:226
struct GNUNET_HashCode file_id
Hash of the file that we will unindex.
Definition: fs.h:241
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1453
static char buf[2048]
static char * filename
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
We&#39;ve encountered a fatal error.
Definition: fs_api.h:1342
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_remove(struct GNUNET_DATASTORE_Handle *h, const struct GNUNET_HashCode *key, size_t size, const void *data, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Explicitly remove some content from the database.
struct GNUNET_FS_TreeEncoder * GNUNET_FS_tree_encoder_create(struct GNUNET_FS_Handle *h, uint64_t size, void *cls, GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_TaskCallback cont)
Initialize a tree encoder.
Definition: fs_tree.c:269
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
There was an internal error.
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1375
Type of a block representing any type of search result (universal).
A 512-bit hashcode.
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1385
Message handler for a specific message type.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK
Reply to client indicating unindex receipt.
struct GNUNET_DATASTORE_QueueEntry * dqe
Handle to datastore &#39;get_key&#39; operation issued for obtaining KBlocks.
Definition: fs_api.h:1423
GNUNET_FS_DirScannerProgressUpdateReason
Progress reasons of the directory scanner.
Run when otherwise idle.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Handle * mq
Connection to the FS service, only valid during the UNINDEX_STATE_FS_NOTIFY phase.
Definition: fs_api.h:1396
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:239
Notification that the unindexing of this file was stopped (final event for this action).
Last call to the progress function: we have finished scanning the directory.
Notification that the unindexing of this file was completed.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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:88
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX
Request from client to unindex a file.
void GNUNET_FS_unindex_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_UnindexContext *uc, uint64_t offset)
Fill in all of the generic fields for an unindex event and call the callback.
Definition: fs_unindex.c:84
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1778
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
int GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:257
union GNUNET_FS_Uri::@13 data
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
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:391
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
static void unindex_finish(struct GNUNET_FS_UnindexContext *uc)
Function called when we are done with removing UBlocks.
Definition: fs_unindex.c:289
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1083
static void process_kblock_for_unindex(void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
Function called from datastore with result from us looking for a UBlock.
Definition: fs_unindex.c:476
We&#39;re currently hashing the file.
Definition: fs_api.h:1310
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:47
Seek an absolute position (from the start of the file).
shared definitions for the FS library
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
We&#39;re telling the datastore to delete the respective DBlocks and IBlocks.
Definition: fs_api.h:1316
void GNUNET_FS_share_tree_free(struct GNUNET_FS_ShareTreeItem *toplevel)
Release memory of a share item tree.
Definition: fs_sharetree.c:436
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:375
static void unindex_directory_scan_cb(void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason)
Function called by the directory scanner as we extract keywords that we will need to remove UBlocks...
Definition: fs_unindex.c:354
static void process_cont(void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Continuation called to notify client about result of the datastore removal operation.
Definition: fs_unindex.c:159
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_FS_DirScanner * dscan
Directory scanner to find keywords (KBlock removal).
Definition: fs_api.h:1370
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1088
struct GNUNET_FS_Uri::@13::@14 ksk
void GNUNET_FS_unindex_process_hash_(void *cls, const struct GNUNET_HashCode *file_id)
Function called once the hash of the file that is being unindexed has been computed.
Definition: fs_unindex.c:694
struct ContentHashKey chk
The content hash key of the last block we processed, will in the end be set to the CHK from the URI...
Definition: fs_api.h:1355
#define GNUNET_log(kind,...)
uint64_t offset
At which offset should we be able to find this on-demand encoded block? (in NBO)
Definition: block_fs.h:94
Data block (leaf) in the CHK tree.
static void unindex_extract_keywords(void *cls)
Function called when the tree encoder has processed all blocks.
Definition: fs_unindex.c:633
struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta(struct GNUNET_TIME_Absolute start, uint64_t finished, uint64_t total)
Calculate the estimate time of arrival/completion for an operation.
Definition: time.c:551
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1438
Header for all communications.
void GNUNET_FS_unindex_signal_suspend_(void *cls)
Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal...
Definition: fs_unindex.c:727
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
Definition: fs_tree.c:443
struct GNUNET_FS_ShareTreeItem * GNUNET_FS_directory_scan_get_result(struct GNUNET_FS_DirScanner *ds)
Obtain the result of the scan after the scan has signalled completion.
Time for absolute times used by GNUnet, in microseconds.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_YES
Definition: gnunet_common.h:77
static unsigned int anonymity
static size_t unindex_reader(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the ...
Definition: fs_unindex.c:51
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_key(struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
Get a result for a particular key from the datastore.
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1407
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1360
uint32_t data
The data value.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1268
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
Notification that we encountered an error unindexing a file.
struct GNUNET_CRYPTO_EcdsaPublicKey verification_key
Public key used to sign this block.
Definition: block_fs.h:64
universal block for keyword and namespace search results
Definition: block_fs.h:49
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
Definition: fs_api.c:744
index block (indexing a DBlock that can be obtained directly from reading the plaintext file) ...
Definition: block_fs.h:81
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
void * cctx
Client context pointer (set the last time by the client for this operation; initially NULL on START/R...
Merkle-tree-ish-CHK file encoding for GNUnet.
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1448
publish a UBLOCK in GNUnet
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073