fs_directory.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2003, 2004, 2006, 2009 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file fs/fs_directory.c
  18. * @brief Helper functions for building directories.
  19. * @author Christian Grothoff
  20. *
  21. * TODO:
  22. * - modify directory builder API to support incremental
  23. * generation of directories (to allow directories that
  24. * would not fit into memory to be created)
  25. * - modify directory processor API to support incremental
  26. * iteration over FULL directories (without missing entries)
  27. * to allow access to directories that do not fit entirely
  28. * into memory
  29. */
  30. #include "platform.h"
  31. #include "gnunet_fs_service.h"
  32. #include "fs_api.h"
  33. /**
  34. * String that is used to indicate that a file
  35. * is a GNUnet directory.
  36. */
  37. #define GNUNET_DIRECTORY_MAGIC "\211GND\r\n\032\n"
  38. /**
  39. * Does the meta-data claim that this is a directory?
  40. * Checks if the mime-type is that of a GNUnet directory.
  41. *
  42. * @return #GNUNET_YES if it is, #GNUNET_NO if it is not, #GNUNET_SYSERR if
  43. * we have no mime-type information (treat as #GNUNET_NO)
  44. */
  45. int
  46. GNUNET_FS_meta_data_test_for_directory (const struct
  47. GNUNET_CONTAINER_MetaData *md)
  48. {
  49. char *mime;
  50. int ret;
  51. if (NULL == md)
  52. return GNUNET_SYSERR;
  53. mime = GNUNET_CONTAINER_meta_data_get_by_type (md,
  54. EXTRACTOR_METATYPE_MIMETYPE);
  55. if (NULL == mime)
  56. return GNUNET_SYSERR;
  57. ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES :
  58. GNUNET_NO;
  59. GNUNET_free (mime);
  60. return ret;
  61. }
  62. /**
  63. * Set the MIMETYPE information for the given
  64. * metadata to "application/gnunet-directory".
  65. *
  66. * @param md metadata to add mimetype to
  67. */
  68. void
  69. GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md)
  70. {
  71. char *mime;
  72. mime =
  73. GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
  74. if (mime != NULL)
  75. {
  76. GNUNET_break (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME));
  77. GNUNET_free (mime);
  78. return;
  79. }
  80. GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>",
  81. EXTRACTOR_METATYPE_MIMETYPE,
  82. EXTRACTOR_METAFORMAT_UTF8, "text/plain",
  83. GNUNET_FS_DIRECTORY_MIME,
  84. strlen (GNUNET_FS_DIRECTORY_MIME) + 1);
  85. }
  86. /**
  87. * Closure for 'find_full_data'.
  88. */
  89. struct GetFullDataClosure
  90. {
  91. /**
  92. * Extracted binary meta data.
  93. */
  94. void *data;
  95. /**
  96. * Number of bytes stored in data.
  97. */
  98. size_t size;
  99. };
  100. /**
  101. * Type of a function that libextractor calls for each
  102. * meta data item found.
  103. *
  104. * @param cls closure (user-defined)
  105. * @param plugin_name name of the plugin that produced this value;
  106. * special values can be used (i.e. '&lt;zlib&gt;' for zlib being
  107. * used in the main libextractor library and yielding
  108. * meta data).
  109. * @param type libextractor-type describing the meta data
  110. * @param format basic format information about data
  111. * @param data_mime_type mime-type of data (not of the original file);
  112. * can be NULL (if mime-type is not known)
  113. * @param data actual meta-data found
  114. * @param data_len number of bytes in data
  115. * @return 0 to continue extracting, 1 to abort
  116. */
  117. static int
  118. find_full_data (void *cls, const char *plugin_name,
  119. enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format,
  120. const char *data_mime_type, const char *data, size_t data_len)
  121. {
  122. struct GetFullDataClosure *gfdc = cls;
  123. if (type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
  124. {
  125. gfdc->size = data_len;
  126. if (data_len > 0)
  127. {
  128. gfdc->data = GNUNET_malloc (data_len);
  129. GNUNET_memcpy (gfdc->data, data, data_len);
  130. }
  131. return 1;
  132. }
  133. return 0;
  134. }
  135. /**
  136. * Iterate over all entries in a directory. Note that directories
  137. * are structured such that it is possible to iterate over the
  138. * individual blocks as well as over the entire directory. Thus
  139. * a client can call this function on the buffer in the
  140. * GNUNET_FS_ProgressCallback. Also, directories can optionally
  141. * include the contents of (small) files embedded in the directory
  142. * itself; for those files, the processor may be given the
  143. * contents of the file directly by this function.
  144. * <p>
  145. *
  146. * Note that this function maybe called on parts of directories. Thus
  147. * parser errors should not be reported _at all_ (with GNUNET_break).
  148. * Still, if some entries can be recovered despite these parsing
  149. * errors, the function should try to do this.
  150. *
  151. * @param size number of bytes in data
  152. * @param data pointer to the beginning of the directory
  153. * @param offset offset of data in the directory
  154. * @param dep function to call on each entry
  155. * @param dep_cls closure for @a dep
  156. * @return #GNUNET_OK if this could be a block in a directory,
  157. * #GNUNET_NO if this could be part of a directory (but not 100% OK)
  158. * #GNUNET_SYSERR if @a data does not represent a directory
  159. */
  160. int
  161. GNUNET_FS_directory_list_contents (size_t size,
  162. const void *data,
  163. uint64_t offset,
  164. GNUNET_FS_DirectoryEntryProcessor dep,
  165. void *dep_cls)
  166. {
  167. struct GetFullDataClosure full_data;
  168. const char *cdata = data;
  169. char *emsg;
  170. uint64_t pos;
  171. uint64_t align;
  172. uint32_t mdSize;
  173. uint64_t epos;
  174. struct GNUNET_FS_Uri *uri;
  175. struct GNUNET_CONTAINER_MetaData *md;
  176. char *filename;
  177. if ((offset == 0) &&
  178. ((size < 8 + sizeof(uint32_t)) ||
  179. (0 != memcmp (cdata,
  180. GNUNET_FS_DIRECTORY_MAGIC,
  181. 8))))
  182. return GNUNET_SYSERR;
  183. pos = offset;
  184. if (offset == 0)
  185. {
  186. GNUNET_memcpy (&mdSize,
  187. &cdata[8],
  188. sizeof(uint32_t));
  189. mdSize = ntohl (mdSize);
  190. if (mdSize > size - 8 - sizeof(uint32_t))
  191. {
  192. /* invalid size */
  193. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  194. _ ("MAGIC mismatch. This is not a GNUnet directory.\n"));
  195. return GNUNET_SYSERR;
  196. }
  197. md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)],
  198. mdSize);
  199. if (md == NULL)
  200. {
  201. GNUNET_break (0);
  202. return GNUNET_SYSERR; /* malformed ! */
  203. }
  204. dep (dep_cls,
  205. NULL,
  206. NULL,
  207. md,
  208. 0,
  209. NULL);
  210. GNUNET_CONTAINER_meta_data_destroy (md);
  211. pos = 8 + sizeof(uint32_t) + mdSize;
  212. }
  213. while (pos < size)
  214. {
  215. /* find end of URI */
  216. if (cdata[pos] == '\0')
  217. {
  218. /* URI is never empty, must be end of block,
  219. * skip to next alignment */
  220. align = ((pos / DBLOCK_SIZE) + 1) * DBLOCK_SIZE;
  221. if (align == pos)
  222. {
  223. /* if we were already aligned, still skip a block! */
  224. align += DBLOCK_SIZE;
  225. }
  226. pos = align;
  227. if (pos >= size)
  228. {
  229. /* malformed - or partial download... */
  230. break;
  231. }
  232. }
  233. epos = pos;
  234. while ((epos < size) && (cdata[epos] != '\0'))
  235. epos++;
  236. if (epos >= size)
  237. return GNUNET_NO; /* malformed - or partial download */
  238. uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg);
  239. pos = epos + 1;
  240. if (NULL == uri)
  241. {
  242. GNUNET_free (emsg);
  243. pos--; /* go back to '\0' to force going to next alignment */
  244. continue;
  245. }
  246. if (GNUNET_FS_uri_test_ksk (uri))
  247. {
  248. GNUNET_FS_uri_destroy (uri);
  249. GNUNET_break (0);
  250. return GNUNET_NO; /* illegal in directory! */
  251. }
  252. GNUNET_memcpy (&mdSize,
  253. &cdata[pos],
  254. sizeof(uint32_t));
  255. mdSize = ntohl (mdSize);
  256. pos += sizeof(uint32_t);
  257. if (pos + mdSize > size)
  258. {
  259. GNUNET_FS_uri_destroy (uri);
  260. return GNUNET_NO; /* malformed - or partial download */
  261. }
  262. md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos],
  263. mdSize);
  264. if (NULL == md)
  265. {
  266. GNUNET_FS_uri_destroy (uri);
  267. GNUNET_break (0);
  268. return GNUNET_NO; /* malformed ! */
  269. }
  270. pos += mdSize;
  271. filename =
  272. GNUNET_CONTAINER_meta_data_get_by_type (md,
  273. EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
  274. full_data.size = 0;
  275. full_data.data = NULL;
  276. GNUNET_CONTAINER_meta_data_iterate (md,
  277. &find_full_data,
  278. &full_data);
  279. if (NULL != dep)
  280. {
  281. dep (dep_cls,
  282. filename,
  283. uri,
  284. md,
  285. full_data.size,
  286. full_data.data);
  287. }
  288. GNUNET_free_non_null (full_data.data);
  289. GNUNET_free_non_null (filename);
  290. GNUNET_CONTAINER_meta_data_destroy (md);
  291. GNUNET_FS_uri_destroy (uri);
  292. }
  293. return GNUNET_OK;
  294. }
  295. /**
  296. * Entries in the directory (builder).
  297. */
  298. struct BuilderEntry
  299. {
  300. /**
  301. * This is a linked list.
  302. */
  303. struct BuilderEntry *next;
  304. /**
  305. * Length of this entry.
  306. */
  307. size_t len;
  308. };
  309. /**
  310. * Internal state of a directory builder.
  311. */
  312. struct GNUNET_FS_DirectoryBuilder
  313. {
  314. /**
  315. * Meta-data for the directory itself.
  316. */
  317. struct GNUNET_CONTAINER_MetaData *meta;
  318. /**
  319. * Head of linked list of entries.
  320. */
  321. struct BuilderEntry *head;
  322. /**
  323. * Number of entires in the directory.
  324. */
  325. unsigned int count;
  326. };
  327. /**
  328. * Create a directory builder.
  329. *
  330. * @param mdir metadata for the directory
  331. */
  332. struct GNUNET_FS_DirectoryBuilder *
  333. GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
  334. *mdir)
  335. {
  336. struct GNUNET_FS_DirectoryBuilder *ret;
  337. ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder);
  338. if (mdir != NULL)
  339. ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir);
  340. else
  341. ret->meta = GNUNET_CONTAINER_meta_data_create ();
  342. GNUNET_FS_meta_data_make_directory (ret->meta);
  343. return ret;
  344. }
  345. /**
  346. * Add an entry to a directory.
  347. *
  348. * @param bld directory to extend
  349. * @param uri uri of the entry (must not be a KSK)
  350. * @param md metadata of the entry
  351. * @param data raw data of the entry, can be NULL, otherwise
  352. * data must point to exactly the number of bytes specified
  353. * by the uri which must be of type LOC or CHK
  354. */
  355. void
  356. GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
  357. const struct GNUNET_FS_Uri *uri,
  358. const struct GNUNET_CONTAINER_MetaData *md,
  359. const void *data)
  360. {
  361. struct GNUNET_FS_Uri *curi;
  362. struct BuilderEntry *e;
  363. uint64_t fsize;
  364. uint32_t big;
  365. ssize_t ret;
  366. size_t mds;
  367. size_t mdxs;
  368. char *uris;
  369. char *ser;
  370. char *sptr;
  371. size_t slen;
  372. struct GNUNET_CONTAINER_MetaData *meta;
  373. const struct GNUNET_CONTAINER_MetaData *meta_use;
  374. GNUNET_assert (! GNUNET_FS_uri_test_ksk (uri));
  375. if (NULL != data)
  376. {
  377. GNUNET_assert (! GNUNET_FS_uri_test_sks (uri));
  378. if (GNUNET_FS_uri_test_chk (uri))
  379. {
  380. fsize = GNUNET_FS_uri_chk_get_file_size (uri);
  381. }
  382. else
  383. {
  384. curi = GNUNET_FS_uri_loc_get_uri (uri);
  385. GNUNET_assert (NULL != curi);
  386. fsize = GNUNET_FS_uri_chk_get_file_size (curi);
  387. GNUNET_FS_uri_destroy (curi);
  388. }
  389. }
  390. else
  391. {
  392. fsize = 0; /* not given */
  393. }
  394. if (fsize > MAX_INLINE_SIZE)
  395. fsize = 0; /* too large */
  396. uris = GNUNET_FS_uri_to_string (uri);
  397. slen = strlen (uris) + 1;
  398. mds = GNUNET_CONTAINER_meta_data_get_serialized_size (md);
  399. meta_use = md;
  400. meta = NULL;
  401. if (fsize > 0)
  402. {
  403. meta = GNUNET_CONTAINER_meta_data_duplicate (md);
  404. GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
  405. EXTRACTOR_METATYPE_GNUNET_FULL_DATA,
  406. EXTRACTOR_METAFORMAT_BINARY, NULL, data,
  407. fsize);
  408. mdxs = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
  409. if ((slen + sizeof(uint32_t) + mdxs - 1) / DBLOCK_SIZE ==
  410. (slen + sizeof(uint32_t) + mds - 1) / DBLOCK_SIZE)
  411. {
  412. /* adding full data would not cause us to cross
  413. * additional blocks, so add it! */
  414. meta_use = meta;
  415. mds = mdxs;
  416. }
  417. }
  418. if (mds > GNUNET_MAX_MALLOC_CHECKED / 2)
  419. mds = GNUNET_MAX_MALLOC_CHECKED / 2;
  420. e = GNUNET_malloc (sizeof(struct BuilderEntry) + slen + mds
  421. + sizeof(uint32_t));
  422. ser = (char *) &e[1];
  423. GNUNET_memcpy (ser, uris, slen);
  424. GNUNET_free (uris);
  425. sptr = &ser[slen + sizeof(uint32_t)];
  426. ret =
  427. GNUNET_CONTAINER_meta_data_serialize (meta_use, &sptr, mds,
  428. GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
  429. if (NULL != meta)
  430. GNUNET_CONTAINER_meta_data_destroy (meta);
  431. if (ret == -1)
  432. mds = 0;
  433. else
  434. mds = ret;
  435. big = htonl (mds);
  436. GNUNET_memcpy (&ser[slen], &big, sizeof(uint32_t));
  437. e->len = slen + sizeof(uint32_t) + mds;
  438. e->next = bld->head;
  439. bld->head = e;
  440. bld->count++;
  441. }
  442. /**
  443. * Given the start and end position of a block of
  444. * data, return the end position of that data
  445. * after alignment to the DBLOCK_SIZE.
  446. */
  447. static size_t
  448. do_align (size_t start_position, size_t end_position)
  449. {
  450. size_t align;
  451. align = (end_position / DBLOCK_SIZE) * DBLOCK_SIZE;
  452. if ((start_position < align) && (end_position > align))
  453. return align + end_position - start_position;
  454. return end_position;
  455. }
  456. /**
  457. * Compute a permuation of the blocks to
  458. * minimize the cost of alignment. Greedy packer.
  459. *
  460. * @param start starting position for the first block
  461. * @param count size of the two arrays
  462. * @param sizes the sizes of the individual blocks
  463. * @param perm the permutation of the blocks (updated)
  464. */
  465. static void
  466. block_align (size_t start, unsigned int count, const size_t *sizes,
  467. unsigned int *perm)
  468. {
  469. unsigned int i;
  470. unsigned int j;
  471. unsigned int tmp;
  472. unsigned int best;
  473. ssize_t badness;
  474. size_t cpos;
  475. size_t cend;
  476. ssize_t cbad;
  477. unsigned int cval;
  478. cpos = start;
  479. for (i = 0; i < count; i++)
  480. {
  481. start = cpos;
  482. badness = 0x7FFFFFFF;
  483. best = -1;
  484. for (j = i; j < count; j++)
  485. {
  486. cval = perm[j];
  487. cend = cpos + sizes[cval];
  488. if (cpos % DBLOCK_SIZE == 0)
  489. {
  490. /* prefer placing the largest blocks first */
  491. cbad = -(cend % DBLOCK_SIZE);
  492. }
  493. else
  494. {
  495. if (cpos / DBLOCK_SIZE == cend / DBLOCK_SIZE)
  496. {
  497. /* Data fits into the same block! Prefer small left-overs! */
  498. cbad = DBLOCK_SIZE - cend % DBLOCK_SIZE;
  499. }
  500. else
  501. {
  502. /* Would have to waste space to re-align, add big factor, this
  503. * case is a real loss (proportional to space wasted)! */
  504. cbad = DBLOCK_SIZE * (DBLOCK_SIZE - cpos % DBLOCK_SIZE);
  505. }
  506. }
  507. if (cbad < badness)
  508. {
  509. best = j;
  510. badness = cbad;
  511. }
  512. }
  513. GNUNET_assert (best != -1);
  514. tmp = perm[i];
  515. perm[i] = perm[best];
  516. perm[best] = tmp;
  517. cpos += sizes[perm[i]];
  518. cpos = do_align (start, cpos);
  519. }
  520. }
  521. /**
  522. * Finish building the directory. Frees the
  523. * builder context and returns the directory
  524. * in-memory.
  525. *
  526. * @param bld directory to finish
  527. * @param rsize set to the number of bytes needed
  528. * @param rdata set to the encoded directory
  529. * @return #GNUNET_OK on success
  530. */
  531. int
  532. GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
  533. size_t *rsize,
  534. void **rdata)
  535. {
  536. char *data;
  537. char *sptr;
  538. size_t *sizes;
  539. unsigned int *perm;
  540. unsigned int i;
  541. unsigned int j;
  542. struct BuilderEntry *pos;
  543. struct BuilderEntry **bes;
  544. size_t size;
  545. size_t psize;
  546. size_t off;
  547. ssize_t ret;
  548. uint32_t big;
  549. size = strlen (GNUNET_DIRECTORY_MAGIC) + sizeof(uint32_t);
  550. size += GNUNET_CONTAINER_meta_data_get_serialized_size (bld->meta);
  551. sizes = NULL;
  552. perm = NULL;
  553. bes = NULL;
  554. if (0 < bld->count)
  555. {
  556. sizes = GNUNET_new_array (bld->count,
  557. size_t);
  558. perm = GNUNET_new_array (bld->count,
  559. unsigned int);
  560. bes = GNUNET_new_array (bld->count,
  561. struct BuilderEntry *);
  562. pos = bld->head;
  563. for (i = 0; i < bld->count; i++)
  564. {
  565. perm[i] = i;
  566. bes[i] = pos;
  567. sizes[i] = pos->len;
  568. pos = pos->next;
  569. }
  570. block_align (size, bld->count, sizes, perm);
  571. /* compute final size with alignment */
  572. for (i = 0; i < bld->count; i++)
  573. {
  574. psize = size;
  575. size += sizes[perm[i]];
  576. size = do_align (psize, size);
  577. }
  578. }
  579. *rsize = size;
  580. data = GNUNET_malloc_large (size);
  581. if (data == NULL)
  582. {
  583. GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
  584. "malloc");
  585. *rsize = 0;
  586. *rdata = NULL;
  587. GNUNET_free_non_null (sizes);
  588. GNUNET_free_non_null (perm);
  589. GNUNET_free_non_null (bes);
  590. return GNUNET_SYSERR;
  591. }
  592. *rdata = data;
  593. GNUNET_memcpy (data,
  594. GNUNET_DIRECTORY_MAGIC,
  595. strlen (GNUNET_DIRECTORY_MAGIC));
  596. off = strlen (GNUNET_DIRECTORY_MAGIC);
  597. sptr = &data[off + sizeof(uint32_t)];
  598. ret =
  599. GNUNET_CONTAINER_meta_data_serialize (bld->meta,
  600. &sptr,
  601. size - off - sizeof(uint32_t),
  602. GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
  603. GNUNET_assert (ret != -1);
  604. big = htonl (ret);
  605. GNUNET_memcpy (&data[off],
  606. &big,
  607. sizeof(uint32_t));
  608. off += sizeof(uint32_t) + ret;
  609. for (j = 0; j < bld->count; j++)
  610. {
  611. i = perm[j];
  612. psize = off;
  613. off += sizes[i];
  614. off = do_align (psize, off);
  615. GNUNET_memcpy (&data[off - sizes[i]], &(bes[i])[1], sizes[i]);
  616. GNUNET_free (bes[i]);
  617. }
  618. GNUNET_free_non_null (sizes);
  619. GNUNET_free_non_null (perm);
  620. GNUNET_free_non_null (bes);
  621. GNUNET_assert (off == size);
  622. GNUNET_CONTAINER_meta_data_destroy (bld->meta);
  623. GNUNET_free (bld);
  624. return GNUNET_OK;
  625. }
  626. /* end of fs_directory.c */