aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs.c79
-rw-r--r--src/fs/fs.h19
-rw-r--r--src/fs/fs_file_information.c87
-rw-r--r--src/fs/fs_publish.c5
-rw-r--r--src/fs/fs_test_lib.c3
-rw-r--r--src/fs/gnunet-publish.c6
-rw-r--r--src/fs/test_fs_download.c3
-rw-r--r--src/fs/test_fs_file_information.c14
-rw-r--r--src/fs/test_fs_list_indexed.c9
-rw-r--r--src/fs/test_fs_publish.c9
-rw-r--r--src/fs/test_fs_search.c3
-rw-r--r--src/fs/test_fs_unindex.c3
-rw-r--r--src/include/gnunet_disk_lib.h5
-rw-r--r--src/include/gnunet_fs_service.h45
-rw-r--r--src/util/disk.c20
15 files changed, 208 insertions, 102 deletions
diff --git a/src/fs/fs.c b/src/fs/fs.c
index e14f0570a..963fd7920 100644
--- a/src/fs/fs.c
+++ b/src/fs/fs.c
@@ -275,6 +275,31 @@ get_read_handle (struct GNUNET_FS_Handle *h,
275 275
276 276
277/** 277/**
278 * Return a write handle for serialization.
279 *
280 * @param h master context
281 * @param ext component of the path
282 * @param ent entity identifier (or emtpy string for the directory)
283 * @return NULL on error
284 */
285static struct GNUNET_BIO_WriteHandle *
286get_write_handle (struct GNUNET_FS_Handle *h,
287 const char *ext,
288 const char *ent)
289{
290 char *fn;
291 struct GNUNET_BIO_WriteHandle *ret;
292
293 fn = get_serialization_file_name (h, ext, ent);
294 if (fn == NULL)
295 return NULL;
296 ret = GNUNET_BIO_write_open (fn);
297 GNUNET_free (fn);
298 return ret;
299}
300
301
302/**
278 * Using the given serialization filename, try to deserialize 303 * Using the given serialization filename, try to deserialize
279 * the file-information tree associated with it. 304 * the file-information tree associated with it.
280 * 305 *
@@ -490,6 +515,60 @@ deserialize_file_information (struct GNUNET_FS_Handle *h,
490 515
491 516
492/** 517/**
518 * Create a temporary file on disk to store the current
519 * state of "fi" in.
520 *
521 * @param fi file information to sync with disk
522 */
523void
524GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi)
525{
526 char *fn;
527 char *dn;
528 const char *end;
529 const char *nxt;
530 struct GNUNET_BIO_WriteHandle *wh;
531
532 if (NULL == fi->serialization)
533 {
534 dn = get_serialization_file_name (fi->h, "publish-fi", "");
535 fn = GNUNET_DISK_mktemp (dn);
536 GNUNET_free (dn);
537 if (fn == NULL)
538 return; /* epic fail */
539 end = NULL;
540 nxt = fn;
541 while ('\0' != nxt)
542 {
543 if (DIR_SEPARATOR == *nxt)
544 end = nxt + 1;
545 nxt++;
546 }
547 if ( (end == NULL) ||
548 (strlen (end) == 0) )
549 {
550 GNUNET_break (0);
551 GNUNET_free (fn);
552 return;
553 }
554 GNUNET_break (6 == strlen (end));
555 fi->serialization = GNUNET_strdup (end);
556 GNUNET_free (fn);
557 }
558 wh = get_write_handle (fi->h, "publish-fi", fi->serialization);
559 if (wh == NULL)
560 {
561 GNUNET_free (fi->serialization);
562 fi->serialization = NULL;
563 return;
564 }
565 /* FIXME: actual serialization here! */
566 GNUNET_BIO_write_close (wh);
567}
568
569
570
571/**
493 * Find the entry in the file information struct where the 572 * Find the entry in the file information struct where the
494 * serialization filename matches the given name. 573 * serialization filename matches the given name.
495 * 574 *
diff --git a/src/fs/fs.h b/src/fs/fs.h
index 02bb3715e..50306851e 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -294,6 +294,11 @@ struct GNUNET_FS_FileInformation
294 struct GNUNET_FS_FileInformation *dir; 294 struct GNUNET_FS_FileInformation *dir;
295 295
296 /** 296 /**
297 * Handle to the master context.
298 */
299 struct GNUNET_FS_Handle *h;
300
301 /**
297 * Pointer kept for the client. 302 * Pointer kept for the client.
298 */ 303 */
299 void *client_info; 304 void *client_info;
@@ -606,6 +611,20 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
606 const struct GNUNET_FS_FileInformation *p, 611 const struct GNUNET_FS_FileInformation *p,
607 uint64_t offset); 612 uint64_t offset);
608 613
614
615/**
616 * Synchronize this file-information struct with its mirror
617 * on disk. Note that all internal FS-operations that change
618 * file information data should already call "sync" internally,
619 * so this function is likely not useful for clients.
620 *
621 * @param fi the struct to sync
622 */
623void
624GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f);
625
626
627
609/** 628/**
610 * Master context for most FS operations. 629 * Master context for most FS operations.
611 */ 630 */
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index 40fc88432..2d0194741 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -36,40 +36,6 @@
36 36
37 37
38/** 38/**
39 * Create a temporary file on disk to store the current
40 * state of "fi" in.
41 *
42 * @param fi file information to sync with disk
43 */
44void
45GNUNET_FS_file_information_sync (struct GNUNET_FS_FileInformation * fi)
46{
47 if (NULL == fi->serialization)
48 {
49 fi->serialization = NULL; // FIXME -- need cfg!
50 }
51 // FIXME...
52}
53
54
55/**
56 * Load file information from the file to which
57 * it was sync'ed.
58 *
59 * @param fn name of the file to use
60 * @return NULL on error
61 */
62struct GNUNET_FS_FileInformation *
63GNUNET_FS_file_information_recover (const char *fn)
64{
65 struct GNUNET_FS_FileInformation *ret;
66 ret = NULL;
67 // FIXME!
68 return ret;
69}
70
71
72/**
73 * Obtain the name under which this file information 39 * Obtain the name under which this file information
74 * structure is stored on disk. Only works for top-level 40 * structure is stored on disk. Only works for top-level
75 * file information structures. 41 * file information structures.
@@ -177,6 +143,7 @@ data_reader_file(void *cls,
177/** 143/**
178 * Create an entry for a file in a publish-structure. 144 * Create an entry for a file in a publish-structure.
179 * 145 *
146 * @param h handle to the file sharing subsystem
180 * @param client_info initial value for the client-info value for this entry 147 * @param client_info initial value for the client-info value for this entry
181 * @param filename name of the file or directory to publish 148 * @param filename name of the file or directory to publish
182 * @param keywords under which keywords should this file be available 149 * @param keywords under which keywords should this file be available
@@ -192,7 +159,8 @@ data_reader_file(void *cls,
192 * @return publish structure entry for the file 159 * @return publish structure entry for the file
193 */ 160 */
194struct GNUNET_FS_FileInformation * 161struct GNUNET_FS_FileInformation *
195GNUNET_FS_file_information_create_from_file (void *client_info, 162GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
163 void *client_info,
196 const char *filename, 164 const char *filename,
197 const struct GNUNET_FS_Uri *keywords, 165 const struct GNUNET_FS_Uri *keywords,
198 const struct GNUNET_CONTAINER_MetaData *meta, 166 const struct GNUNET_CONTAINER_MetaData *meta,
@@ -221,7 +189,8 @@ GNUNET_FS_file_information_create_from_file (void *client_info,
221 GNUNET_free (fi); 189 GNUNET_free (fi);
222 return NULL; 190 return NULL;
223 } 191 }
224 ret = GNUNET_FS_file_information_create_from_reader (client_info, 192 ret = GNUNET_FS_file_information_create_from_reader (h,
193 client_info,
225 sbuf.st_size, 194 sbuf.st_size,
226 &data_reader_file, 195 &data_reader_file,
227 fi, 196 fi,
@@ -231,6 +200,7 @@ GNUNET_FS_file_information_create_from_file (void *client_info,
231 anonymity, 200 anonymity,
232 priority, 201 priority,
233 expirationTime); 202 expirationTime);
203 ret->h = h;
234 ret->filename = GNUNET_strdup (filename); 204 ret->filename = GNUNET_strdup (filename);
235 fn = filename; 205 fn = filename;
236 while (NULL != (ss = strstr (fn, 206 while (NULL != (ss = strstr (fn,
@@ -285,6 +255,7 @@ data_reader_copy(void *cls,
285/** 255/**
286 * Create an entry for a file in a publish-structure. 256 * Create an entry for a file in a publish-structure.
287 * 257 *
258 * @param h handle to the file sharing subsystem
288 * @param client_info initial value for the client-info value for this entry 259 * @param client_info initial value for the client-info value for this entry
289 * @param length length of the file 260 * @param length length of the file
290 * @param data data for the file (should not be used afterwards by 261 * @param data data for the file (should not be used afterwards by
@@ -302,7 +273,8 @@ data_reader_copy(void *cls,
302 * @return publish structure entry for the file 273 * @return publish structure entry for the file
303 */ 274 */
304struct GNUNET_FS_FileInformation * 275struct GNUNET_FS_FileInformation *
305GNUNET_FS_file_information_create_from_data (void *client_info, 276GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
277 void *client_info,
306 uint64_t length, 278 uint64_t length,
307 void *data, 279 void *data,
308 const struct GNUNET_FS_Uri *keywords, 280 const struct GNUNET_FS_Uri *keywords,
@@ -312,7 +284,8 @@ GNUNET_FS_file_information_create_from_data (void *client_info,
312 uint32_t priority, 284 uint32_t priority,
313 struct GNUNET_TIME_Absolute expirationTime) 285 struct GNUNET_TIME_Absolute expirationTime)
314{ 286{
315 return GNUNET_FS_file_information_create_from_reader (client_info, 287 return GNUNET_FS_file_information_create_from_reader (h,
288 client_info,
316 length, 289 length,
317 &data_reader_copy, 290 &data_reader_copy,
318 data, 291 data,
@@ -328,6 +301,7 @@ GNUNET_FS_file_information_create_from_data (void *client_info,
328/** 301/**
329 * Create an entry for a file in a publish-structure. 302 * Create an entry for a file in a publish-structure.
330 * 303 *
304 * @param h handle to the file sharing subsystem
331 * @param client_info initial value for the client-info value for this entry 305 * @param client_info initial value for the client-info value for this entry
332 * @param length length of the file 306 * @param length length of the file
333 * @param reader function that can be used to obtain the data for the file 307 * @param reader function that can be used to obtain the data for the file
@@ -345,7 +319,8 @@ GNUNET_FS_file_information_create_from_data (void *client_info,
345 * @return publish structure entry for the file 319 * @return publish structure entry for the file
346 */ 320 */
347struct GNUNET_FS_FileInformation * 321struct GNUNET_FS_FileInformation *
348GNUNET_FS_file_information_create_from_reader (void *client_info, 322GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
323 void *client_info,
349 uint64_t length, 324 uint64_t length,
350 GNUNET_FS_DataReader reader, 325 GNUNET_FS_DataReader reader,
351 void *reader_cls, 326 void *reader_cls,
@@ -359,6 +334,7 @@ GNUNET_FS_file_information_create_from_reader (void *client_info,
359 struct GNUNET_FS_FileInformation *ret; 334 struct GNUNET_FS_FileInformation *ret;
360 335
361 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation)); 336 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation));
337 ret->h = h;
362 ret->client_info = client_info; 338 ret->client_info = client_info;
363 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 339 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
364 if (ret->meta == NULL) 340 if (ret->meta == NULL)
@@ -371,7 +347,6 @@ GNUNET_FS_file_information_create_from_reader (void *client_info,
371 ret->data.file.file_size = length; 347 ret->data.file.file_size = length;
372 ret->anonymity = anonymity; 348 ret->anonymity = anonymity;
373 ret->priority = priority; 349 ret->priority = priority;
374 GNUNET_FS_file_information_sync (ret);
375 return ret; 350 return ret;
376} 351}
377 352
@@ -387,6 +362,11 @@ struct DirScanCls
387 struct EXTRACTOR_PluginList *extractors; 362 struct EXTRACTOR_PluginList *extractors;
388 363
389 /** 364 /**
365 * Master context.
366 */
367 struct GNUNET_FS_Handle *h;
368
369 /**
390 * Function to call on each directory entry. 370 * Function to call on each directory entry.
391 */ 371 */
392 GNUNET_FS_FileProcessor proc; 372 GNUNET_FS_FileProcessor proc;
@@ -462,7 +442,8 @@ dir_scan_cb (void *cls,
462 } 442 }
463 if (S_ISDIR (sbuf.st_mode)) 443 if (S_ISDIR (sbuf.st_mode))
464 { 444 {
465 fi = GNUNET_FS_file_information_create_from_directory (NULL, 445 fi = GNUNET_FS_file_information_create_from_directory (dsc->h,
446 NULL,
466 filename, 447 filename,
467 dsc->scanner, 448 dsc->scanner,
468 dsc->scanner_cls, 449 dsc->scanner_cls,
@@ -486,7 +467,8 @@ dir_scan_cb (void *cls,
486 // FIXME: remove path from filename in metadata! 467 // FIXME: remove path from filename in metadata!
487 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); 468 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
488 ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords); 469 ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords);
489 fi = GNUNET_FS_file_information_create_from_file (NULL, 470 fi = GNUNET_FS_file_information_create_from_file (dsc->h,
471 NULL,
490 filename, 472 filename,
491 ksk_uri, 473 ksk_uri,
492 meta, 474 meta,
@@ -517,6 +499,7 @@ dir_scan_cb (void *cls,
517 * convenience function. 499 * convenience function.
518 * 500 *
519 * @param cls must be of type "struct EXTRACTOR_Extractor*" 501 * @param cls must be of type "struct EXTRACTOR_Extractor*"
502 * @param h handle to the file sharing subsystem
520 * @param dirname name of the directory to scan 503 * @param dirname name of the directory to scan
521 * @param do_index should files be indexed or inserted 504 * @param do_index should files be indexed or inserted
522 * @param anonymity desired anonymity level 505 * @param anonymity desired anonymity level
@@ -529,6 +512,7 @@ dir_scan_cb (void *cls,
529 */ 512 */
530int 513int
531GNUNET_FS_directory_scanner_default (void *cls, 514GNUNET_FS_directory_scanner_default (void *cls,
515 struct GNUNET_FS_Handle *h,
532 const char *dirname, 516 const char *dirname,
533 int do_index, 517 int do_index,
534 uint32_t anonymity, 518 uint32_t anonymity,
@@ -541,6 +525,7 @@ GNUNET_FS_directory_scanner_default (void *cls,
541 struct EXTRACTOR_PluginList *ex = cls; 525 struct EXTRACTOR_PluginList *ex = cls;
542 struct DirScanCls dsc; 526 struct DirScanCls dsc;
543 527
528 dsc.h = h;
544 dsc.extractors = ex; 529 dsc.extractors = ex;
545 dsc.proc = proc; 530 dsc.proc = proc;
546 dsc.proc_cls = proc_cls; 531 dsc.proc_cls = proc_cls;
@@ -607,6 +592,7 @@ dirproc (void *cls,
607 * passed (GNUNET_FS_directory_scanner_default). This is strictly a 592 * passed (GNUNET_FS_directory_scanner_default). This is strictly a
608 * convenience function. 593 * convenience function.
609 * 594 *
595 * @param h handle to the file sharing subsystem
610 * @param client_info initial value for the client-info value for this entry 596 * @param client_info initial value for the client-info value for this entry
611 * @param filename name of the top-level file or directory 597 * @param filename name of the top-level file or directory
612 * @param scanner function used to get a list of files in a directory 598 * @param scanner function used to get a list of files in a directory
@@ -621,7 +607,8 @@ dirproc (void *cls,
621 * @return publish structure entry for the directory, NULL on error 607 * @return publish structure entry for the directory, NULL on error
622 */ 608 */
623struct GNUNET_FS_FileInformation * 609struct GNUNET_FS_FileInformation *
624GNUNET_FS_file_information_create_from_directory (void *client_info, 610GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
611 void *client_info,
625 const char *filename, 612 const char *filename,
626 GNUNET_FS_DirectoryScanner scanner, 613 GNUNET_FS_DirectoryScanner scanner,
627 void *scanner_cls, 614 void *scanner_cls,
@@ -642,6 +629,7 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
642 meta = GNUNET_CONTAINER_meta_data_create (); 629 meta = GNUNET_CONTAINER_meta_data_create ();
643 GNUNET_FS_meta_data_make_directory (meta); 630 GNUNET_FS_meta_data_make_directory (meta);
644 scanner (scanner_cls, 631 scanner (scanner_cls,
632 h,
645 filename, 633 filename,
646 do_index, 634 do_index,
647 anonymity, 635 anonymity,
@@ -652,7 +640,8 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
652 emsg); 640 emsg);
653 ksk = NULL; // FIXME... 641 ksk = NULL; // FIXME...
654 // FIXME: create meta! 642 // FIXME: create meta!
655 ret = GNUNET_FS_file_information_create_empty_directory (client_info, 643 ret = GNUNET_FS_file_information_create_empty_directory (h,
644 client_info,
656 ksk, 645 ksk,
657 meta, 646 meta,
658 anonymity, 647 anonymity,
@@ -663,7 +652,6 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
663 while (dc.entries != NULL) 652 while (dc.entries != NULL)
664 { 653 {
665 dc.entries->dir = ret; 654 dc.entries->dir = ret;
666 GNUNET_FS_file_information_sync (dc.entries);
667 dc.entries = dc.entries->next; 655 dc.entries = dc.entries->next;
668 } 656 }
669 fn = filename; 657 fn = filename;
@@ -678,7 +666,6 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
678 fn, 666 fn,
679 strlen (fn) + 1); 667 strlen (fn) + 1);
680 ret->filename = GNUNET_strdup (filename); 668 ret->filename = GNUNET_strdup (filename);
681 GNUNET_FS_file_information_sync (ret);
682 return ret; 669 return ret;
683} 670}
684 671
@@ -689,6 +676,7 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
689 * use of "GNUNET_FS_file_information_create_from_directory" 676 * use of "GNUNET_FS_file_information_create_from_directory"
690 * is not appropriate. 677 * is not appropriate.
691 * 678 *
679 * @param h handle to the file sharing subsystem
692 * @param client_info initial value for the client-info value for this entry 680 * @param client_info initial value for the client-info value for this entry
693 * @param meta metadata for the directory 681 * @param meta metadata for the directory
694 * @param keywords under which keywords should this directory be available 682 * @param keywords under which keywords should this directory be available
@@ -701,7 +689,8 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
701 * @return publish structure entry for the directory , NULL on error 689 * @return publish structure entry for the directory , NULL on error
702 */ 690 */
703struct GNUNET_FS_FileInformation * 691struct GNUNET_FS_FileInformation *
704GNUNET_FS_file_information_create_empty_directory (void *client_info, 692GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
693 void *client_info,
705 const struct GNUNET_FS_Uri *keywords, 694 const struct GNUNET_FS_Uri *keywords,
706 const struct GNUNET_CONTAINER_MetaData *meta, 695 const struct GNUNET_CONTAINER_MetaData *meta,
707 uint32_t anonymity, 696 uint32_t anonymity,
@@ -711,6 +700,7 @@ GNUNET_FS_file_information_create_empty_directory (void *client_info,
711 struct GNUNET_FS_FileInformation *ret; 700 struct GNUNET_FS_FileInformation *ret;
712 701
713 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation)); 702 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation));
703 ret->h = h;
714 ret->client_info = client_info; 704 ret->client_info = client_info;
715 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 705 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
716 ret->keywords = GNUNET_FS_uri_dup (keywords); 706 ret->keywords = GNUNET_FS_uri_dup (keywords);
@@ -718,7 +708,6 @@ GNUNET_FS_file_information_create_empty_directory (void *client_info,
718 ret->is_directory = GNUNET_YES; 708 ret->is_directory = GNUNET_YES;
719 ret->anonymity = anonymity; 709 ret->anonymity = anonymity;
720 ret->priority = priority; 710 ret->priority = priority;
721 GNUNET_FS_file_information_sync (ret);
722 return ret; 711 return ret;
723} 712}
724 713
@@ -749,8 +738,6 @@ GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
749 ent->next = dir->data.dir.entries; 738 ent->next = dir->data.dir.entries;
750 dir->data.dir.entries = ent; 739 dir->data.dir.entries = ent;
751 dir->data.dir.dir_size = 0; 740 dir->data.dir.dir_size = 0;
752 GNUNET_FS_file_information_sync (ent);
753 GNUNET_FS_file_information_sync (dir);
754 return GNUNET_OK; 741 return GNUNET_OK;
755} 742}
756 743
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 973ecd438..16bab3ba1 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -158,13 +158,11 @@ ds_put_cont (void *cls,
158 GNUNET_asprintf (&pcc->p->emsg, 158 GNUNET_asprintf (&pcc->p->emsg,
159 _("Upload failed: %s"), 159 _("Upload failed: %s"),
160 msg); 160 msg);
161 GNUNET_FS_file_information_sync (pcc->p);
162 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 161 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
163 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 162 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
164 pi.value.publish.specifics.error.message = pcc->p->emsg; 163 pi.value.publish.specifics.error.message = pcc->p->emsg;
165 pcc->p->client_info = GNUNET_FS_publish_make_status_ (&pi, pcc->sc, pcc->p, 0); 164 pcc->p->client_info = GNUNET_FS_publish_make_status_ (&pi, pcc->sc, pcc->p, 0);
166 } 165 }
167 GNUNET_FS_file_information_sync (pcc->p);
168 if (NULL != pcc->cont) 166 if (NULL != pcc->cont)
169 pcc->sc->upload_task 167 pcc->sc->upload_task
170 = GNUNET_SCHEDULER_add_with_priority (pcc->sc->h->sched, 168 = GNUNET_SCHEDULER_add_with_priority (pcc->sc->h->sched,
@@ -302,7 +300,6 @@ publish_kblocks_cont (void *cls,
302 sc); 300 sc);
303 return; 301 return;
304 } 302 }
305 GNUNET_FS_file_information_sync (p);
306 if (NULL != p->dir) 303 if (NULL != p->dir)
307 signal_publish_completion (p, sc); 304 signal_publish_completion (p, sc);
308 /* move on to next file */ 305 /* move on to next file */
@@ -400,7 +397,6 @@ encode_cont (void *cls,
400 _("Upload failed: %s"), 397 _("Upload failed: %s"),
401 emsg); 398 emsg);
402 GNUNET_free (emsg); 399 GNUNET_free (emsg);
403 GNUNET_FS_file_information_sync (p);
404 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 400 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
405 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 401 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
406 pi.value.publish.specifics.error.message = p->emsg; 402 pi.value.publish.specifics.error.message = p->emsg;
@@ -833,7 +829,6 @@ GNUNET_FS_publish_main_ (void *cls,
833 _("Recursive upload failed: %s"), 829 _("Recursive upload failed: %s"),
834 p->emsg); 830 p->emsg);
835 } 831 }
836 GNUNET_FS_file_information_sync (p);
837 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 832 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
838 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 833 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
839 pi.value.publish.specifics.error.message = p->emsg; 834 pi.value.publish.specifics.error.message = p->emsg;
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c
index dd783f406..b891b4249 100644
--- a/src/fs/fs_test_lib.c
+++ b/src/fs/fs_test_lib.c
@@ -536,7 +536,8 @@ GNUNET_FS_TEST_publish (struct GNUNET_SCHEDULER_Handle *sched,
536 daemon->publish_seed = seed; 536 daemon->publish_seed = seed;
537 daemon->verbose = verbose; 537 daemon->verbose = verbose;
538 daemon->publish_sched = sched; 538 daemon->publish_sched = sched;
539 fi = GNUNET_FS_file_information_create_from_reader (daemon, 539 fi = GNUNET_FS_file_information_create_from_reader (daemon->fs,
540 daemon,
540 size, 541 size,
541 &file_generator, 542 &file_generator,
542 daemon, 543 daemon,
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index 279eedcce..5869fcff5 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -532,7 +532,8 @@ run (void *cls,
532 } 532 }
533 else if (S_ISDIR (sbuf.st_mode)) 533 else if (S_ISDIR (sbuf.st_mode))
534 { 534 {
535 fi = GNUNET_FS_file_information_create_from_directory (NULL, 535 fi = GNUNET_FS_file_information_create_from_directory (ctx,
536 NULL,
536 args[0], 537 args[0],
537 &GNUNET_FS_directory_scanner_default, 538 &GNUNET_FS_directory_scanner_default,
538 l, 539 l,
@@ -544,7 +545,8 @@ run (void *cls,
544 } 545 }
545 else 546 else
546 { 547 {
547 fi = GNUNET_FS_file_information_create_from_file (NULL, 548 fi = GNUNET_FS_file_information_create_from_file (ctx,
549 NULL,
548 args[0], 550 args[0],
549 NULL, 551 NULL,
550 NULL, 552 NULL,
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index b06f0e965..047c314e4 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -296,7 +296,8 @@ run (void *cls,
296 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 296 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
297 meta = GNUNET_CONTAINER_meta_data_create (); 297 meta = GNUNET_CONTAINER_meta_data_create ();
298 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 298 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
299 fi = GNUNET_FS_file_information_create_from_data ("publish-context", 299 fi = GNUNET_FS_file_information_create_from_data (fs,
300 "publish-context",
300 FILESIZE, 301 FILESIZE,
301 buf, 302 buf,
302 kuri, 303 kuri,
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c
index 36a0771a3..c5b4ec997 100644
--- a/src/fs/test_fs_file_information.c
+++ b/src/fs/test_fs_file_information.c
@@ -83,8 +83,12 @@ run (void *cls,
83 struct GNUNET_FS_FileInformation *fi1; 83 struct GNUNET_FS_FileInformation *fi1;
84 struct GNUNET_FS_FileInformation *fi2; 84 struct GNUNET_FS_FileInformation *fi2;
85 struct GNUNET_FS_FileInformation *fidir; 85 struct GNUNET_FS_FileInformation *fidir;
86 struct GNUNET_FS_Handle *fs;
86 size_t i; 87 size_t i;
87 88
89 fs = GNUNET_FS_start (s, cfg, "test-fs-file-information", NULL, NULL,
90 GNUNET_FS_FLAGS_NONE,
91 GNUNET_FS_OPTIONS_END);
88 fn1 = GNUNET_DISK_mktemp ("gnunet-file_information-test-dst"); 92 fn1 = GNUNET_DISK_mktemp ("gnunet-file_information-test-dst");
89 buf = GNUNET_malloc (FILESIZE); 93 buf = GNUNET_malloc (FILESIZE);
90 for (i = 0; i < FILESIZE; i++) 94 for (i = 0; i < FILESIZE; i++)
@@ -109,7 +113,8 @@ run (void *cls,
109 113
110 meta = GNUNET_CONTAINER_meta_data_create (); 114 meta = GNUNET_CONTAINER_meta_data_create ();
111 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 115 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
112 fi1 = GNUNET_FS_file_information_create_from_file ("file_information-context1", 116 fi1 = GNUNET_FS_file_information_create_from_file (fs,
117 "file_information-context1",
113 fn1, 118 fn1,
114 kuri, 119 kuri,
115 meta, 120 meta,
@@ -117,7 +122,8 @@ run (void *cls,
117 1, 122 1,
118 42, 123 42,
119 GNUNET_TIME_relative_to_absolute (LIFETIME)); 124 GNUNET_TIME_relative_to_absolute (LIFETIME));
120 fi2 = GNUNET_FS_file_information_create_from_file ("file_information-context2", 125 fi2 = GNUNET_FS_file_information_create_from_file (fs,
126 "file_information-context2",
121 fn2, 127 fn2,
122 kuri, 128 kuri,
123 meta, 129 meta,
@@ -125,7 +131,8 @@ run (void *cls,
125 1, 131 1,
126 42, 132 42,
127 GNUNET_TIME_relative_to_absolute (LIFETIME)); 133 GNUNET_TIME_relative_to_absolute (LIFETIME));
128 fidir = GNUNET_FS_file_information_create_empty_directory ("file_information-context-dir", 134 fidir = GNUNET_FS_file_information_create_empty_directory (fs,
135 "file_information-context-dir",
129 kuri, 136 kuri,
130 meta, 137 meta,
131 1, 138 1,
@@ -144,6 +151,7 @@ run (void *cls,
144 GNUNET_DISK_directory_remove (fn2); 151 GNUNET_DISK_directory_remove (fn2);
145 GNUNET_free_non_null (fn1); 152 GNUNET_free_non_null (fn1);
146 GNUNET_free_non_null (fn2); 153 GNUNET_free_non_null (fn2);
154 GNUNET_FS_stop (fs);
147} 155}
148 156
149 157
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index 58a3f3a82..280ca11ee 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -278,7 +278,8 @@ run (void *cls,
278 278
279 meta = GNUNET_CONTAINER_meta_data_create (); 279 meta = GNUNET_CONTAINER_meta_data_create ();
280 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 280 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
281 fi1 = GNUNET_FS_file_information_create_from_file ("list_indexed-context1", 281 fi1 = GNUNET_FS_file_information_create_from_file (fs,
282 "list_indexed-context1",
282 fn1, 283 fn1,
283 kuri, 284 kuri,
284 meta, 285 meta,
@@ -286,7 +287,8 @@ run (void *cls,
286 1, 287 1,
287 42, 288 42,
288 GNUNET_TIME_relative_to_absolute (LIFETIME)); 289 GNUNET_TIME_relative_to_absolute (LIFETIME));
289 fi2 = GNUNET_FS_file_information_create_from_file ("list_indexed-context2", 290 fi2 = GNUNET_FS_file_information_create_from_file (fs,
291 "list_indexed-context2",
290 fn2, 292 fn2,
291 kuri, 293 kuri,
292 meta, 294 meta,
@@ -294,7 +296,8 @@ run (void *cls,
294 2, 296 2,
295 42, 297 42,
296 GNUNET_TIME_relative_to_absolute (LIFETIME)); 298 GNUNET_TIME_relative_to_absolute (LIFETIME));
297 fidir = GNUNET_FS_file_information_create_empty_directory ("list_indexed-context-dir", 299 fidir = GNUNET_FS_file_information_create_empty_directory (fs,
300 "list_indexed-context-dir",
298 kuri, 301 kuri,
299 meta, 302 meta,
300 3, 303 3,
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index 2d664817c..20e65aeac 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -267,7 +267,8 @@ run (void *cls,
267 267
268 meta = GNUNET_CONTAINER_meta_data_create (); 268 meta = GNUNET_CONTAINER_meta_data_create ();
269 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 269 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
270 fi1 = GNUNET_FS_file_information_create_from_file ("publish-context1", 270 fi1 = GNUNET_FS_file_information_create_from_file (fs,
271 "publish-context1",
271 fn1, 272 fn1,
272 kuri, 273 kuri,
273 meta, 274 meta,
@@ -275,7 +276,8 @@ run (void *cls,
275 1, 276 1,
276 42, 277 42,
277 GNUNET_TIME_relative_to_absolute (LIFETIME)); 278 GNUNET_TIME_relative_to_absolute (LIFETIME));
278 fi2 = GNUNET_FS_file_information_create_from_file ("publish-context2", 279 fi2 = GNUNET_FS_file_information_create_from_file (fs,
280 "publish-context2",
279 fn2, 281 fn2,
280 kuri, 282 kuri,
281 meta, 283 meta,
@@ -283,7 +285,8 @@ run (void *cls,
283 2, 285 2,
284 42, 286 42,
285 GNUNET_TIME_relative_to_absolute (LIFETIME)); 287 GNUNET_TIME_relative_to_absolute (LIFETIME));
286 fidir = GNUNET_FS_file_information_create_empty_directory ("publish-context-dir", 288 fidir = GNUNET_FS_file_information_create_empty_directory (fs,
289 "publish-context-dir",
287 kuri, 290 kuri,
288 meta, 291 meta,
289 3, 292 3,
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index 32f885814..42687a743 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -249,7 +249,8 @@ run (void *cls,
249 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 249 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
250 meta = GNUNET_CONTAINER_meta_data_create (); 250 meta = GNUNET_CONTAINER_meta_data_create ();
251 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 251 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
252 fi = GNUNET_FS_file_information_create_from_data ("publish-context", 252 fi = GNUNET_FS_file_information_create_from_data (fs,
253 "publish-context",
253 FILESIZE, 254 FILESIZE,
254 buf, 255 buf,
255 kuri, 256 kuri,
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 3607144f3..861685d32 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -261,7 +261,8 @@ run (void *cls,
261 GNUNET_free (buf); 261 GNUNET_free (buf);
262 meta = GNUNET_CONTAINER_meta_data_create (); 262 meta = GNUNET_CONTAINER_meta_data_create ();
263 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 263 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
264 fi = GNUNET_FS_file_information_create_from_file ("publish-context", 264 fi = GNUNET_FS_file_information_create_from_file (fs,
265 "publish-context",
265 fn, 266 fn,
266 kuri, 267 kuri,
267 meta, 268 meta,
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index fcb58ffef..6292e029e 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -293,7 +293,10 @@ int GNUNET_DISK_file_get_identifiers (const char *filename,
293 293
294 294
295/** 295/**
296 * Create an (empty) temporary file on disk. 296 * Create an (empty) temporary file on disk. If the given name is not
297 * an absolute path, the current 'TMPDIR' will be prepended. In any case,
298 * 6 random characters will be appended to the name to create a unique
299 * filename.
297 * 300 *
298 * @param t component to use for the name; 301 * @param t component to use for the name;
299 * does NOT contain "XXXXXX" or "/tmp/". 302 * does NOT contain "XXXXXX" or "/tmp/".
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 508abeedb..8f54943c0 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -1562,16 +1562,6 @@ typedef int (*GNUNET_FS_FileInformationProcessor)(void *cls,
1562 1562
1563 1563
1564/** 1564/**
1565 * Recover file information structure from disk.
1566 *
1567 * @param fn filename for the structure on disk
1568 * @return NULL on error
1569 */
1570struct GNUNET_FS_FileInformation *
1571GNUNET_FS_file_information_recover (const char *fn);
1572
1573
1574/**
1575 * Obtain the name under which this file information 1565 * Obtain the name under which this file information
1576 * structure is stored on disk. Only works for top-level 1566 * structure is stored on disk. Only works for top-level
1577 * file information structures. 1567 * file information structures.
@@ -1585,21 +1575,11 @@ const char *
1585GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s); 1575GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s);
1586 1576
1587 1577
1588/**
1589 * Synchronize this file-information struct with its mirror
1590 * on disk. Note that all internal FS-operations that change
1591 * file information data should already call "sync" internally,
1592 * so this function is likely not useful for clients.
1593 *
1594 * @param fi the struct to sync
1595 */
1596void
1597GNUNET_FS_file_information_sync (struct GNUNET_FS_FileInformation *f);
1598
1599 1578
1600/** 1579/**
1601 * Create an entry for a file in a publish-structure. 1580 * Create an entry for a file in a publish-structure.
1602 * 1581 *
1582 * @param h handle to the file sharing subsystem
1603 * @param client_info initial client-info value for this entry 1583 * @param client_info initial client-info value for this entry
1604 * @param filename name of the file or directory to publish 1584 * @param filename name of the file or directory to publish
1605 * @param keywords under which keywords should this file be available 1585 * @param keywords under which keywords should this file be available
@@ -1615,7 +1595,8 @@ GNUNET_FS_file_information_sync (struct GNUNET_FS_FileInformation *f);
1615 * @return publish structure entry for the file 1595 * @return publish structure entry for the file
1616 */ 1596 */
1617struct GNUNET_FS_FileInformation * 1597struct GNUNET_FS_FileInformation *
1618GNUNET_FS_file_information_create_from_file (void *client_info, 1598GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
1599 void *client_info,
1619 const char *filename, 1600 const char *filename,
1620 const struct GNUNET_FS_Uri *keywords, 1601 const struct GNUNET_FS_Uri *keywords,
1621 const struct GNUNET_CONTAINER_MetaData *meta, 1602 const struct GNUNET_CONTAINER_MetaData *meta,
@@ -1628,6 +1609,7 @@ GNUNET_FS_file_information_create_from_file (void *client_info,
1628/** 1609/**
1629 * Create an entry for a file in a publish-structure. 1610 * Create an entry for a file in a publish-structure.
1630 * 1611 *
1612 * @param h handle to the file sharing subsystem
1631 * @param client_info initial client-info value for this entry 1613 * @param client_info initial client-info value for this entry
1632 * @param length length of the file 1614 * @param length length of the file
1633 * @param data data for the file (should not be used afterwards by 1615 * @param data data for the file (should not be used afterwards by
@@ -1645,7 +1627,8 @@ GNUNET_FS_file_information_create_from_file (void *client_info,
1645 * @return publish structure entry for the file 1627 * @return publish structure entry for the file
1646 */ 1628 */
1647struct GNUNET_FS_FileInformation * 1629struct GNUNET_FS_FileInformation *
1648GNUNET_FS_file_information_create_from_data (void *client_info, 1630GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
1631 void *client_info,
1649 uint64_t length, 1632 uint64_t length,
1650 void *data, 1633 void *data,
1651 const struct GNUNET_FS_Uri *keywords, 1634 const struct GNUNET_FS_Uri *keywords,
@@ -1682,6 +1665,7 @@ typedef size_t (*GNUNET_FS_DataReader)(void *cls,
1682/** 1665/**
1683 * Create an entry for a file in a publish-structure. 1666 * Create an entry for a file in a publish-structure.
1684 * 1667 *
1668 * @param h handle to the file sharing subsystem
1685 * @param client_info initial client-info value for this entry 1669 * @param client_info initial client-info value for this entry
1686 * @param length length of the file 1670 * @param length length of the file
1687 * @param reader function that can be used to obtain the data for the file 1671 * @param reader function that can be used to obtain the data for the file
@@ -1699,7 +1683,8 @@ typedef size_t (*GNUNET_FS_DataReader)(void *cls,
1699 * @return publish structure entry for the file 1683 * @return publish structure entry for the file
1700 */ 1684 */
1701struct GNUNET_FS_FileInformation * 1685struct GNUNET_FS_FileInformation *
1702GNUNET_FS_file_information_create_from_reader (void *client_info, 1686GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
1687 void *client_info,
1703 uint64_t length, 1688 uint64_t length,
1704 GNUNET_FS_DataReader reader, 1689 GNUNET_FS_DataReader reader,
1705 void *reader_cls, 1690 void *reader_cls,
@@ -1730,6 +1715,7 @@ typedef void (*GNUNET_FS_FileProcessor)(void *cls,
1730 * Type of a function that will be used to scan a directory. 1715 * Type of a function that will be used to scan a directory.
1731 * 1716 *
1732 * @param cls closure 1717 * @param cls closure
1718 * @param h handle to the file sharing subsystem
1733 * @param dirname name of the directory to scan 1719 * @param dirname name of the directory to scan
1734 * @param do_index should files be indexed or inserted 1720 * @param do_index should files be indexed or inserted
1735 * @param anonymity desired anonymity level 1721 * @param anonymity desired anonymity level
@@ -1741,6 +1727,7 @@ typedef void (*GNUNET_FS_FileProcessor)(void *cls,
1741 * @return GNUNET_OK on success 1727 * @return GNUNET_OK on success
1742 */ 1728 */
1743typedef int (*GNUNET_FS_DirectoryScanner)(void *cls, 1729typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1730 struct GNUNET_FS_Handle *h,
1744 const char *dirname, 1731 const char *dirname,
1745 int do_index, 1732 int do_index,
1746 uint32_t anonymity, 1733 uint32_t anonymity,
@@ -1764,6 +1751,7 @@ typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1764 * convenience function. 1751 * convenience function.
1765 * 1752 *
1766 * @param cls must be of type "struct EXTRACTOR_Extractor*" 1753 * @param cls must be of type "struct EXTRACTOR_Extractor*"
1754 * @param h handle to the file sharing subsystem
1767 * @param dirname name of the directory to scan 1755 * @param dirname name of the directory to scan
1768 * @param do_index should files be indexed or inserted 1756 * @param do_index should files be indexed or inserted
1769 * @param anonymity desired anonymity level 1757 * @param anonymity desired anonymity level
@@ -1776,6 +1764,7 @@ typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1776 */ 1764 */
1777int 1765int
1778GNUNET_FS_directory_scanner_default (void *cls, 1766GNUNET_FS_directory_scanner_default (void *cls,
1767 struct GNUNET_FS_Handle *h,
1779 const char *dirname, 1768 const char *dirname,
1780 int do_index, 1769 int do_index,
1781 uint32_t anonymity, 1770 uint32_t anonymity,
@@ -1796,6 +1785,7 @@ GNUNET_FS_directory_scanner_default (void *cls,
1796 * passed (GNUNET_FS_directory_scanner_default). This is strictly a 1785 * passed (GNUNET_FS_directory_scanner_default). This is strictly a
1797 * convenience function. 1786 * convenience function.
1798 * 1787 *
1788 * @param h handle to the file sharing subsystem
1799 * @param client_info initial client-info value for this entry 1789 * @param client_info initial client-info value for this entry
1800 * @param filename name of the top-level file or directory 1790 * @param filename name of the top-level file or directory
1801 * @param scanner function used to get a list of files in a directory 1791 * @param scanner function used to get a list of files in a directory
@@ -1810,7 +1800,8 @@ GNUNET_FS_directory_scanner_default (void *cls,
1810 * @return publish structure entry for the directory, NULL on error 1800 * @return publish structure entry for the directory, NULL on error
1811 */ 1801 */
1812struct GNUNET_FS_FileInformation * 1802struct GNUNET_FS_FileInformation *
1813GNUNET_FS_file_information_create_from_directory (void *client_info, 1803GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
1804 void *client_info,
1814 const char *filename, 1805 const char *filename,
1815 GNUNET_FS_DirectoryScanner scanner, 1806 GNUNET_FS_DirectoryScanner scanner,
1816 void *scanner_cls, 1807 void *scanner_cls,
@@ -1827,6 +1818,7 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
1827 * use of "GNUNET_FS_file_information_create_from_directory" 1818 * use of "GNUNET_FS_file_information_create_from_directory"
1828 * is not appropriate. 1819 * is not appropriate.
1829 * 1820 *
1821 * @param h handle to the file sharing subsystem
1830 * @param client_info initial client-info value for this entry 1822 * @param client_info initial client-info value for this entry
1831 * @param keywords under which keywords should this directory be available 1823 * @param keywords under which keywords should this directory be available
1832 * directly; can be NULL 1824 * directly; can be NULL
@@ -1839,7 +1831,8 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
1839 * @return publish structure entry for the directory , NULL on error 1831 * @return publish structure entry for the directory , NULL on error
1840 */ 1832 */
1841struct GNUNET_FS_FileInformation * 1833struct GNUNET_FS_FileInformation *
1842GNUNET_FS_file_information_create_empty_directory (void *client_info, 1834GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
1835 void *client_info,
1843 const struct GNUNET_FS_Uri *keywords, 1836 const struct GNUNET_FS_Uri *keywords,
1844 const struct GNUNET_CONTAINER_MetaData *meta, 1837 const struct GNUNET_CONTAINER_MetaData *meta,
1845 uint32_t anonymity, 1838 uint32_t anonymity,
diff --git a/src/util/disk.c b/src/util/disk.c
index 233802569..4477dc135 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -266,7 +266,10 @@ GNUNET_DISK_file_get_identifiers (const char *filename,
266 266
267 267
268/** 268/**
269 * Create an (empty) temporary file on disk. 269 * Create an (empty) temporary file on disk. If the given name is not
270 * an absolute path, the current 'TMPDIR' will be prepended. In any case,
271 * 6 random characters will be appended to the name to create a unique
272 * filename.
270 * 273 *
271 * @param t component to use for the name; 274 * @param t component to use for the name;
272 * does NOT contain "XXXXXX" or "/tmp/". 275 * does NOT contain "XXXXXX" or "/tmp/".
@@ -281,10 +284,17 @@ GNUNET_DISK_mktemp (const char *t)
281 char *tmpl; 284 char *tmpl;
282 char *fn; 285 char *fn;
283 286
284 tmpdir = getenv ("TMPDIR"); 287 if ( (t[0] != '/') &&
285 tmpdir = tmpdir ? tmpdir : "/tmp"; 288 (t[0] != '\\') )
286 289 {
287 GNUNET_asprintf (&tmpl, "%s/%s%s", tmpdir, t, "XXXXXX"); 290 tmpdir = getenv ("TMPDIR");
291 tmpdir = tmpdir ? tmpdir : "/tmp";
292 GNUNET_asprintf (&tmpl, "%s/%s%s", tmpdir, t, "XXXXXX");
293 }
294 else
295 {
296 GNUNET_asprintf (&tmpl, "%s%s", t, "XXXXXX");
297 }
288#ifdef MINGW 298#ifdef MINGW
289 fn = (char *) GNUNET_malloc (MAX_PATH + 1); 299 fn = (char *) GNUNET_malloc (MAX_PATH + 1);
290 if (ERROR_SUCCESS != plibc_conv_to_win_path (tmpl, fn)) 300 if (ERROR_SUCCESS != plibc_conv_to_win_path (tmpl, fn))