aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_disk_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_disk_lib.h')
-rw-r--r--src/include/gnunet_disk_lib.h171
1 files changed, 94 insertions, 77 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index f5fae80c9..abca17370 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -262,7 +262,8 @@ enum GNUNET_DISK_PipeEnd
262 * @param part a file on the partition to check 262 * @param part a file on the partition to check
263 * @return -1 on errors, otherwise the number of free blocks 263 * @return -1 on errors, otherwise the number of free blocks
264 */ 264 */
265long GNUNET_DISK_get_blocks_available (const char *part); 265long
266GNUNET_DISK_get_blocks_available (const char *part);
266 267
267 268
268/** 269/**
@@ -271,7 +272,8 @@ long GNUNET_DISK_get_blocks_available (const char *part);
271 * @param h handle to check 272 * @param h handle to check
272 * @return GNUNET_YES if invalid, GNUNET_NO if valid 273 * @return GNUNET_YES if invalid, GNUNET_NO if valid
273 */ 274 */
274int GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); 275int
276GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h);
275 277
276 278
277/** 279/**
@@ -282,7 +284,8 @@ int GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h);
282 * @return GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if something 284 * @return GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if something
283 * else (will print an error message in that case, too). 285 * else (will print an error message in that case, too).
284 */ 286 */
285int GNUNET_DISK_file_test (const char *fil); 287int
288GNUNET_DISK_file_test (const char *fil);
286 289
287 290
288/** 291/**
@@ -292,8 +295,9 @@ int GNUNET_DISK_file_test (const char *fil);
292 * @param whence specification to which position the offset parameter relates to 295 * @param whence specification to which position the offset parameter relates to
293 * @return the new position on success, GNUNET_SYSERR otherwise 296 * @return the new position on success, GNUNET_SYSERR otherwise
294 */ 297 */
295off_t GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, 298off_t
296 off_t offset, enum GNUNET_DISK_Seek whence); 299GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset,
300 enum GNUNET_DISK_Seek whence);
297 301
298 302
299/** 303/**
@@ -308,8 +312,9 @@ off_t GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h,
308 * included? 312 * included?
309 * @return GNUNET_OK on success, GNUNET_SYSERR on error 313 * @return GNUNET_OK on success, GNUNET_SYSERR on error
310 */ 314 */
311int GNUNET_DISK_file_size (const char *filename, uint64_t * size, 315int
312 int includeSymLinks); 316GNUNET_DISK_file_size (const char *filename, uint64_t * size,
317 int includeSymLinks);
313 318
314 319
315/** 320/**
@@ -327,8 +332,9 @@ int GNUNET_DISK_file_size (const char *filename, uint64_t * size,
327 * @param ino set to the inode ID 332 * @param ino set to the inode ID
328 * @return GNUNET_OK on success 333 * @return GNUNET_OK on success
329 */ 334 */
330int GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev, 335int
331 uint64_t * ino); 336GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev,
337 uint64_t * ino);
332 338
333 339
334/** 340/**
@@ -342,7 +348,8 @@ int GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev,
342 * @return NULL on error, otherwise name of fresh 348 * @return NULL on error, otherwise name of fresh
343 * file on disk in directory for temporary files 349 * file on disk in directory for temporary files
344 */ 350 */
345char *GNUNET_DISK_mktemp (const char *t); 351char *
352GNUNET_DISK_mktemp (const char *t);
346 353
347 354
348/** 355/**
@@ -357,12 +364,9 @@ char *GNUNET_DISK_mktemp (const char *t);
357 * call (because of flags) 364 * call (because of flags)
358 * @return IO handle on success, NULL on error 365 * @return IO handle on success, NULL on error
359 */ 366 */
360struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn, 367struct GNUNET_DISK_FileHandle *
361 enum GNUNET_DISK_OpenFlags 368GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
362 flags, 369 enum GNUNET_DISK_AccessPermissions perm);
363 enum
364 GNUNET_DISK_AccessPermissions
365 perm);
366 370
367/** 371/**
368 * Creates an interprocess channel 372 * Creates an interprocess channel
@@ -371,8 +375,8 @@ struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn,
371 * @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only) 375 * @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only)
372 * @return handle to the new pipe, NULL on error 376 * @return handle to the new pipe, NULL on error
373 */ 377 */
374struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking, int inherit_read, 378struct GNUNET_DISK_PipeHandle *
375 int inherit_write); 379GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write);
376 380
377 381
378/** 382/**
@@ -380,7 +384,8 @@ struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking, int inherit_read,
380 * @param p pipe 384 * @param p pipe
381 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 385 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
382 */ 386 */
383int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); 387int
388GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
384 389
385/** 390/**
386 * Closes one half of an interprocess channel 391 * Closes one half of an interprocess channel
@@ -389,8 +394,9 @@ int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
389 * @param end which end of the pipe to close 394 * @param end which end of the pipe to close
390 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 395 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
391 */ 396 */
392int GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, 397int
393 enum GNUNET_DISK_PipeEnd end); 398GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p,
399 enum GNUNET_DISK_PipeEnd end);
394 400
395/** 401/**
396 * Close an open file. 402 * Close an open file.
@@ -398,7 +404,8 @@ int GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p,
398 * @param h file handle 404 * @param h file handle
399 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 405 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
400 */ 406 */
401int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); 407int
408GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
402 409
403 410
404/** 411/**
@@ -408,12 +415,9 @@ int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
408 * @param n end to access 415 * @param n end to access
409 * @return handle for the respective end 416 * @return handle for the respective end
410 */ 417 */
411const struct GNUNET_DISK_FileHandle *GNUNET_DISK_pipe_handle (const struct 418const struct GNUNET_DISK_FileHandle *
412 GNUNET_DISK_PipeHandle 419GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p,
413 *p, 420 enum GNUNET_DISK_PipeEnd n);
414 enum
415 GNUNET_DISK_PipeEnd
416 n);
417 421
418/** 422/**
419 * Read the contents of a binary file into a buffer. 423 * Read the contents of a binary file into a buffer.
@@ -422,8 +426,9 @@ const struct GNUNET_DISK_FileHandle *GNUNET_DISK_pipe_handle (const struct
422 * @param len the maximum number of bytes to read 426 * @param len the maximum number of bytes to read
423 * @return the number of bytes read on success, GNUNET_SYSERR on failure 427 * @return the number of bytes read on success, GNUNET_SYSERR on failure
424 */ 428 */
425ssize_t GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, 429ssize_t
426 void *result, size_t len); 430GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result,
431 size_t len);
427 432
428 433
429/** 434/**
@@ -434,7 +439,8 @@ ssize_t GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h,
434 * @param len the maximum number of bytes to read 439 * @param len the maximum number of bytes to read
435 * @return number of bytes read, GNUNET_SYSERR on failure 440 * @return number of bytes read, GNUNET_SYSERR on failure
436 */ 441 */
437ssize_t GNUNET_DISK_fn_read (const char *fn, void *result, size_t len); 442ssize_t
443GNUNET_DISK_fn_read (const char *fn, void *result, size_t len);
438 444
439 445
440/** 446/**
@@ -445,8 +451,9 @@ ssize_t GNUNET_DISK_fn_read (const char *fn, void *result, size_t len);
445 * @param n number of bytes to write 451 * @param n number of bytes to write
446 * @return number of bytes written on success, GNUNET_SYSERR on error 452 * @return number of bytes written on success, GNUNET_SYSERR on error
447 */ 453 */
448ssize_t GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, 454ssize_t
449 const void *buffer, size_t n); 455GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h,
456 const void *buffer, size_t n);
450 457
451 458
452/** 459/**
@@ -459,8 +466,9 @@ ssize_t GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h,
459 * @param mode file permissions 466 * @param mode file permissions
460 * @return number of bytes written on success, GNUNET_SYSERR on error 467 * @return number of bytes written on success, GNUNET_SYSERR on error
461 */ 468 */
462ssize_t GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, 469ssize_t
463 enum GNUNET_DISK_AccessPermissions mode); 470GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n,
471 enum GNUNET_DISK_AccessPermissions mode);
464 472
465 473
466/** 474/**
@@ -470,7 +478,8 @@ ssize_t GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n,
470 * @param dst destination file name 478 * @param dst destination file name
471 * @return GNUNET_OK on success, GNUNET_SYSERR on error 479 * @return GNUNET_OK on success, GNUNET_SYSERR on error
472 */ 480 */
473int GNUNET_DISK_file_copy (const char *src, const char *dst); 481int
482GNUNET_DISK_file_copy (const char *src, const char *dst);
474 483
475 484
476/** 485/**
@@ -481,9 +490,10 @@ int GNUNET_DISK_file_copy (const char *src, const char *dst);
481 * @param callback_cls closure for callback 490 * @param callback_cls closure for callback
482 * @return the number of files found, -1 on error 491 * @return the number of files found, -1 on error
483 */ 492 */
484int GNUNET_DISK_directory_scan (const char *dirName, 493int
485 GNUNET_FileNameCallback callback, 494GNUNET_DISK_directory_scan (const char *dirName,
486 void *callback_cls); 495 GNUNET_FileNameCallback callback,
496 void *callback_cls);
487 497
488 498
489/** 499/**
@@ -521,8 +531,9 @@ typedef void (*GNUNET_DISK_DirectoryIteratorCallback) (void *cls,
521 * GNUNET_NO if this was the last entry (and iteration is complete), 531 * GNUNET_NO if this was the last entry (and iteration is complete),
522 * GNUNET_SYSERR if "can" was YES 532 * GNUNET_SYSERR if "can" was YES
523 */ 533 */
524int GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator 534int
525 *iter, int can); 535GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter,
536 int can);
526 537
527 538
528/** 539/**
@@ -536,10 +547,11 @@ int GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator
536 * @param callback the method to call for each file 547 * @param callback the method to call for each file
537 * @param callback_cls closure for callback 548 * @param callback_cls closure for callback
538 */ 549 */
539void GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, 550void
540 const char *dirName, 551GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
541 GNUNET_DISK_DirectoryIteratorCallback 552 const char *dirName,
542 callback, void *callback_cls); 553 GNUNET_DISK_DirectoryIteratorCallback
554 callback, void *callback_cls);
543 555
544 556
545/** 557/**
@@ -550,7 +562,8 @@ void GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
550 * @returns GNUNET_OK on success, GNUNET_SYSERR on failure, 562 * @returns GNUNET_OK on success, GNUNET_SYSERR on failure,
551 * GNUNET_NO if directory exists but is not writeable 563 * GNUNET_NO if directory exists but is not writeable
552 */ 564 */
553int GNUNET_DISK_directory_create_for_file (const char *filename); 565int
566GNUNET_DISK_directory_create_for_file (const char *filename);
554 567
555 568
556/** 569/**
@@ -563,7 +576,8 @@ int GNUNET_DISK_directory_create_for_file (const char *filename);
563 * @return GNUNET_YES if yes, GNUNET_NO if does not exist, GNUNET_SYSERR 576 * @return GNUNET_YES if yes, GNUNET_NO if does not exist, GNUNET_SYSERR
564 * on any error and if exists but not directory 577 * on any error and if exists but not directory
565 */ 578 */
566int GNUNET_DISK_directory_test (const char *fil); 579int
580GNUNET_DISK_directory_test (const char *fil);
567 581
568 582
569/** 583/**
@@ -573,7 +587,8 @@ int GNUNET_DISK_directory_test (const char *fil);
573 * @param fileName the file to remove 587 * @param fileName the file to remove
574 * @return GNUNET_OK on success, GNUNET_SYSERR on error 588 * @return GNUNET_OK on success, GNUNET_SYSERR on error
575 */ 589 */
576int GNUNET_DISK_directory_remove (const char *fileName); 590int
591GNUNET_DISK_directory_remove (const char *fileName);
577 592
578 593
579/** 594/**
@@ -582,7 +597,8 @@ int GNUNET_DISK_directory_remove (const char *fileName);
582 * @param dir the directory to create 597 * @param dir the directory to create
583 * @returns GNUNET_SYSERR on failure, GNUNET_OK otherwise 598 * @returns GNUNET_SYSERR on failure, GNUNET_OK otherwise
584 */ 599 */
585int GNUNET_DISK_directory_create (const char *dir); 600int
601GNUNET_DISK_directory_create (const char *dir);
586 602
587 603
588/** 604/**
@@ -594,8 +610,9 @@ int GNUNET_DISK_directory_create (const char *dir);
594 * @param excl GNUNET_YES for an exclusive lock 610 * @param excl GNUNET_YES for an exclusive lock
595 * @return GNUNET_OK on success, GNUNET_SYSERR on error 611 * @return GNUNET_OK on success, GNUNET_SYSERR on error
596 */ 612 */
597int GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, 613int
598 off_t lockEnd, int excl); 614GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
615 off_t lockEnd, int excl);
599 616
600 617
601/** 618/**
@@ -605,15 +622,17 @@ int GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
605 * @param unlockEnd absolute position until where to unlock 622 * @param unlockEnd absolute position until where to unlock
606 * @return GNUNET_OK on success, GNUNET_SYSERR on error 623 * @return GNUNET_OK on success, GNUNET_SYSERR on error
607 */ 624 */
608int GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, 625int
609 off_t unlockStart, off_t unlockEnd); 626GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart,
627 off_t unlockEnd);
610 628
611 629
612/** 630/**
613 * @brief Removes special characters as ':' from a filename. 631 * @brief Removes special characters as ':' from a filename.
614 * @param fn the filename to canonicalize 632 * @param fn the filename to canonicalize
615 */ 633 */
616void GNUNET_DISK_filename_canonicalize (char *fn); 634void
635GNUNET_DISK_filename_canonicalize (char *fn);
617 636
618 637
619/** 638/**
@@ -622,7 +641,8 @@ void GNUNET_DISK_filename_canonicalize (char *fn);
622 * @param user new owner of the file 641 * @param user new owner of the file
623 * @return GNUNET_OK on success, GNUNET_SYSERR on failure 642 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
624 */ 643 */
625int GNUNET_DISK_file_change_owner (const char *filename, const char *user); 644int
645GNUNET_DISK_file_change_owner (const char *filename, const char *user);
626 646
627 647
628/** 648/**
@@ -639,8 +659,9 @@ int GNUNET_DISK_file_change_owner (const char *filename, const char *user);
639 * private directory name. 659 * private directory name.
640 * @return the constructed filename 660 * @return the constructed filename
641 */ 661 */
642char *GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle 662char *
643 *cfg, const char *serviceName, ...); 663GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg,
664 const char *serviceName, ...);
644 665
645 666
646/** 667/**
@@ -656,9 +677,10 @@ struct GNUNET_DISK_MapHandle;
656 * @param len size of the mapping 677 * @param len size of the mapping
657 * @return pointer to the mapped memory region, NULL on failure 678 * @return pointer to the mapped memory region, NULL on failure
658 */ 679 */
659void *GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, 680void *
660 struct GNUNET_DISK_MapHandle **m, 681GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h,
661 enum GNUNET_DISK_MapType access, size_t len); 682 struct GNUNET_DISK_MapHandle **m,
683 enum GNUNET_DISK_MapType access, size_t len);
662 684
663/** 685/**
664 * Unmap a file 686 * Unmap a file
@@ -666,14 +688,16 @@ void *GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h,
666 * @param h mapping handle 688 * @param h mapping handle
667 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 689 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
668 */ 690 */
669int GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); 691int
692GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h);
670 693
671/** 694/**
672 * Write file changes to disk 695 * Write file changes to disk
673 * @param h handle to an open file 696 * @param h handle to an open file
674 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 697 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
675 */ 698 */
676int GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); 699int
700GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h);
677 701
678/** 702/**
679 * Creates a named pipe/FIFO and opens it 703 * Creates a named pipe/FIFO and opens it
@@ -682,13 +706,9 @@ int GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h);
682 * @param perm access permissions 706 * @param perm access permissions
683 * @return pipe handle on success, NULL on error 707 * @return pipe handle on success, NULL on error
684 */ 708 */
685struct GNUNET_DISK_FileHandle *GNUNET_DISK_npipe_create (char **fn, 709struct GNUNET_DISK_FileHandle *
686 enum 710GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
687 GNUNET_DISK_OpenFlags 711 enum GNUNET_DISK_AccessPermissions perm);
688 flags,
689 enum
690 GNUNET_DISK_AccessPermissions
691 perm);
692 712
693/** 713/**
694 * Opens already existing named pipe/FIFO 714 * Opens already existing named pipe/FIFO
@@ -698,20 +718,17 @@ struct GNUNET_DISK_FileHandle *GNUNET_DISK_npipe_create (char **fn,
698 * @param perm access permissions 718 * @param perm access permissions
699 * @return pipe handle on success, NULL on error 719 * @return pipe handle on success, NULL on error
700 */ 720 */
701struct GNUNET_DISK_FileHandle *GNUNET_DISK_npipe_open (const char *fn, 721struct GNUNET_DISK_FileHandle *
702 enum 722GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
703 GNUNET_DISK_OpenFlags 723 enum GNUNET_DISK_AccessPermissions perm);
704 flags,
705 enum
706 GNUNET_DISK_AccessPermissions
707 perm);
708 724
709/** 725/**
710 * Closes a named pipe/FIFO 726 * Closes a named pipe/FIFO
711 * @param pipe named pipe 727 * @param pipe named pipe
712 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 728 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
713 */ 729 */
714int GNUNET_DISK_npipe_close (struct GNUNET_DISK_FileHandle *pipe); 730int
731GNUNET_DISK_npipe_close (struct GNUNET_DISK_FileHandle *pipe);
715 732
716#if 0 /* keep Emacsens' auto-indent happy */ 733#if 0 /* keep Emacsens' auto-indent happy */
717{ 734{