aboutsummaryrefslogtreecommitdiff
path: root/src/util/disk.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-06 11:16:26 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-06 11:16:26 +0000
commit2ebfdbbe8af9eef26ad1a2776a20227715560558 (patch)
tree9ce4e1f88ab32a156653dc6d74a9c02a82c77ee1 /src/util/disk.c
parentb0f956058355ea7e96a7d3022b08dd951acd99a5 (diff)
downloadgnunet-2ebfdbbe8af9eef26ad1a2776a20227715560558.tar.gz
gnunet-2ebfdbbe8af9eef26ad1a2776a20227715560558.zip
-load revocations from disk, misc doxygen/style fixes
Diffstat (limited to 'src/util/disk.c')
-rw-r--r--src/util/disk.c158
1 files changed, 84 insertions, 74 deletions
diff --git a/src/util/disk.c b/src/util/disk.c
index 9390743fd..d349aeb8e 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -282,23 +282,23 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, OFF_T offset,
282 * @param size set to the size of the file (or, 282 * @param size set to the size of the file (or,
283 * in the case of directories, the sum 283 * in the case of directories, the sum
284 * of all sizes of files in the directory) 284 * of all sizes of files in the directory)
285 * @param includeSymLinks should symbolic links be 285 * @param include_symbolic_links should symbolic links be
286 * included? 286 * included?
287 * @param singleFileMode GNUNET_YES to only get size of one file 287 * @param single_file_mode GNUNET_YES to only get size of one file
288 * and return GNUNET_SYSERR for directories. 288 * and return GNUNET_SYSERR for directories.
289 * @return GNUNET_SYSERR on error, GNUNET_OK on success 289 * @return GNUNET_SYSERR on error, GNUNET_OK on success
290 */ 290 */
291int 291int
292GNUNET_DISK_file_size (const char *filename, uint64_t * size, 292GNUNET_DISK_file_size (const char *filename, uint64_t * size,
293 int includeSymLinks, int singleFileMode) 293 int include_symbolic_links, int single_file_mode)
294{ 294{
295 struct GetFileSizeData gfsd; 295 struct GetFileSizeData gfsd;
296 int ret; 296 int ret;
297 297
298 GNUNET_assert (size != NULL); 298 GNUNET_assert (size != NULL);
299 gfsd.total = 0; 299 gfsd.total = 0;
300 gfsd.include_sym_links = includeSymLinks; 300 gfsd.include_sym_links = include_symbolic_links;
301 gfsd.single_file_mode = singleFileMode; 301 gfsd.single_file_mode = single_file_mode;
302 ret = getSizeRec (&gfsd, filename); 302 ret = getSizeRec (&gfsd, filename);
303 *size = gfsd.total; 303 *size = gfsd.total;
304 return ret; 304 return ret;
@@ -318,7 +318,7 @@ GNUNET_DISK_file_size (const char *filename, uint64_t * size,
318 * @param filename name of the file 318 * @param filename name of the file
319 * @param dev set to the device ID 319 * @param dev set to the device ID
320 * @param ino set to the inode ID 320 * @param ino set to the inode ID
321 * @return GNUNET_OK on success 321 * @return #GNUNET_OK on success
322 */ 322 */
323int 323int
324GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev, 324GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev,
@@ -557,15 +557,15 @@ GNUNET_DISK_mktemp (const char *t)
557 557
558 558
559/** 559/**
560 * Test if "fil" is a directory and listable. Optionally, also check if the 560 * Test if @a fil is a directory and listable. Optionally, also check if the
561 * directory is readable. Will not print an error message if the directory does 561 * directory is readable. Will not print an error message if the directory does
562 * not exist. Will log errors if GNUNET_SYSERR is returned (i.e., a file exists 562 * not exist. Will log errors if #GNUNET_SYSERR is returned (i.e., a file exists
563 * with the same name). 563 * with the same name).
564 * 564 *
565 * @param fil filename to test 565 * @param fil filename to test
566 * @param is_readable GNUNET_YES to additionally check if "fil" is readable; 566 * @param is_readable GNUNET_YES to additionally check if @a fil is readable;
567 * GNUNET_NO to disable this check 567 * #GNUNET_NO to disable this check
568 * @return GNUNET_YES if yes, GNUNET_NO if not; GNUNET_SYSERR if it 568 * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it
569 * does not exist or stat'ed 569 * does not exist or stat'ed
570 */ 570 */
571int 571int
@@ -605,7 +605,7 @@ GNUNET_DISK_directory_test (const char *fil, int is_readable)
605 * (of a file that exists and that is not a directory). 605 * (of a file that exists and that is not a directory).
606 * 606 *
607 * @param fil filename to check 607 * @param fil filename to check
608 * @return GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if something 608 * @return #GNUNET_YES if yes, GNUNET_NO if not a file, #GNUNET_SYSERR if something
609 * else (will print an error message in that case, too). 609 * else (will print an error message in that case, too).
610 */ 610 */
611int 611int
@@ -651,7 +651,7 @@ GNUNET_DISK_file_test (const char *fil)
651 * Implementation of "mkdir -p" 651 * Implementation of "mkdir -p"
652 * 652 *
653 * @param dir the directory to create 653 * @param dir the directory to create
654 * @returns GNUNET_OK on success, GNUNET_SYSERR on failure 654 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
655 */ 655 */
656int 656int
657GNUNET_DISK_directory_create (const char *dir) 657GNUNET_DISK_directory_create (const char *dir)
@@ -759,9 +759,9 @@ GNUNET_DISK_directory_create (const char *dir)
759 * a file. 759 * a file.
760 * 760 *
761 * @param filename name of a file in the directory 761 * @param filename name of a file in the directory
762 * @returns GNUNET_OK on success, 762 * @returns #GNUNET_OK on success,
763 * GNUNET_SYSERR on failure, 763 * #GNUNET_SYSERR on failure,
764 * GNUNET_NO if the directory 764 * #GNUNET_NO if the directory
765 * exists but is not writeable for us 765 * exists but is not writeable for us
766 */ 766 */
767int 767int
@@ -788,27 +788,29 @@ GNUNET_DISK_directory_create_for_file (const char *filename)
788 788
789/** 789/**
790 * Read the contents of a binary file into a buffer. 790 * Read the contents of a binary file into a buffer.
791 *
791 * @param h handle to an open file 792 * @param h handle to an open file
792 * @param result the buffer to write the result to 793 * @param result the buffer to write the result to
793 * @param len the maximum number of bytes to read 794 * @param len the maximum number of bytes to read
794 * @return the number of bytes read on success, GNUNET_SYSERR on failure 795 * @return the number of bytes read on success, #GNUNET_SYSERR on failure
795 */ 796 */
796ssize_t 797ssize_t
797GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result, 798GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h,
799 void *result,
798 size_t len) 800 size_t len)
799{ 801{
800 if (h == NULL) 802 if (NULL == h)
801 { 803 {
802 errno = EINVAL; 804 errno = EINVAL;
803 return GNUNET_SYSERR; 805 return GNUNET_SYSERR;
804 } 806 }
805 807
806#ifdef MINGW 808#ifdef MINGW
807 DWORD bytesRead; 809 DWORD bytes_read;
808 810
809 if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE) 811 if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
810 { 812 {
811 if (!ReadFile (h->h, result, len, &bytesRead, NULL)) 813 if (!ReadFile (h->h, result, len, &bytes_read, NULL))
812 { 814 {
813 SetErrnoFromWinError (GetLastError ()); 815 SetErrnoFromWinError (GetLastError ());
814 return GNUNET_SYSERR; 816 return GNUNET_SYSERR;
@@ -816,7 +818,7 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result,
816 } 818 }
817 else 819 else
818 { 820 {
819 if (!ReadFile (h->h, result, len, &bytesRead, h->oOverlapRead)) 821 if (!ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
820 { 822 {
821 if (GetLastError () != ERROR_IO_PENDING) 823 if (GetLastError () != ERROR_IO_PENDING)
822 { 824 {
@@ -825,11 +827,11 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result,
825 return GNUNET_SYSERR; 827 return GNUNET_SYSERR;
826 } 828 }
827 LOG (GNUNET_ERROR_TYPE_DEBUG, "Will get overlapped result\n"); 829 LOG (GNUNET_ERROR_TYPE_DEBUG, "Will get overlapped result\n");
828 GetOverlappedResult (h->h, h->oOverlapRead, &bytesRead, TRUE); 830 GetOverlappedResult (h->h, h->oOverlapRead, &bytes_read, TRUE);
829 } 831 }
830 LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes from pipe\n", bytesRead); 832 LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes from pipe\n", bytes_read);
831 } 833 }
832 return bytesRead; 834 return bytes_read;
833#else 835#else
834 return read (h->fd, result, len); 836 return read (h->fd, result, len);
835#endif 837#endif
@@ -844,25 +846,25 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result,
844 * @param h handle to an open file 846 * @param h handle to an open file
845 * @param result the buffer to write the result to 847 * @param result the buffer to write the result to
846 * @param len the maximum number of bytes to read 848 * @param len the maximum number of bytes to read
847 * @return the number of bytes read on success, GNUNET_SYSERR on failure 849 * @return the number of bytes read on success, #GNUNET_SYSERR on failure
848 */ 850 */
849ssize_t 851ssize_t
850GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h, 852GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h,
851 void *result, 853 void *result,
852 size_t len) 854 size_t len)
853{ 855{
854 if (h == NULL) 856 if (NULL == h)
855 { 857 {
856 errno = EINVAL; 858 errno = EINVAL;
857 return GNUNET_SYSERR; 859 return GNUNET_SYSERR;
858 } 860 }
859 861
860#ifdef MINGW 862#ifdef MINGW
861 DWORD bytesRead; 863 DWORD bytes_read;
862 864
863 if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE) 865 if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
864 { 866 {
865 if (!ReadFile (h->h, result, len, &bytesRead, NULL)) 867 if (!ReadFile (h->h, result, len, &bytes_read, NULL))
866 { 868 {
867 SetErrnoFromWinError (GetLastError ()); 869 SetErrnoFromWinError (GetLastError ());
868 return GNUNET_SYSERR; 870 return GNUNET_SYSERR;
@@ -870,7 +872,7 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
870 } 872 }
871 else 873 else
872 { 874 {
873 if (!ReadFile (h->h, result, len, &bytesRead, h->oOverlapRead)) 875 if (!ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
874 { 876 {
875 if (GetLastError () != ERROR_IO_PENDING) 877 if (GetLastError () != ERROR_IO_PENDING)
876 { 878 {
@@ -887,9 +889,9 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
887 return GNUNET_SYSERR; 889 return GNUNET_SYSERR;
888 } 890 }
889 } 891 }
890 LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes\n", bytesRead); 892 LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes\n", bytes_read);
891 } 893 }
892 return bytesRead; 894 return bytes_read;
893#else 895#else
894 int flags; 896 int flags;
895 ssize_t ret; 897 ssize_t ret;
@@ -916,10 +918,12 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
916 * @param fn file name 918 * @param fn file name
917 * @param result the buffer to write the result to 919 * @param result the buffer to write the result to
918 * @param len the maximum number of bytes to read 920 * @param len the maximum number of bytes to read
919 * @return number of bytes read, GNUNET_SYSERR on failure 921 * @return number of bytes read, #GNUNET_SYSERR on failure
920 */ 922 */
921ssize_t 923ssize_t
922GNUNET_DISK_fn_read (const char *fn, void *result, size_t len) 924GNUNET_DISK_fn_read (const char *fn,
925 void *result,
926 size_t len)
923{ 927{
924 struct GNUNET_DISK_FileHandle *fh; 928 struct GNUNET_DISK_FileHandle *fh;
925 ssize_t ret; 929 ssize_t ret;
@@ -936,27 +940,28 @@ GNUNET_DISK_fn_read (const char *fn, void *result, size_t len)
936 940
937/** 941/**
938 * Write a buffer to a file. 942 * Write a buffer to a file.
943 *
939 * @param h handle to open file 944 * @param h handle to open file
940 * @param buffer the data to write 945 * @param buffer the data to write
941 * @param n number of bytes to write 946 * @param n number of bytes to write
942 * @return number of bytes written on success, GNUNET_SYSERR on error 947 * @return number of bytes written on success, #GNUNET_SYSERR on error
943 */ 948 */
944ssize_t 949ssize_t
945GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h, 950GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
946 const void *buffer, size_t n) 951 const void *buffer, size_t n)
947{ 952{
948 if (h == NULL) 953 if (NULL == h)
949 { 954 {
950 errno = EINVAL; 955 errno = EINVAL;
951 return GNUNET_SYSERR; 956 return GNUNET_SYSERR;
952 } 957 }
953 958
954#ifdef MINGW 959#ifdef MINGW
955 DWORD bytesWritten; 960 DWORD bytes_written;
956 961
957 if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE) 962 if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
958 { 963 {
959 if (!WriteFile (h->h, buffer, n, &bytesWritten, NULL)) 964 if (!WriteFile (h->h, buffer, n, &bytes_written, NULL))
960 { 965 {
961 SetErrnoFromWinError (GetLastError ()); 966 SetErrnoFromWinError (GetLastError ());
962 return GNUNET_SYSERR; 967 return GNUNET_SYSERR;
@@ -965,7 +970,7 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
965 else 970 else
966 { 971 {
967 LOG (GNUNET_ERROR_TYPE_DEBUG, "It is a pipe trying to write %u bytes\n", n); 972 LOG (GNUNET_ERROR_TYPE_DEBUG, "It is a pipe trying to write %u bytes\n", n);
968 if (!WriteFile (h->h, buffer, n, &bytesWritten, h->oOverlapWrite)) 973 if (!WriteFile (h->h, buffer, n, &bytes_written, h->oOverlapWrite))
969 { 974 {
970 if (GetLastError () != ERROR_IO_PENDING) 975 if (GetLastError () != ERROR_IO_PENDING)
971 { 976 {
@@ -975,7 +980,7 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
975 return GNUNET_SYSERR; 980 return GNUNET_SYSERR;
976 } 981 }
977 LOG (GNUNET_ERROR_TYPE_DEBUG, "Will get overlapped result\n"); 982 LOG (GNUNET_ERROR_TYPE_DEBUG, "Will get overlapped result\n");
978 if (!GetOverlappedResult (h->h, h->oOverlapWrite, &bytesWritten, TRUE)) 983 if (!GetOverlappedResult (h->h, h->oOverlapWrite, &bytes_written, TRUE))
979 { 984 {
980 SetErrnoFromWinError (GetLastError ()); 985 SetErrnoFromWinError (GetLastError ());
981 LOG (GNUNET_ERROR_TYPE_DEBUG, 986 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -997,21 +1002,21 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
997 { 1002 {
998 LOG (GNUNET_ERROR_TYPE_DEBUG, 1003 LOG (GNUNET_ERROR_TYPE_DEBUG,
999 "Wrote %u bytes (ovr says %u), picking the greatest\n", 1004 "Wrote %u bytes (ovr says %u), picking the greatest\n",
1000 bytesWritten, ovr); 1005 bytes_written, ovr);
1001 } 1006 }
1002 } 1007 }
1003 if (bytesWritten == 0) 1008 if (bytes_written == 0)
1004 { 1009 {
1005 if (n > 0) 1010 if (n > 0)
1006 { 1011 {
1007 LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes, returning -1 with EAGAIN\n", bytesWritten); 1012 LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes, returning -1 with EAGAIN\n", bytes_written);
1008 errno = EAGAIN; 1013 errno = EAGAIN;
1009 return GNUNET_SYSERR; 1014 return GNUNET_SYSERR;
1010 } 1015 }
1011 } 1016 }
1012 LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes\n", bytesWritten); 1017 LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes\n", bytes_written);
1013 } 1018 }
1014 return bytesWritten; 1019 return bytes_written;
1015#else 1020#else
1016 return write (h->fd, buffer, n); 1021 return write (h->fd, buffer, n);
1017#endif 1022#endif
@@ -1020,37 +1025,39 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
1020 1025
1021/** 1026/**
1022 * Write a buffer to a file, blocking, if necessary. 1027 * Write a buffer to a file, blocking, if necessary.
1028 *
1023 * @param h handle to open file 1029 * @param h handle to open file
1024 * @param buffer the data to write 1030 * @param buffer the data to write
1025 * @param n number of bytes to write 1031 * @param n number of bytes to write
1026 * @return number of bytes written on success, GNUNET_SYSERR on error 1032 * @return number of bytes written on success, #GNUNET_SYSERR on error
1027 */ 1033 */
1028ssize_t 1034ssize_t
1029GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h, 1035GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h,
1030 const void *buffer, size_t n) 1036 const void *buffer,
1037 size_t n)
1031{ 1038{
1032 if (h == NULL) 1039 if (NULL == h)
1033 { 1040 {
1034 errno = EINVAL; 1041 errno = EINVAL;
1035 return GNUNET_SYSERR; 1042 return GNUNET_SYSERR;
1036 } 1043 }
1037 1044
1038#ifdef MINGW 1045#ifdef MINGW
1039 DWORD bytesWritten; 1046 DWORD bytes_written;
1040 /* We do a non-overlapped write, which is as blocking as it gets */ 1047 /* We do a non-overlapped write, which is as blocking as it gets */
1041 LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing %u bytes\n", n); 1048 LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing %u bytes\n", n);
1042 if (!WriteFile (h->h, buffer, n, &bytesWritten, NULL)) 1049 if (!WriteFile (h->h, buffer, n, &bytes_written, NULL))
1043 { 1050 {
1044 SetErrnoFromWinError (GetLastError ()); 1051 SetErrnoFromWinError (GetLastError ());
1045 LOG (GNUNET_ERROR_TYPE_DEBUG, "Error writing to pipe: %u\n", 1052 LOG (GNUNET_ERROR_TYPE_DEBUG, "Error writing to pipe: %u\n",
1046 GetLastError ()); 1053 GetLastError ());
1047 return GNUNET_SYSERR; 1054 return GNUNET_SYSERR;
1048 } 1055 }
1049 if (bytesWritten == 0 && n > 0) 1056 if (bytes_written == 0 && n > 0)
1050 { 1057 {
1051 LOG (GNUNET_ERROR_TYPE_DEBUG, "Waiting for pipe to clean\n"); 1058 LOG (GNUNET_ERROR_TYPE_DEBUG, "Waiting for pipe to clean\n");
1052 WaitForSingleObject (h->h, INFINITE); 1059 WaitForSingleObject (h->h, INFINITE);
1053 if (!WriteFile (h->h, buffer, n, &bytesWritten, NULL)) 1060 if (!WriteFile (h->h, buffer, n, &bytes_written, NULL))
1054 { 1061 {
1055 SetErrnoFromWinError (GetLastError ()); 1062 SetErrnoFromWinError (GetLastError ());
1056 LOG (GNUNET_ERROR_TYPE_DEBUG, "Error writing to pipe: %u\n", 1063 LOG (GNUNET_ERROR_TYPE_DEBUG, "Error writing to pipe: %u\n",
@@ -1058,8 +1065,10 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h,
1058 return GNUNET_SYSERR; 1065 return GNUNET_SYSERR;
1059 } 1066 }
1060 } 1067 }
1061 LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes\n", bytesWritten); 1068 LOG (GNUNET_ERROR_TYPE_DEBUG,
1062 return bytesWritten; 1069 "Wrote %u bytes\n",
1070 bytes_written);
1071 return bytes_written;
1063#else 1072#else
1064 int flags; 1073 int flags;
1065 ssize_t ret; 1074 ssize_t ret;
@@ -1084,7 +1093,7 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h,
1084 * @param buffer the data to write 1093 * @param buffer the data to write
1085 * @param n number of bytes to write 1094 * @param n number of bytes to write
1086 * @param mode file permissions 1095 * @param mode file permissions
1087 * @return number of bytes written on success, GNUNET_SYSERR on error 1096 * @return number of bytes written on success, #GNUNET_SYSERR on error
1088 */ 1097 */
1089ssize_t 1098ssize_t
1090GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, 1099GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n,
@@ -1110,9 +1119,9 @@ GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n,
1110 * @param dir_name the name of the directory 1119 * @param dir_name the name of the directory
1111 * @param callback the method to call for each file, 1120 * @param callback the method to call for each file,
1112 * can be NULL, in that case, we only count 1121 * can be NULL, in that case, we only count
1113 * @param callback_cls closure for callback 1122 * @param callback_cls closure for @a callback
1114 * @return the number of files found, GNUNET_SYSERR on error or 1123 * @return the number of files found, #GNUNET_SYSERR on error or
1115 * ieration aborted by callback returning GNUNET_SYSERR 1124 * ieration aborted by callback returning #GNUNET_SYSERR
1116 */ 1125 */
1117int 1126int
1118GNUNET_DISK_directory_scan (const char *dir_name, 1127GNUNET_DISK_directory_scan (const char *dir_name,
@@ -1143,7 +1152,8 @@ GNUNET_DISK_directory_scan (const char *dir_name,
1143 } 1152 }
1144 if (!S_ISDIR (istat.st_mode)) 1153 if (!S_ISDIR (istat.st_mode))
1145 { 1154 {
1146 LOG (GNUNET_ERROR_TYPE_WARNING, _("Expected `%s' to be a directory!\n"), 1155 LOG (GNUNET_ERROR_TYPE_WARNING,
1156 _("Expected `%s' to be a directory!\n"),
1147 dir_name); 1157 dir_name);
1148 GNUNET_free (dname); 1158 GNUNET_free (dname);
1149 return GNUNET_SYSERR; 1159 return GNUNET_SYSERR;
@@ -1324,7 +1334,7 @@ GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
1324{ 1334{
1325 struct GNUNET_DISK_DirectoryIterator *di; 1335 struct GNUNET_DISK_DirectoryIterator *di;
1326 1336
1327 di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator)); 1337 di = GNUNET_new (struct GNUNET_DISK_DirectoryIterator);
1328 di->callback = callback; 1338 di->callback = callback;
1329 di->callback_cls = callback_cls; 1339 di->callback_cls = callback_cls;
1330 di->directory = OPENDIR (dir_name); 1340 di->directory = OPENDIR (dir_name);
@@ -1748,7 +1758,7 @@ GNUNET_DISK_file_open (const char *fn,
1748 } 1758 }
1749#endif 1759#endif
1750 1760
1751 ret = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 1761 ret = GNUNET_new (struct GNUNET_DISK_FileHandle);
1752#ifdef MINGW 1762#ifdef MINGW
1753 ret->h = h; 1763 ret->h = h;
1754 ret->type = GNUNET_DISK_HANLDE_TYPE_FILE; 1764 ret->type = GNUNET_DISK_HANLDE_TYPE_FILE;
@@ -1843,7 +1853,7 @@ GNUNET_DISK_get_handle_from_w32_handle (HANDLE osfh)
1843 return NULL; 1853 return NULL;
1844 } 1854 }
1845 1855
1846 fh = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 1856 fh = GNUNET_new (struct GNUNET_DISK_FileHandle);
1847 1857
1848 fh->h = osfh; 1858 fh->h = osfh;
1849 fh->type = ftype; 1859 fh->type = ftype;
@@ -1883,7 +1893,7 @@ GNUNET_DISK_get_handle_from_int_fd (int fno)
1883 return NULL; /* invalid FD */ 1893 return NULL; /* invalid FD */
1884 1894
1885#ifndef WINDOWS 1895#ifndef WINDOWS
1886 fh = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 1896 fh = GNUNET_new (struct GNUNET_DISK_FileHandle);
1887 1897
1888 fh->fd = fno; 1898 fh->fd = fno;
1889#else 1899#else
@@ -2064,7 +2074,7 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h,
2064 return NULL; 2074 return NULL;
2065 } 2075 }
2066 2076
2067 *m = GNUNET_malloc (sizeof (struct GNUNET_DISK_MapHandle)); 2077 *m = GNUNET_new (struct GNUNET_DISK_MapHandle);
2068 (*m)->h = CreateFileMapping (h->h, NULL, protect, 0, 0, NULL); 2078 (*m)->h = CreateFileMapping (h->h, NULL, protect, 0, 0, NULL);
2069 if ((*m)->h == INVALID_HANDLE_VALUE) 2079 if ((*m)->h == INVALID_HANDLE_VALUE)
2070 { 2080 {
@@ -2090,7 +2100,7 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h,
2090 prot = PROT_READ; 2100 prot = PROT_READ;
2091 if (access & GNUNET_DISK_MAP_TYPE_WRITE) 2101 if (access & GNUNET_DISK_MAP_TYPE_WRITE)
2092 prot |= PROT_WRITE; 2102 prot |= PROT_WRITE;
2093 *m = GNUNET_malloc (sizeof (struct GNUNET_DISK_MapHandle)); 2103 *m = GNUNET_new (struct GNUNET_DISK_MapHandle);
2094 (*m)->addr = mmap (NULL, len, prot, MAP_SHARED, h->fd, 0); 2104 (*m)->addr = mmap (NULL, len, prot, MAP_SHARED, h->fd, 0);
2095 GNUNET_assert (NULL != (*m)->addr); 2105 GNUNET_assert (NULL != (*m)->addr);
2096 if (MAP_FAILED == (*m)->addr) 2106 if (MAP_FAILED == (*m)->addr)
@@ -2322,9 +2332,9 @@ GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, int i
2322 HANDLE tmp_handle; 2332 HANDLE tmp_handle;
2323 int save_errno; 2333 int save_errno;
2324 2334
2325 p = GNUNET_malloc (sizeof (struct GNUNET_DISK_PipeHandle)); 2335 p = GNUNET_new (struct GNUNET_DISK_PipeHandle);
2326 p->fd[0] = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 2336 p->fd[0] = GNUNET_new (struct GNUNET_DISK_FileHandle);
2327 p->fd[1] = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 2337 p->fd[1] = GNUNET_new (struct GNUNET_DISK_FileHandle);
2328 2338
2329 /* All pipes are overlapped. If you want them to block - just 2339 /* All pipes are overlapped. If you want them to block - just
2330 * call WriteFile() and ReadFile() with NULL overlapped pointer. 2340 * call WriteFile() and ReadFile() with NULL overlapped pointer.
@@ -2417,7 +2427,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
2417{ 2427{
2418 struct GNUNET_DISK_PipeHandle *p; 2428 struct GNUNET_DISK_PipeHandle *p;
2419 2429
2420 p = GNUNET_malloc (sizeof (struct GNUNET_DISK_PipeHandle)); 2430 p = GNUNET_new (struct GNUNET_DISK_PipeHandle);
2421 2431
2422#ifndef MINGW 2432#ifndef MINGW
2423 int ret; 2433 int ret;
@@ -2427,7 +2437,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
2427 ret = 0; 2437 ret = 0;
2428 if (fd[0] >= 0) 2438 if (fd[0] >= 0)
2429 { 2439 {
2430 p->fd[0] = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 2440 p->fd[0] = GNUNET_new (struct GNUNET_DISK_FileHandle);
2431 p->fd[0]->fd = fd[0]; 2441 p->fd[0]->fd = fd[0];
2432 if (!blocking_read) 2442 if (!blocking_read)
2433 { 2443 {
@@ -2450,7 +2460,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
2450 2460
2451 if (fd[1] >= 0) 2461 if (fd[1] >= 0)
2452 { 2462 {
2453 p->fd[1] = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 2463 p->fd[1] = GNUNET_new (struct GNUNET_DISK_FileHandle);
2454 p->fd[1]->fd = fd[1]; 2464 p->fd[1]->fd = fd[1];
2455 if (!blocking_write) 2465 if (!blocking_write)
2456 { 2466 {
@@ -2487,7 +2497,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
2487#else 2497#else
2488 if (fd[0] >= 0) 2498 if (fd[0] >= 0)
2489 { 2499 {
2490 p->fd[0] = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 2500 p->fd[0] = GNUNET_new (struct GNUNET_DISK_FileHandle);
2491 p->fd[0]->h = (HANDLE) _get_osfhandle (fd[0]); 2501 p->fd[0]->h = (HANDLE) _get_osfhandle (fd[0]);
2492 if (p->fd[0]->h != INVALID_HANDLE_VALUE) 2502 if (p->fd[0]->h != INVALID_HANDLE_VALUE)
2493 { 2503 {
@@ -2505,7 +2515,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
2505 } 2515 }
2506 if (fd[1] >= 0) 2516 if (fd[1] >= 0)
2507 { 2517 {
2508 p->fd[1] = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle)); 2518 p->fd[1] = GNUNET_new (struct GNUNET_DISK_FileHandle);
2509 p->fd[1]->h = (HANDLE) _get_osfhandle (fd[1]); 2519 p->fd[1]->h = (HANDLE) _get_osfhandle (fd[1]);
2510 if (p->fd[1]->h != INVALID_HANDLE_VALUE) 2520 if (p->fd[1]->h != INVALID_HANDLE_VALUE)
2511 { 2521 {