GNUnet  0.10.x
fs_namespace.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2003-2013 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_signatures.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_fs_service.h"
32 #include "fs_api.h"
33 #include "fs_publish_ublock.h"
34 
35 
41 {
45  char *id;
46 
50  char *update;
51 
56 
60  struct GNUNET_FS_Uri *uri;
61 
66  unsigned int nug;
67 
71  unsigned int tree_id;
72 
73 };
74 
75 
80 {
81 
86 
91 
96 
102 
106  unsigned int update_node_count;
107 
111  unsigned int rc;
112 
116  unsigned int nug_gen;
117 };
118 
119 
128 static char *
130  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
131 {
132  char *dn;
133  char *ret;
134  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
135  struct GNUNET_HashCode hc;
137 
138  if (GNUNET_OK !=
139  GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR",
140  &dn))
141  {
143  "fs", "UPDATE_DIR");
144  return NULL;
145  }
147  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &hc);
149  &enc);
150  GNUNET_asprintf (&ret, "%s%s%s",
151  dn,
153  (const char *) enc.encoding);
154  GNUNET_free (dn);
155  return ret;
156 }
157 
158 
164 static void
166 {
167  unsigned int i;
168  struct NamespaceUpdateNode *nsn;
169 
170  for (i = 0; i < uig->update_node_count; i++)
171  {
172  nsn = uig->update_nodes[i];
174  GNUNET_FS_uri_destroy (nsn->uri);
175  GNUNET_free (nsn->id);
176  GNUNET_free (nsn->update);
177  GNUNET_free (nsn);
178  }
180  0);
181  if (NULL != uig->update_map)
183  GNUNET_free (uig);
184 }
185 
186 
192 static void
194 {
195  char *fn;
196  struct GNUNET_BIO_WriteHandle *wh;
197  unsigned int i;
198  struct NamespaceUpdateNode *n;
199  char *uris;
200 
202  &uig->ns);
203  wh = GNUNET_BIO_write_open (fn);
204  if (NULL == wh)
205  {
207  _("Failed to open `%s' for writing: %s\n"),
208  fn,
209  STRERROR (errno));
210  GNUNET_free (fn);
211  return;
212  }
214  goto END;
215  for (i = 0; i < uig->update_node_count; i++)
216  {
217  n = uig->update_nodes[i];
218  uris = GNUNET_FS_uri_to_string (n->uri);
219  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, n->id)) ||
220  (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, n->md)) ||
221  (GNUNET_OK != GNUNET_BIO_write_string (wh, n->update)) ||
222  (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)))
223  {
224  GNUNET_free (uris);
225  break;
226  }
227  GNUNET_free (uris);
228  }
229 END:
230  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
232  _("Failed to write `%s': %s\n"),
233  fn,
234  STRERROR (errno));
235  GNUNET_free (fn);
236 }
237 
238 
246 static struct GNUNET_FS_UpdateInformationGraph *
248  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
249 {
251  char *fn;
252  struct GNUNET_BIO_ReadHandle *rh;
253  unsigned int i;
254  struct NamespaceUpdateNode *n;
255  char *uris;
256  uint32_t count;
257  char *emsg;
258 
260  uig->h = h;
261  uig->ns = *ns;
263  if (GNUNET_YES != GNUNET_DISK_file_test (fn))
264  {
265  GNUNET_free (fn);
266  return uig;
267  }
268  rh = GNUNET_BIO_read_open (fn);
269  if (NULL == rh)
270  {
271  GNUNET_free (fn);
272  return uig;
273  }
274  if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &count))
275  {
276  GNUNET_break (0);
277  goto END;
278  }
279  if (count > 1024 * 1024)
280  {
281  GNUNET_break (0);
282  goto END;
283  }
284  if (0 == count)
285  goto END;
286  uig->update_nodes =
287  GNUNET_malloc (count * sizeof (struct NamespaceUpdateNode *));
288 
289  for (i = 0; i < count; i++)
290  {
291  n = GNUNET_new (struct NamespaceUpdateNode);
292  if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024))
293  || (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) ||
294  (GNUNET_OK !=
295  GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) ||
296  (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2)))
297  {
298  GNUNET_break (0);
301  if (n->md != NULL)
303  GNUNET_free (n);
304  break;
305  }
306  n->uri = GNUNET_FS_uri_parse (uris, &emsg);
307  GNUNET_free (uris);
308  if (n->uri == NULL)
309  {
310  GNUNET_break (0);
311  GNUNET_free (emsg);
312  GNUNET_free (n->id);
315  GNUNET_free (n);
316  break;
317  }
318  uig->update_nodes[i] = n;
319  }
320  uig->update_node_count = i;
321  END:
322  if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
323  {
324  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to read `%s': %s\n"),
325  fn, emsg);
326  GNUNET_free (emsg);
327  }
328  GNUNET_free (fn);
329  return uig;
330 }
331 
332 
337 {
338 
343 
349 
354 
359 
364 
369 
373  void *cont_cls;
374 
379 };
380 
381 
389 static void
390 sks_publish_cont (void *cls,
391  const char *msg)
392 {
393  struct GNUNET_FS_PublishSksContext *psc = cls;
395 
396  psc->uc = NULL;
397  if (NULL != msg)
398  {
399  if (NULL != psc->cont)
400  psc->cont (psc->cont_cls, NULL, msg);
402  return;
403  }
404  if (NULL != psc->nsn)
405  {
406  /* FIXME: this can be done much more
407  * efficiently by simply appending to the
408  * file and overwriting the 4-byte header */
409  uig = read_update_information_graph (psc->h,
410  &psc->ns);
412  uig->update_node_count,
413  psc->nsn);
414  psc->nsn = NULL;
417  }
418  if (NULL != psc->cont)
419  psc->cont (psc->cont_cls, psc->uri, NULL);
421 }
422 
423 
441  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
442  const char *identifier, const char *update,
443  const struct GNUNET_CONTAINER_MetaData *meta,
444  const struct GNUNET_FS_Uri *uri,
445  const struct GNUNET_FS_BlockOptions *bo,
448 {
449  struct GNUNET_FS_PublishSksContext *psc;
450  struct GNUNET_FS_Uri *sks_uri;
451 
452  sks_uri = GNUNET_new (struct GNUNET_FS_Uri);
453  sks_uri->type = GNUNET_FS_URI_SKS;
454  sks_uri->data.sks.identifier = GNUNET_strdup (identifier);
456  &sks_uri->data.sks.ns);
457 
459  psc->h = h;
460  psc->uri = sks_uri;
461  psc->cont = cont;
462  psc->cont_cls = cont_cls;
463  psc->ns = *ns;
464  if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
465  {
466  psc->dsh = GNUNET_DATASTORE_connect (h->cfg);
467  if (NULL == psc->dsh)
468  {
469  sks_publish_cont (psc,
470  _("Failed to connect to datastore."));
471  return NULL;
472  }
473  }
474  if (NULL != update)
475  {
476  psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
477  psc->nsn->id = GNUNET_strdup (identifier);
478  psc->nsn->update = GNUNET_strdup (update);
480  psc->nsn->uri = GNUNET_FS_uri_dup (uri);
481  }
482  psc->uc = GNUNET_FS_publish_ublock_ (h,
483  psc->dsh,
484  identifier,
485  update,
486  ns,
487  meta,
488  uri,
489  bo,
490  options,
492  psc);
493  return psc;
494 }
495 
496 
502 void
504 {
505  if (NULL != psc->uc)
506  {
508  psc->uc = NULL;
509  }
510  if (NULL != psc->dsh)
511  {
513  psc->dsh = NULL;
514  }
515  GNUNET_FS_uri_destroy (psc->uri);
516  if (NULL != psc->nsn)
517  {
519  GNUNET_FS_uri_destroy (psc->nsn->uri);
520  GNUNET_free (psc->nsn->id);
521  GNUNET_free (psc->nsn->update);
522  GNUNET_free (psc->nsn);
523  }
524  GNUNET_free (psc);
525 }
526 
527 
532 {
537 
541  void *ip_cls;
542 };
543 
544 
555 static int
557  const struct GNUNET_HashCode *key,
558  void *value)
559 {
560  struct ProcessUpdateClosure *pc = cls;
561  struct NamespaceUpdateNode *nsn = value;
562 
563  pc->ip (pc->ip_cls,
564  nsn->id,
565  nsn->uri,
566  nsn->md,
567  nsn->update);
568  return GNUNET_YES;
569 }
570 
571 
576 {
581 
586 
590  unsigned int tree_array_size;
591 
595  unsigned int nug;
596 
600  unsigned int id;
601 };
602 
603 
624 static int
625 find_trees (void *cls,
626  const struct GNUNET_HashCode *key,
627  void *value)
628 {
629  struct FindTreeClosure *fc = cls;
630  struct NamespaceUpdateNode *nsn = value;
631  struct GNUNET_HashCode hc;
632 
633  if (nsn->nug == fc->nug)
634  {
635  if (UINT_MAX == nsn->tree_id)
636  return GNUNET_YES; /* circular */
638  if (fc->tree_array[nsn->tree_id] != nsn)
639  return GNUNET_YES; /* part of "another" (directed) TREE,
640  * and not root of it, end trace */
641  if (nsn->tree_id == fc->id)
642  return GNUNET_YES; /* that's our own root (can this be?) */
643  /* merge existing TREE, we have a root for both */
644  fc->tree_array[nsn->tree_id] = NULL;
645  if (UINT_MAX == fc->id)
646  fc->id = nsn->tree_id; /* take over ID */
647  }
648  else
649  {
650  nsn->nug = fc->nug;
651  nsn->tree_id = UINT_MAX; /* mark as undef */
652  /* trace */
653  GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
655  &find_trees, fc);
656  }
657  return GNUNET_YES;
658 }
659 
660 
684 void
686  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
687  const char *next_id,
689  void *ip_cls)
690 {
691  unsigned int i;
692  unsigned int nug;
693  struct GNUNET_HashCode hc;
694  struct NamespaceUpdateNode *nsn;
695  struct ProcessUpdateClosure pc;
696  struct FindTreeClosure fc;
698 
699  uig = read_update_information_graph (h, ns);
700  if (NULL == uig->update_nodes)
701  {
703  "No updateable nodes found for ID `%s'\n", next_id);
705  return; /* no nodes */
706  }
707  uig->update_map =
709  3 * uig->update_node_count /
710  4,
711  GNUNET_NO);
712  for (i = 0; i < uig->update_node_count; i++)
713  {
714  nsn = uig->update_nodes[i];
715  GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
718  }
719  if (NULL != next_id)
720  {
721  GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
722  pc.ip = ip;
723  pc.ip_cls = ip_cls;
725  &process_update_node, &pc);
727  return;
728  }
730  "Calculating TREEs to find roots of update trees\n");
731  /* Find heads of TREEs in update graph */
732  nug = ++uig->nug_gen;
733  fc.tree_array = NULL;
734  fc.tree_array_size = 0;
735 
736  for (i = 0; i < uig->update_node_count; i++)
737  {
738  nsn = uig->update_nodes[i];
739  if (nsn->nug == nug)
740  {
741  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id,
742  nsn->nug);
743  continue; /* already placed in TREE */
744  }
745  GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
746  nsn->nug = nug;
747  nsn->tree_id = UINT_MAX;
748  fc.id = UINT_MAX;
749  fc.nug = nug;
750  fc.uig = uig;
752  &find_trees, &fc);
753  if (UINT_MAX == fc.id)
754  {
755  /* start new TREE */
756  for (fc.id = 0; fc.id < fc.tree_array_size; fc.id++)
757  {
758  if (NULL == fc.tree_array[fc.id])
759  {
760  fc.tree_array[fc.id] = nsn;
761  nsn->tree_id = fc.id;
762  break;
763  }
764  }
765  if (fc.id == fc.tree_array_size)
766  {
768  nsn->tree_id = fc.id;
769  }
771  "Starting new TREE %u with node `%s'\n", nsn->tree_id,
772  nsn->id);
773  /* put all nodes with same identifier into this TREE */
774  GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
775  fc.id = nsn->tree_id;
776  fc.nug = nug;
777  fc.uig = uig;
779  &find_trees, &fc);
780  }
781  else
782  {
783  /* make head of TREE "id" */
784  fc.tree_array[fc.id] = nsn;
785  nsn->tree_id = fc.id;
786  }
788  "TREE of node `%s' is %u\n", nsn->id,
789  fc.id);
790  }
791  for (i = 0; i < fc.tree_array_size; i++)
792  {
793  nsn = fc.tree_array[i];
794  if (NULL != nsn)
795  {
796  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Root of TREE %u is node `%s'\n", i,
797  nsn->id);
798  ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
799  }
800  }
802  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done processing TREEs\n");
804 }
805 
806 
807 /* end of fs_namespace.c */
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:669
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m)
Write metadata container to a file.
Definition: bio.c:569
GNUNET_FS_PublishContinuation cont
Function to call once we&#39;re done.
Definition: fs_namespace.c:368
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:342
Context for the SKS publication.
Definition: fs_namespace.c:336
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
static void write_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Write a namespace&#39;s update node graph to a file.
Definition: fs_namespace.c:193
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:635
Master context for most FS operations.
Definition: fs_api.h:1087
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:547
struct GNUNET_FS_Handle * h
Handle to the FS service context.
Definition: fs_namespace.c:85
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int nug
Namespace update generation ID.
Definition: fs_namespace.c:66
#define STRERROR(i)
Definition: plibc.h:676
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:363
struct GNUNET_FS_PublishSksContext * GNUNET_FS_publish_sks(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *identifier, const char *update, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish an SBlock on GNUnet.
Definition: fs_namespace.c:440
We&#39;re done processing.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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.
static int ret
Final status code.
Definition: gnunet-arm.c:89
void GNUNET_FS_namespace_list_updateable(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *next_id, GNUNET_FS_IdentifierProcessor ip, void *ip_cls)
List all of the identifiers in the namespace for which we could produce an update.
Definition: fs_namespace.c:685
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static void sks_publish_cont(void *cls, const char *msg)
Function called by the UBlock construction with the result from the PUT (UBlock) request.
Definition: fs_namespace.c:390
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:988
Internal representation of the hash map.
int GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open file.
Definition: bio.c:119
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
static int find_trees(void *cls, const struct GNUNET_HashCode *key, void *value)
Find all nodes reachable from the current node (including the current node itself).
Definition: fs_namespace.c:625
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
GNUNET_FS_IdentifierProcessor ip
Function to call for each node.
Definition: fs_namespace.c:536
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:1988
unsigned int rc
Reference counter.
Definition: fs_namespace.c:111
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open(const char *fn)
Open a file for reading.
Definition: bio.c:94
static void free_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Release memory occupied by UIG datastructure.
Definition: fs_namespace.c:165
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Meta data to associate with a file, directory or namespace.
char * id
Identifier for this node.
Definition: fs_namespace.c:45
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
Closure for &#39;find_trees&#39;.
Definition: fs_namespace.c:575
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:106
unsigned int tree_array_size
Size of &#39;tree_array&#39;.
Definition: fs_namespace.c:590
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Private key for the namespace.
Definition: fs_namespace.c:95
static char * fn
Filename of the unique file.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we&#39;re publishing to.
Definition: fs_namespace.c:353
static int process_update_node(void *cls, const struct GNUNET_HashCode *key, void *value)
Call the iterator in the closure for each node.
Definition: fs_namespace.c:556
void(* GNUNET_FS_IdentifierProcessor)(void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_CONTAINER_MetaData *last_meta, const char *next_id)
Function called on updateable identifiers.
union GNUNET_FS_Uri::@16 data
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:503
void(* GNUNET_FS_PublishContinuation)(void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
Signature of a function called as the continuation of a KBlock or SBlock publication.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
GNUNET_FS_PublishOptions
Options for publishing.
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
Handle for buffered writing.
Definition: bio.c:399
unsigned int tree_id
TREE this entry belongs to (if nug is current).
Definition: fs_namespace.c:71
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:670
A 512-bit hashcode.
int GNUNET_BIO_read_string(struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
Read 0-terminated string from a file.
Definition: bio.c:237
void GNUNET_FS_publish_ublock_cancel_(struct GNUNET_FS_PublishUblockContext *uc)
Abort UBlock publishing operation.
struct GNUNET_CONTAINER_MultiHashMap * update_map
Hash map mapping identifiers of update nodes to the update nodes (initialized on-demand).
Definition: fs_namespace.c:101
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition: crypto_hash.c:69
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:241
#define GNUNET_BIO_read_int32(h, i)
Read an (u)int32_t.
Closure for &#39;process_update_node&#39;.
Definition: fs_namespace.c:531
struct GNUNET_FS_PublishUblockContext * GNUNET_FS_publish_ublock_(struct GNUNET_FS_Handle *h, struct GNUNET_DATASTORE_Handle *dsh, const char *label, const char *ulabel, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_UBlockContinuation cont, void *cont_cls)
Publish a UBlock.
Settings for publishing a block (which may of course also apply to an entire directory or file)...
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:173
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:90
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:457
unsigned int nug
Current generational ID used.
Definition: fs_namespace.c:595
0-terminated ASCII encoding of a struct GNUNET_HashCode.
Allow multiple values with the same key.
unsigned int id
Identifier for the current TREE, or UINT_MAX for none yet.
Definition: fs_namespace.c:600
Signed key space (file in namespace).
Definition: fs_api.h:151
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
void * ip_cls
Closure for &#39;ip&#39;.
Definition: fs_namespace.c:541
struct GNUNET_FS_Uri::@16::@18 sks
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static char * get_update_information_directory(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
Return the name of the directory in which we store the update information graph for the given local n...
Definition: fs_namespace.c:129
struct GNUNET_FS_UpdateInformationGraph * uig
UIG we are operating on.
Definition: fs_namespace.c:580
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
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).
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open(const char *fn)
Open a file for writing.
Definition: bio.c:430
Context for &#39;ublock_put_cont&#39;.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:168
Handle to the datastore service.
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
unsigned int nug_gen
Generator for unique nug numbers.
Definition: fs_namespace.c:116
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed)...
Definition: fs_namespace.c:348
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:358
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct NamespaceUpdateNode ** tree_array
Array with &#39;head&#39;s of TREEs.
Definition: fs_namespace.c:585
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:605
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:373
int GNUNET_BIO_read_meta_data(struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result)
Read metadata container from a file.
Definition: bio.c:286
#define GNUNET_YES
Definition: gnunet_common.h:80
#define DIR_SEPARATOR_STR
Definition: plibc.h:632
static struct GNUNET_FS_UpdateInformationGraph * read_update_information_graph(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
Read the namespace update node graph from a file.
Definition: fs_namespace.c:247
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:378
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
Handle to update information for a namespace.
Definition: fs_namespace.c:79
#define GNUNET_malloc(size)
Wrapper around malloc.
Handle for buffered reading.
Definition: bio.c:53
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
#define GNUNET_free(ptr)
Wrapper around free.
publish a UBLOCK in GNUnet
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1092