fs_directory.c 18 KB

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