diff options
Diffstat (limited to 'src/include/gnunet_disk_lib.h')
-rw-r--r-- | src/include/gnunet_disk_lib.h | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 3f29dc2e4..b794088c4 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -251,7 +251,7 @@ enum GNUNET_DISK_PipeEnd | |||
251 | * @param h handle to check | 251 | * @param h handle to check |
252 | * @return #GNUNET_YES if invalid, #GNUNET_NO if valid | 252 | * @return #GNUNET_YES if invalid, #GNUNET_NO if valid |
253 | */ | 253 | */ |
254 | int | 254 | enum GNUNET_GenericReturnValue |
255 | GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); | 255 | GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); |
256 | 256 | ||
257 | 257 | ||
@@ -263,7 +263,7 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); | |||
263 | * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something | 263 | * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something |
264 | * else (will print an error message in that case, too). | 264 | * else (will print an error message in that case, too). |
265 | */ | 265 | */ |
266 | int | 266 | enum GNUNET_GenericReturnValue |
267 | GNUNET_DISK_file_test (const char *fil); | 267 | GNUNET_DISK_file_test (const char *fil); |
268 | 268 | ||
269 | 269 | ||
@@ -304,7 +304,7 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, | |||
304 | * and return #GNUNET_SYSERR for directories. | 304 | * and return #GNUNET_SYSERR for directories. |
305 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 305 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
306 | */ | 306 | */ |
307 | int | 307 | enum GNUNET_GenericReturnValue |
308 | GNUNET_DISK_file_size (const char *filename, | 308 | GNUNET_DISK_file_size (const char *filename, |
309 | uint64_t *size, | 309 | uint64_t *size, |
310 | int include_symbolic_links, | 310 | int include_symbolic_links, |
@@ -326,7 +326,7 @@ GNUNET_DISK_file_size (const char *filename, | |||
326 | * @param ino set to the inode ID | 326 | * @param ino set to the inode ID |
327 | * @return #GNUNET_OK on success | 327 | * @return #GNUNET_OK on success |
328 | */ | 328 | */ |
329 | int | 329 | enum GNUNET_GenericReturnValue |
330 | GNUNET_DISK_file_get_identifiers (const char *filename, | 330 | GNUNET_DISK_file_get_identifiers (const char *filename, |
331 | uint64_t *dev, | 331 | uint64_t *dev, |
332 | uint64_t *ino); | 332 | uint64_t *ino); |
@@ -385,7 +385,7 @@ GNUNET_DISK_file_open (const char *fn, | |||
385 | * @param size where to write size of the file | 385 | * @param size where to write size of the file |
386 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 386 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
387 | */ | 387 | */ |
388 | int | 388 | enum GNUNET_GenericReturnValue |
389 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | 389 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, |
390 | off_t *size); | 390 | off_t *size); |
391 | 391 | ||
@@ -447,7 +447,7 @@ GNUNET_DISK_pipe_from_fd (enum GNUNET_DISK_PipeFlags pf, | |||
447 | * @param p pipe | 447 | * @param p pipe |
448 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 448 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
449 | */ | 449 | */ |
450 | int | 450 | enum GNUNET_GenericReturnValue |
451 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | 451 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); |
452 | 452 | ||
453 | 453 | ||
@@ -458,7 +458,7 @@ GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | |||
458 | * @param end which end of the pipe to close | 458 | * @param end which end of the pipe to close |
459 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 459 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
460 | */ | 460 | */ |
461 | int | 461 | enum GNUNET_GenericReturnValue |
462 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, | 462 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, |
463 | enum GNUNET_DISK_PipeEnd end); | 463 | enum GNUNET_DISK_PipeEnd end); |
464 | 464 | ||
@@ -485,7 +485,7 @@ GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, | |||
485 | * @param h file handle | 485 | * @param h file handle |
486 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 486 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
487 | */ | 487 | */ |
488 | int | 488 | enum GNUNET_GenericReturnValue |
489 | GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); | 489 | GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); |
490 | 490 | ||
491 | 491 | ||
@@ -609,16 +609,19 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, | |||
609 | 609 | ||
610 | 610 | ||
611 | /** | 611 | /** |
612 | * Write a buffer to a file. If the file is longer than | 612 | * Write a buffer to a file atomically. The directory is created if |
613 | * the given buffer size, it will be truncated. | 613 | * necessary. Fail if @a filename already exists or if not exactly @a buf |
614 | * with @a buf_size bytes could be written to @a filename. | ||
614 | * | 615 | * |
615 | * @param fn file name | 616 | * @param fn file name |
616 | * @param buffer the data to write | 617 | * @param buffer the data to write |
617 | * @param n number of bytes to write | 618 | * @param n number of bytes to write |
618 | * @param mode file permissions | 619 | * @param mode file permissions |
619 | * @return number of bytes written on success, #GNUNET_SYSERR on error | 620 | * @return #GNUNET_OK on success, |
621 | * #GNUNET_NO if a file existed under @a filename | ||
622 | * #GNUNET_SYSERR on failure | ||
620 | */ | 623 | */ |
621 | ssize_t | 624 | enum GNUNET_GenericReturnValue |
622 | GNUNET_DISK_fn_write (const char *fn, | 625 | GNUNET_DISK_fn_write (const char *fn, |
623 | const void *buffer, | 626 | const void *buffer, |
624 | size_t n, | 627 | size_t n, |
@@ -632,7 +635,7 @@ GNUNET_DISK_fn_write (const char *fn, | |||
632 | * @param dst destination file name | 635 | * @param dst destination file name |
633 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 636 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
634 | */ | 637 | */ |
635 | int | 638 | enum GNUNET_GenericReturnValue |
636 | GNUNET_DISK_file_copy (const char *src, | 639 | GNUNET_DISK_file_copy (const char *src, |
637 | const char *dst); | 640 | const char *dst); |
638 | 641 | ||
@@ -659,7 +662,7 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
659 | * @returns #GNUNET_OK on success, #GNUNET_SYSERR on failure, | 662 | * @returns #GNUNET_OK on success, #GNUNET_SYSERR on failure, |
660 | * #GNUNET_NO if directory exists but is not writeable | 663 | * #GNUNET_NO if directory exists but is not writeable |
661 | */ | 664 | */ |
662 | int | 665 | enum GNUNET_GenericReturnValue |
663 | GNUNET_DISK_directory_create_for_file (const char *filename); | 666 | GNUNET_DISK_directory_create_for_file (const char *filename); |
664 | 667 | ||
665 | 668 | ||
@@ -675,8 +678,9 @@ GNUNET_DISK_directory_create_for_file (const char *filename); | |||
675 | * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it | 678 | * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it |
676 | * does not exist or `stat`ed | 679 | * does not exist or `stat`ed |
677 | */ | 680 | */ |
678 | int | 681 | enum GNUNET_GenericReturnValue |
679 | GNUNET_DISK_directory_test (const char *fil, int is_readable); | 682 | GNUNET_DISK_directory_test (const char *fil, |
683 | int is_readable); | ||
680 | 684 | ||
681 | 685 | ||
682 | /** | 686 | /** |
@@ -685,7 +689,7 @@ GNUNET_DISK_directory_test (const char *fil, int is_readable); | |||
685 | * @param filename the file to remove | 689 | * @param filename the file to remove |
686 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 690 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
687 | */ | 691 | */ |
688 | int | 692 | enum GNUNET_GenericReturnValue |
689 | GNUNET_DISK_directory_remove (const char *filename); | 693 | GNUNET_DISK_directory_remove (const char *filename); |
690 | 694 | ||
691 | 695 | ||
@@ -707,7 +711,7 @@ GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, | |||
707 | * @param dir the directory to create | 711 | * @param dir the directory to create |
708 | * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise | 712 | * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise |
709 | */ | 713 | */ |
710 | int | 714 | enum GNUNET_GenericReturnValue |
711 | GNUNET_DISK_directory_create (const char *dir); | 715 | GNUNET_DISK_directory_create (const char *dir); |
712 | 716 | ||
713 | 717 | ||
@@ -725,7 +729,7 @@ GNUNET_DISK_filename_canonicalize (char *fn); | |||
725 | * @param user new owner of the file | 729 | * @param user new owner of the file |
726 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 730 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
727 | */ | 731 | */ |
728 | int | 732 | enum GNUNET_GenericReturnValue |
729 | GNUNET_DISK_file_change_owner (const char *filename, | 733 | GNUNET_DISK_file_change_owner (const char *filename, |
730 | const char *user); | 734 | const char *user); |
731 | 735 | ||
@@ -758,7 +762,7 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, | |||
758 | * @param h mapping handle | 762 | * @param h mapping handle |
759 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 763 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
760 | */ | 764 | */ |
761 | int | 765 | enum GNUNET_GenericReturnValue |
762 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); | 766 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); |
763 | 767 | ||
764 | 768 | ||
@@ -768,7 +772,7 @@ GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); | |||
768 | * @param h handle to an open file | 772 | * @param h handle to an open file |
769 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 773 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
770 | */ | 774 | */ |
771 | int | 775 | enum GNUNET_GenericReturnValue |
772 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); | 776 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); |
773 | 777 | ||
774 | 778 | ||