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.h46
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 */
254int 254enum GNUNET_GenericReturnValue
255GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); 255GNUNET_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 */
266int 266enum GNUNET_GenericReturnValue
267GNUNET_DISK_file_test (const char *fil); 267GNUNET_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 */
307int 307enum GNUNET_GenericReturnValue
308GNUNET_DISK_file_size (const char *filename, 308GNUNET_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 */
329int 329enum GNUNET_GenericReturnValue
330GNUNET_DISK_file_get_identifiers (const char *filename, 330GNUNET_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 */
388int 388enum GNUNET_GenericReturnValue
389GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, 389GNUNET_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 */
450int 450enum GNUNET_GenericReturnValue
451GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); 451GNUNET_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 */
461int 461enum GNUNET_GenericReturnValue
462GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, 462GNUNET_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 */
488int 488enum GNUNET_GenericReturnValue
489GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); 489GNUNET_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 */
621ssize_t 624enum GNUNET_GenericReturnValue
622GNUNET_DISK_fn_write (const char *fn, 625GNUNET_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 */
635int 638enum GNUNET_GenericReturnValue
636GNUNET_DISK_file_copy (const char *src, 639GNUNET_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 */
662int 665enum GNUNET_GenericReturnValue
663GNUNET_DISK_directory_create_for_file (const char *filename); 666GNUNET_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 */
678int 681enum GNUNET_GenericReturnValue
679GNUNET_DISK_directory_test (const char *fil, int is_readable); 682GNUNET_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 */
688int 692enum GNUNET_GenericReturnValue
689GNUNET_DISK_directory_remove (const char *filename); 693GNUNET_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 */
710int 714enum GNUNET_GenericReturnValue
711GNUNET_DISK_directory_create (const char *dir); 715GNUNET_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 */
728int 732enum GNUNET_GenericReturnValue
729GNUNET_DISK_file_change_owner (const char *filename, 733GNUNET_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 */
761int 765enum GNUNET_GenericReturnValue
762GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); 766GNUNET_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 */
771int 775enum GNUNET_GenericReturnValue
772GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); 776GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h);
773 777
774 778