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 
44  char *id;
45 
49  char *update;
50 
55 
59  struct GNUNET_FS_Uri *uri;
60 
65  unsigned int nug;
66 
70  unsigned int tree_id;
71 };
72 
73 
82 
87 
92 
98 
102  unsigned int update_node_count;
103 
107  unsigned int rc;
108 
112  unsigned int nug_gen;
113 };
114 
115 
124 static char *
126  struct GNUNET_FS_Handle *h,
127  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
128 {
129  char *dn;
130  char *ret;
131  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
132  struct GNUNET_HashCode hc;
134 
135  if (GNUNET_OK !=
136  GNUNET_CONFIGURATION_get_value_filename(h->cfg, "FS", "UPDATE_DIR", &dn))
137  {
139  return NULL;
140  }
142  GNUNET_CRYPTO_hash(&pub, sizeof(pub), &hc);
143  GNUNET_CRYPTO_hash_to_enc(&hc, &enc);
144  GNUNET_asprintf(&ret,
145  "%s%s%s",
146  dn,
148  (const char *)enc.encoding);
149  GNUNET_free(dn);
150  return ret;
151 }
152 
153 
159 static void
161 {
162  unsigned int i;
163  struct NamespaceUpdateNode *nsn;
164 
165  for (i = 0; i < uig->update_node_count; i++)
166  {
167  nsn = uig->update_nodes[i];
170  GNUNET_free(nsn->id);
171  GNUNET_free(nsn->update);
172  GNUNET_free(nsn);
173  }
175  if (NULL != uig->update_map)
177  GNUNET_free(uig);
178 }
179 
180 
186 static void
188 {
189  char *fn;
190  struct GNUNET_BIO_WriteHandle *wh;
191  unsigned int i;
192  struct NamespaceUpdateNode *n;
193  char *uris;
194 
195  fn = get_update_information_directory(uig->h, &uig->ns);
196  wh = GNUNET_BIO_write_open(fn);
197  if (NULL == wh)
198  {
200  _("Failed to open `%s' for writing: %s\n"),
201  fn,
202  strerror(errno));
203  GNUNET_free(fn);
204  return;
205  }
207  goto END;
208  for (i = 0; i < uig->update_node_count; i++)
209  {
210  n = uig->update_nodes[i];
211  uris = GNUNET_FS_uri_to_string(n->uri);
212  if ((GNUNET_OK != GNUNET_BIO_write_string(wh, n->id)) ||
213  (GNUNET_OK != GNUNET_BIO_write_meta_data(wh, n->md)) ||
215  (GNUNET_OK != GNUNET_BIO_write_string(wh, uris)))
216  {
217  GNUNET_free(uris);
218  break;
219  }
220  GNUNET_free(uris);
221  }
222 END:
225  _("Failed to write `%s': %s\n"),
226  fn,
227  strerror(errno));
228  GNUNET_free(fn);
229 }
230 
231 
239 static struct GNUNET_FS_UpdateInformationGraph *
241  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
242 {
244  char *fn;
245  struct GNUNET_BIO_ReadHandle *rh;
246  unsigned int i;
247  struct NamespaceUpdateNode *n;
248  char *uris;
249  uint32_t count;
250  char *emsg;
251 
253  uig->h = h;
254  uig->ns = *ns;
257  {
258  GNUNET_free(fn);
259  return uig;
260  }
261  rh = GNUNET_BIO_read_open(fn);
262  if (NULL == rh)
263  {
264  GNUNET_free(fn);
265  return uig;
266  }
267  if (GNUNET_OK != GNUNET_BIO_read_int32(rh, &count))
268  {
269  GNUNET_break(0);
270  goto END;
271  }
272  if (count > 1024 * 1024)
273  {
274  GNUNET_break(0);
275  goto END;
276  }
277  if (0 == count)
278  goto END;
279  uig->update_nodes =
280  GNUNET_malloc(count * sizeof(struct NamespaceUpdateNode *));
281 
282  for (i = 0; i < count; i++)
283  {
284  n = GNUNET_new(struct NamespaceUpdateNode);
285  if ((GNUNET_OK !=
286  GNUNET_BIO_read_string(rh, "identifier", &n->id, 1024)) ||
287  (GNUNET_OK != GNUNET_BIO_read_meta_data(rh, "meta", &n->md)) ||
288  (GNUNET_OK !=
289  GNUNET_BIO_read_string(rh, "update-id", &n->update, 1024)) ||
290  (GNUNET_OK != GNUNET_BIO_read_string(rh, "uri", &uris, 1024 * 2)))
291  {
292  GNUNET_break(0);
295  if (n->md != NULL)
297  GNUNET_free(n);
298  break;
299  }
300  n->uri = GNUNET_FS_uri_parse(uris, &emsg);
301  GNUNET_free(uris);
302  if (n->uri == NULL)
303  {
304  GNUNET_break(0);
305  GNUNET_free(emsg);
306  GNUNET_free(n->id);
309  GNUNET_free(n);
310  break;
311  }
312  uig->update_nodes[i] = n;
313  }
314  uig->update_node_count = i;
315 END:
316  if (GNUNET_OK != GNUNET_BIO_read_close(rh, &emsg))
317  {
319  _("Failed to read `%s': %s\n"),
320  fn,
321  emsg);
322  GNUNET_free(emsg);
323  }
324  GNUNET_free(fn);
325  return uig;
326 }
327 
328 
337 
343 
348 
353 
358 
363 
367  void *cont_cls;
368 
373 };
374 
375 
383 static void
384 sks_publish_cont(void *cls, const char *msg)
385 {
386  struct GNUNET_FS_PublishSksContext *psc = cls;
388 
389  psc->uc = NULL;
390  if (NULL != msg)
391  {
392  if (NULL != psc->cont)
393  psc->cont(psc->cont_cls, NULL, msg);
395  return;
396  }
397  if (NULL != psc->nsn)
398  {
399  /* FIXME: this can be done much more
400  * efficiently by simply appending to the
401  * file and overwriting the 4-byte header */
402  uig = read_update_information_graph(psc->h, &psc->ns);
404  psc->nsn = NULL;
407  }
408  if (NULL != psc->cont)
409  psc->cont(psc->cont_cls, psc->uri, NULL);
411 }
412 
413 
431  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
432  const char *identifier,
433  const char *update,
434  const struct GNUNET_CONTAINER_MetaData *meta,
435  const struct GNUNET_FS_Uri *uri,
436  const struct GNUNET_FS_BlockOptions *bo,
439  void *cont_cls)
440 {
441  struct GNUNET_FS_PublishSksContext *psc;
442  struct GNUNET_FS_Uri *sks_uri;
443 
444  sks_uri = GNUNET_new(struct GNUNET_FS_Uri);
445  sks_uri->type = GNUNET_FS_URI_SKS;
446  sks_uri->data.sks.identifier = GNUNET_strdup(identifier);
447  GNUNET_CRYPTO_ecdsa_key_get_public(ns, &sks_uri->data.sks.ns);
448 
450  psc->h = h;
451  psc->uri = sks_uri;
452  psc->cont = cont;
453  psc->cont_cls = cont_cls;
454  psc->ns = *ns;
455  if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
456  {
457  psc->dsh = GNUNET_DATASTORE_connect(h->cfg);
458  if (NULL == psc->dsh)
459  {
460  sks_publish_cont(psc, _("Failed to connect to datastore."));
461  return NULL;
462  }
463  }
464  if (NULL != update)
465  {
466  psc->nsn = GNUNET_new(struct NamespaceUpdateNode);
467  psc->nsn->id = GNUNET_strdup(identifier);
468  psc->nsn->update = GNUNET_strdup(update);
470  psc->nsn->uri = GNUNET_FS_uri_dup(uri);
471  }
472  psc->uc = GNUNET_FS_publish_ublock_(h,
473  psc->dsh,
474  identifier,
475  update,
476  ns,
477  meta,
478  uri,
479  bo,
480  options,
482  psc);
483  return psc;
484 }
485 
486 
492 void
494 {
495  if (NULL != psc->uc)
496  {
498  psc->uc = NULL;
499  }
500  if (NULL != psc->dsh)
501  {
503  psc->dsh = NULL;
504  }
506  if (NULL != psc->nsn)
507  {
510  GNUNET_free(psc->nsn->id);
511  GNUNET_free(psc->nsn->update);
512  GNUNET_free(psc->nsn);
513  }
514  GNUNET_free(psc);
515 }
516 
517 
526 
530  void *ip_cls;
531 };
532 
533 
544 static int
545 process_update_node(void *cls, const struct GNUNET_HashCode *key, void *value)
546 {
547  struct ProcessUpdateClosure *pc = cls;
548  struct NamespaceUpdateNode *nsn = value;
549 
550  pc->ip(pc->ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
551  return GNUNET_YES;
552 }
553 
554 
563 
568 
572  unsigned int tree_array_size;
573 
577  unsigned int nug;
578 
582  unsigned int id;
583 };
584 
585 
606 static int
607 find_trees(void *cls, const struct GNUNET_HashCode *key, void *value)
608 {
609  struct FindTreeClosure *fc = cls;
610  struct NamespaceUpdateNode *nsn = value;
611  struct GNUNET_HashCode hc;
612 
613  if (nsn->nug == fc->nug)
614  {
615  if (UINT_MAX == nsn->tree_id)
616  return GNUNET_YES; /* circular */
618  if (fc->tree_array[nsn->tree_id] != nsn)
619  return GNUNET_YES; /* part of "another" (directed) TREE,
620  * and not root of it, end trace */
621  if (nsn->tree_id == fc->id)
622  return GNUNET_YES; /* that's our own root (can this be?) */
623  /* merge existing TREE, we have a root for both */
624  fc->tree_array[nsn->tree_id] = NULL;
625  if (UINT_MAX == fc->id)
626  fc->id = nsn->tree_id; /* take over ID */
627  }
628  else
629  {
630  nsn->nug = fc->nug;
631  nsn->tree_id = UINT_MAX; /* mark as undef */
632  /* trace */
633  GNUNET_CRYPTO_hash(nsn->update, strlen(nsn->update), &hc);
635  &hc,
636  &find_trees,
637  fc);
638  }
639  return GNUNET_YES;
640 }
641 
642 
666 void
668  struct GNUNET_FS_Handle *h,
669  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
670  const char *next_id,
672  void *ip_cls)
673 {
674  unsigned int i;
675  unsigned int nug;
676  struct GNUNET_HashCode hc;
677  struct NamespaceUpdateNode *nsn;
678  struct ProcessUpdateClosure pc;
679  struct FindTreeClosure fc;
681 
682  uig = read_update_information_graph(h, ns);
683  if (NULL == uig->update_nodes)
684  {
686  "No updateable nodes found for ID `%s'\n",
687  next_id);
689  return; /* no nodes */
690  }
691  uig->update_map =
693  GNUNET_NO);
694  for (i = 0; i < uig->update_node_count; i++)
695  {
696  nsn = uig->update_nodes[i];
697  GNUNET_CRYPTO_hash(nsn->id, strlen(nsn->id), &hc);
699  uig->update_map,
700  &hc,
701  nsn,
703  }
704  if (NULL != next_id)
705  {
706  GNUNET_CRYPTO_hash(next_id, strlen(next_id), &hc);
707  pc.ip = ip;
708  pc.ip_cls = ip_cls;
710  &hc,
712  &pc);
714  return;
715  }
717  "Calculating TREEs to find roots of update trees\n");
718  /* Find heads of TREEs in update graph */
719  nug = ++uig->nug_gen;
720  fc.tree_array = NULL;
721  fc.tree_array_size = 0;
722 
723  for (i = 0; i < uig->update_node_count; i++)
724  {
725  nsn = uig->update_nodes[i];
726  if (nsn->nug == nug)
727  {
729  "TREE of node `%s' is %u\n",
730  nsn->id,
731  nsn->nug);
732  continue; /* already placed in TREE */
733  }
734  GNUNET_CRYPTO_hash(nsn->update, strlen(nsn->update), &hc);
735  nsn->nug = nug;
736  nsn->tree_id = UINT_MAX;
737  fc.id = UINT_MAX;
738  fc.nug = nug;
739  fc.uig = uig;
741  &hc,
742  &find_trees,
743  &fc);
744  if (UINT_MAX == fc.id)
745  {
746  /* start new TREE */
747  for (fc.id = 0; fc.id < fc.tree_array_size; fc.id++)
748  {
749  if (NULL == fc.tree_array[fc.id])
750  {
751  fc.tree_array[fc.id] = nsn;
752  nsn->tree_id = fc.id;
753  break;
754  }
755  }
756  if (fc.id == fc.tree_array_size)
757  {
759  nsn->tree_id = fc.id;
760  }
762  "Starting new TREE %u with node `%s'\n",
763  nsn->tree_id,
764  nsn->id);
765  /* put all nodes with same identifier into this TREE */
766  GNUNET_CRYPTO_hash(nsn->id, strlen(nsn->id), &hc);
767  fc.id = nsn->tree_id;
768  fc.nug = nug;
769  fc.uig = uig;
771  &hc,
772  &find_trees,
773  &fc);
774  }
775  else
776  {
777  /* make head of TREE "id" */
778  fc.tree_array[fc.id] = nsn;
779  nsn->tree_id = fc.id;
780  }
782  "TREE of node `%s' is %u\n",
783  nsn->id,
784  fc.id);
785  }
786  for (i = 0; i < fc.tree_array_size; i++)
787  {
788  nsn = fc.tree_array[i];
789  if (NULL != nsn)
790  {
792  "Root of TREE %u is node `%s'\n",
793  i,
794  nsn->id);
795  ip(ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
796  }
797  }
799  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Done processing TREEs\n");
801 }
802 
803 
804 /* 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:541
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:542
GNUNET_FS_PublishContinuation cont
Function to call once we&#39;re done.
Definition: fs_namespace.c:362
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:336
Context for the SKS publication.
Definition: fs_namespace.c:332
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:59
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:187
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:641
Master context for most FS operations.
Definition: fs_api.h:1056
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:521
struct GNUNET_FS_Handle * h
Handle to the FS service context.
Definition: fs_namespace.c:81
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int nug
Namespace update generation ID.
Definition: fs_namespace.c:65
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:357
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:430
We&#39;re done processing.
#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.
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:667
#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:384
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:995
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:118
#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:607
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
GNUNET_FS_IdentifierProcessor ip
Function to call for each node.
Definition: fs_namespace.c:525
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2024
unsigned int rc
Reference counter.
Definition: fs_namespace.c:107
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open(const char *fn)
Open a file for reading.
Definition: bio.c:93
static void free_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Release memory occupied by UIG datastructure.
Definition: fs_namespace.c:160
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:44
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
Closure for &#39;find_trees&#39;.
Definition: fs_namespace.c:558
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:102
unsigned int tree_array_size
Size of &#39;tree_array&#39;.
Definition: fs_namespace.c:572
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Private key for the namespace.
Definition: fs_namespace.c:91
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:347
#define DIR_SEPARATOR_STR
Definition: platform.h:168
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:545
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:493
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:49
Handle for buffered writing.
Definition: bio.c:378
unsigned int tree_id
TREE this entry belongs to (if nug is current).
Definition: fs_namespace.c:70
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:675
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:232
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:97
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:521
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:166
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:86
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:436
unsigned int nug
Current generational ID used.
Definition: fs_namespace.c:577
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:582
Signed key space (file in namespace).
Definition: fs_api.h:145
#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:530
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:125
struct GNUNET_FS_UpdateInformationGraph * uig
UIG we are operating on.
Definition: fs_namespace.c:562
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:54
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:408
Context for &#39;ublock_put_cont&#39;.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:162
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:112
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed)...
Definition: fs_namespace.c:342
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:352
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:567
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:580
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:367
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:284
#define GNUNET_YES
Definition: gnunet_common.h:77
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:240
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:372
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:77
#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:1060