diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-19 10:48:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-19 10:48:51 +0000 |
commit | b3e1d0806fb274c62a5acf19c56369b71f992312 (patch) | |
tree | 657a7cd7a327aad0e7598b3d28cecc0d5cd95cd4 | |
parent | 0385dc1043912d3ddc5d57f6b7346054a30f64ef (diff) | |
download | gnunet-b3e1d0806fb274c62a5acf19c56369b71f992312.tar.gz gnunet-b3e1d0806fb274c62a5acf19c56369b71f992312.zip |
-LRN: calculate file size for single files when needed and use GNUNET_DISK_file_size instead of STAT
-rw-r--r-- | src/fs/fs_download.c | 4 | ||||
-rw-r--r-- | src/fs/fs_file_information.c | 10 | ||||
-rw-r--r-- | src/fs/fs_unindex.c | 2 | ||||
-rw-r--r-- | src/fs/gnunet-directory.c | 2 | ||||
-rw-r--r-- | src/fs/gnunet-helper-fs-publish.c | 10 | ||||
-rw-r--r-- | src/fs/test_fs_download.c | 2 | ||||
-rw-r--r-- | src/fs/test_fs_download_indexed.c | 2 | ||||
-rw-r--r-- | src/fs/test_fs_download_persistence.c | 2 | ||||
-rw-r--r-- | src/hello/gnunet-hello.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_disk_lib.h | 10 | ||||
-rw-r--r-- | src/statistics/gnunet-service-statistics.c | 11 | ||||
-rw-r--r-- | src/testing/gnunet-testing.c | 2 | ||||
-rw-r--r-- | src/testing/testing_group.c | 2 | ||||
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 21 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_blacklist.c | 29 | ||||
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 11 | ||||
-rw-r--r-- | src/transport/transport-testing.c | 2 | ||||
-rw-r--r-- | src/util/crypto_hash.c | 2 | ||||
-rw-r--r-- | src/util/crypto_rsa.c | 2 | ||||
-rw-r--r-- | src/util/disk.c | 17 | ||||
-rw-r--r-- | src/util/pseudonym.c | 4 | ||||
-rw-r--r-- | src/util/test_disk.c | 2 |
22 files changed, 89 insertions, 62 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 0596d85e3..490beef5e 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -2068,7 +2068,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, | |||
2068 | { | 2068 | { |
2069 | dc->filename = GNUNET_strdup (filename); | 2069 | dc->filename = GNUNET_strdup (filename); |
2070 | if (GNUNET_YES == GNUNET_DISK_file_test (filename)) | 2070 | if (GNUNET_YES == GNUNET_DISK_file_test (filename)) |
2071 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES)); | 2071 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES, GNUNET_YES)); |
2072 | } | 2072 | } |
2073 | if (GNUNET_FS_uri_test_loc (dc->uri)) | 2073 | if (GNUNET_FS_uri_test_loc (dc->uri)) |
2074 | GNUNET_assert (GNUNET_OK == | 2074 | GNUNET_assert (GNUNET_OK == |
@@ -2178,7 +2178,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, | |||
2178 | { | 2178 | { |
2179 | dc->filename = GNUNET_strdup (filename); | 2179 | dc->filename = GNUNET_strdup (filename); |
2180 | if (GNUNET_YES == GNUNET_DISK_file_test (filename)) | 2180 | if (GNUNET_YES == GNUNET_DISK_file_test (filename)) |
2181 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES)); | 2181 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES, GNUNET_YES)); |
2182 | } | 2182 | } |
2183 | if (GNUNET_FS_uri_test_loc (dc->uri)) | 2183 | if (GNUNET_FS_uri_test_loc (dc->uri)) |
2184 | GNUNET_assert (GNUNET_OK == | 2184 | GNUNET_assert (GNUNET_OK == |
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index 85a076fee..806592784 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c | |||
@@ -107,7 +107,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
107 | *bo) | 107 | *bo) |
108 | { | 108 | { |
109 | struct FileInfo *fi; | 109 | struct FileInfo *fi; |
110 | struct stat sbuf; | 110 | uint64_t fsize; |
111 | struct GNUNET_FS_FileInformation *ret; | 111 | struct GNUNET_FS_FileInformation *ret; |
112 | const char *fn; | 112 | const char *fn; |
113 | const char *ss; | 113 | const char *ss; |
@@ -116,7 +116,8 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
116 | char fn_conv[MAX_PATH]; | 116 | char fn_conv[MAX_PATH]; |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | if (0 != STAT (filename, &sbuf)) | 119 | /* FIXME: should includeSymLinks be GNUNET_NO or GNUNET_YES here? */ |
120 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES)) | ||
120 | { | 121 | { |
121 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename); | 122 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename); |
122 | return NULL; | 123 | return NULL; |
@@ -129,7 +130,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
129 | } | 130 | } |
130 | ret = | 131 | ret = |
131 | GNUNET_FS_file_information_create_from_reader (h, client_info, | 132 | GNUNET_FS_file_information_create_from_reader (h, client_info, |
132 | sbuf.st_size, | 133 | fsize, |
133 | &GNUNET_FS_data_reader_file_, | 134 | &GNUNET_FS_data_reader_file_, |
134 | fi, keywords, meta, | 135 | fi, keywords, meta, |
135 | do_index, bo); | 136 | do_index, bo); |
@@ -145,6 +146,9 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
145 | #endif | 146 | #endif |
146 | while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) | 147 | while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) |
147 | fn = ss + 1; | 148 | fn = ss + 1; |
149 | /* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then | ||
150 | * this should be changed to EXTRACTOR_METAFORMAT_UTF8 | ||
151 | */ | ||
148 | #if !WINDOWS | 152 | #if !WINDOWS |
149 | GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>", | 153 | GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>", |
150 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 154 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 3c2ef8f6f..bf619b75a 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -755,7 +755,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename, | |||
755 | struct GNUNET_FS_ProgressInfo pi; | 755 | struct GNUNET_FS_ProgressInfo pi; |
756 | uint64_t size; | 756 | uint64_t size; |
757 | 757 | ||
758 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES)) | 758 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES)) |
759 | return NULL; | 759 | return NULL; |
760 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext)); | 760 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext)); |
761 | ret->h = h; | 761 | ret->h = h; |
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c index 0721ea90e..c722f57ff 100644 --- a/src/fs/gnunet-directory.c +++ b/src/fs/gnunet-directory.c | |||
@@ -136,7 +136,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
136 | i = 0; | 136 | i = 0; |
137 | while (NULL != (filename = args[i++])) | 137 | while (NULL != (filename = args[i++])) |
138 | { | 138 | { |
139 | if ((GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES)) || | 139 | if ((GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES)) || |
140 | (NULL == | 140 | (NULL == |
141 | (h = | 141 | (h = |
142 | GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, | 142 | GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, |
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index 4f7046408..4bb77fa22 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c | |||
@@ -69,7 +69,8 @@ struct ScanTreeNode | |||
69 | char *filename; | 69 | char *filename; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Size of the file (if it is a file), in bytes | 72 | * Size of the file (if it is a file), in bytes. |
73 | * At the moment it is set to 0 for directories. | ||
73 | */ | 74 | */ |
74 | uint64_t file_size; | 75 | uint64_t file_size; |
75 | 76 | ||
@@ -275,8 +276,11 @@ preprocess_file (const char *filename, | |||
275 | { | 276 | { |
276 | struct ScanTreeNode *item; | 277 | struct ScanTreeNode *item; |
277 | struct stat sbuf; | 278 | struct stat sbuf; |
279 | uint64_t fsize = 0; | ||
278 | 280 | ||
279 | if (0 != STAT (filename, &sbuf)) | 281 | if ((0 != STAT (filename, &sbuf)) || |
282 | ((!S_ISDIR (sbuf.st_mode)) && (GNUNET_OK != GNUNET_DISK_file_size ( | ||
283 | filename, &fsize, GNUNET_NO, GNUNET_YES)))) | ||
280 | { | 284 | { |
281 | /* If the file doesn't exist (or is not stat-able for any other reason) | 285 | /* If the file doesn't exist (or is not stat-able for any other reason) |
282 | skip it (but report it), but do continue. */ | 286 | skip it (but report it), but do continue. */ |
@@ -297,7 +301,7 @@ preprocess_file (const char *filename, | |||
297 | item = GNUNET_malloc (sizeof (struct ScanTreeNode)); | 301 | item = GNUNET_malloc (sizeof (struct ScanTreeNode)); |
298 | item->filename = GNUNET_strdup (filename); | 302 | item->filename = GNUNET_strdup (filename); |
299 | item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; | 303 | item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; |
300 | item->file_size = (uint64_t) sbuf.st_size; | 304 | item->file_size = fsize; |
301 | if (item->is_directory == GNUNET_YES) | 305 | if (item->is_directory == GNUNET_YES) |
302 | { | 306 | { |
303 | struct RecursionContext rc; | 307 | struct RecursionContext rc; |
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 570eab909..198a8154e 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c | |||
@@ -118,7 +118,7 @@ abort_download_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
118 | GNUNET_FS_download_stop (download, GNUNET_YES); | 118 | GNUNET_FS_download_stop (download, GNUNET_YES); |
119 | download = NULL; | 119 | download = NULL; |
120 | } | 120 | } |
121 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES)); | 121 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES, GNUNET_NO)); |
122 | GNUNET_assert (size == FILESIZE); | 122 | GNUNET_assert (size == FILESIZE); |
123 | GNUNET_DISK_directory_remove (fn); | 123 | GNUNET_DISK_directory_remove (fn); |
124 | GNUNET_free (fn); | 124 | GNUNET_free (fn); |
diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c index e8504f175..c00b9e717 100644 --- a/src/fs/test_fs_download_indexed.c +++ b/src/fs/test_fs_download_indexed.c | |||
@@ -119,7 +119,7 @@ abort_download_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
119 | GNUNET_FS_download_stop (download, GNUNET_YES); | 119 | GNUNET_FS_download_stop (download, GNUNET_YES); |
120 | download = NULL; | 120 | download = NULL; |
121 | } | 121 | } |
122 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES)); | 122 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES, GNUNET_NO)); |
123 | GNUNET_assert (size == FILESIZE); | 123 | GNUNET_assert (size == FILESIZE); |
124 | GNUNET_DISK_directory_remove (fn); | 124 | GNUNET_DISK_directory_remove (fn); |
125 | GNUNET_free (fn); | 125 | GNUNET_free (fn); |
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index bcb1c54b6..3a6d9553e 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c | |||
@@ -113,7 +113,7 @@ abort_download_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
113 | GNUNET_FS_download_stop (download, GNUNET_YES); | 113 | GNUNET_FS_download_stop (download, GNUNET_YES); |
114 | download = NULL; | 114 | download = NULL; |
115 | } | 115 | } |
116 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES)); | 116 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES, GNUNET_NO)); |
117 | GNUNET_assert (size == FILESIZE); | 117 | GNUNET_assert (size == FILESIZE); |
118 | GNUNET_DISK_directory_remove (fn); | 118 | GNUNET_DISK_directory_remove (fn); |
119 | GNUNET_free (fn); | 119 | GNUNET_free (fn); |
diff --git a/src/hello/gnunet-hello.c b/src/hello/gnunet-hello.c index d64833b42..cbbdce3da 100644 --- a/src/hello/gnunet-hello.c +++ b/src/hello/gnunet-hello.c | |||
@@ -122,7 +122,7 @@ main (int argc, char *argv[]) | |||
122 | _("Call with name of HELLO file to modify.\n")); | 122 | _("Call with name of HELLO file to modify.\n")); |
123 | return 1; | 123 | return 1; |
124 | } | 124 | } |
125 | if (GNUNET_OK != GNUNET_DISK_file_size (argv[1], &fsize, GNUNET_YES)) | 125 | if (GNUNET_OK != GNUNET_DISK_file_size (argv[1], &fsize, GNUNET_YES, GNUNET_YES)) |
126 | { | 126 | { |
127 | FPRINTF (stderr, | 127 | FPRINTF (stderr, |
128 | _("Error accessing file `%s': %s\n"), | 128 | _("Error accessing file `%s': %s\n"), |
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 18f553576..d6ec0fe80 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -302,8 +302,8 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, OFF_T offset, | |||
302 | 302 | ||
303 | 303 | ||
304 | /** | 304 | /** |
305 | * Get the size of the file (or directory) | 305 | * Get the size of the file (or directory) of the given file (in |
306 | * of the given file (in bytes). | 306 | * bytes). |
307 | * | 307 | * |
308 | * @param filename name of the file or directory | 308 | * @param filename name of the file or directory |
309 | * @param size set to the size of the file (or, | 309 | * @param size set to the size of the file (or, |
@@ -311,11 +311,13 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, OFF_T offset, | |||
311 | * of all sizes of files in the directory) | 311 | * of all sizes of files in the directory) |
312 | * @param includeSymLinks should symbolic links be | 312 | * @param includeSymLinks should symbolic links be |
313 | * included? | 313 | * included? |
314 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 314 | * @param singleFileMode GNUNET_YES to only get size of one file |
315 | * and return GNUNET_SYSERR for directories. | ||
316 | * @return GNUNET_SYSERR on error, GNUNET_OK on success | ||
315 | */ | 317 | */ |
316 | int | 318 | int |
317 | GNUNET_DISK_file_size (const char *filename, uint64_t * size, | 319 | GNUNET_DISK_file_size (const char *filename, uint64_t * size, |
318 | int includeSymLinks); | 320 | int includeSymLinks, int singleFileMode); |
319 | 321 | ||
320 | 322 | ||
321 | /** | 323 | /** |
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 58ef763e3..1ec07ad5d 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -224,6 +224,7 @@ load (struct GNUNET_SERVER_Handle *server) | |||
224 | char *fn; | 224 | char *fn; |
225 | struct GNUNET_BIO_ReadHandle *rh; | 225 | struct GNUNET_BIO_ReadHandle *rh; |
226 | struct stat sb; | 226 | struct stat sb; |
227 | uint64_t fsize; | ||
227 | char *buf; | 228 | char *buf; |
228 | struct GNUNET_SERVER_MessageStreamTokenizer *mst; | 229 | struct GNUNET_SERVER_MessageStreamTokenizer *mst; |
229 | char *emsg; | 230 | char *emsg; |
@@ -232,12 +233,12 @@ load (struct GNUNET_SERVER_Handle *server) | |||
232 | NULL); | 233 | NULL); |
233 | if (fn == NULL) | 234 | if (fn == NULL) |
234 | return; | 235 | return; |
235 | if ((0 != stat (fn, &sb)) || (sb.st_size == 0)) | 236 | if ((GNUNET_OK != GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) || (fsize == 0)) |
236 | { | 237 | { |
237 | GNUNET_free (fn); | 238 | GNUNET_free (fn); |
238 | return; | 239 | return; |
239 | } | 240 | } |
240 | buf = GNUNET_malloc (sb.st_size); | 241 | buf = GNUNET_malloc (fsize); |
241 | rh = GNUNET_BIO_read_open (fn); | 242 | rh = GNUNET_BIO_read_open (fn); |
242 | if (!rh) | 243 | if (!rh) |
243 | { | 244 | { |
@@ -245,7 +246,7 @@ load (struct GNUNET_SERVER_Handle *server) | |||
245 | GNUNET_free (fn); | 246 | GNUNET_free (fn); |
246 | return; | 247 | return; |
247 | } | 248 | } |
248 | if (GNUNET_OK != GNUNET_BIO_read (rh, fn, buf, sb.st_size)) | 249 | if (GNUNET_OK != GNUNET_BIO_read (rh, fn, buf, fsize)) |
249 | { | 250 | { |
250 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", fn); | 251 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", fn); |
251 | GNUNET_break (GNUNET_OK == GNUNET_BIO_read_close (rh, &emsg)); | 252 | GNUNET_break (GNUNET_OK == GNUNET_BIO_read_close (rh, &emsg)); |
@@ -256,10 +257,10 @@ load (struct GNUNET_SERVER_Handle *server) | |||
256 | } | 257 | } |
257 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 258 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
258 | _("Loading %llu bytes of statistics from `%s'\n"), | 259 | _("Loading %llu bytes of statistics from `%s'\n"), |
259 | (unsigned long long) sb.st_size, fn); | 260 | fsize, fn); |
260 | mst = GNUNET_SERVER_mst_create (&inject_message, server); | 261 | mst = GNUNET_SERVER_mst_create (&inject_message, server); |
261 | GNUNET_break (GNUNET_OK == | 262 | GNUNET_break (GNUNET_OK == |
262 | GNUNET_SERVER_mst_receive (mst, NULL, buf, sb.st_size, | 263 | GNUNET_SERVER_mst_receive (mst, NULL, buf, fsize, |
263 | GNUNET_YES, GNUNET_NO)); | 264 | GNUNET_YES, GNUNET_NO)); |
264 | GNUNET_SERVER_mst_destroy (mst); | 265 | GNUNET_SERVER_mst_destroy (mst); |
265 | GNUNET_free (buf); | 266 | GNUNET_free (buf); |
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index 0caa28e25..bdbb5e8c5 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c | |||
@@ -170,7 +170,7 @@ create_hostkeys (const unsigned int no) | |||
170 | return 1; | 170 | return 1; |
171 | } | 171 | } |
172 | 172 | ||
173 | if (GNUNET_YES != GNUNET_DISK_file_size (hostkey_src_file, &fs, GNUNET_YES)) | 173 | if (GNUNET_OK != GNUNET_DISK_file_size (hostkey_src_file, &fs, GNUNET_YES, GNUNET_YES)) |
174 | fs = 0; | 174 | fs = 0; |
175 | 175 | ||
176 | if (0 != (fs % HOSTKEYFILESIZE)) | 176 | if (0 != (fs % HOSTKEYFILESIZE)) |
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index e8db98a91..49c0c1a33 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -6078,7 +6078,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
6078 | return NULL; | 6078 | return NULL; |
6079 | } | 6079 | } |
6080 | 6080 | ||
6081 | if (GNUNET_YES != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES)) | 6081 | if (GNUNET_OK != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES, GNUNET_YES)) |
6082 | fs = 0; | 6082 | fs = 0; |
6083 | #if DEBUG_TESTING | 6083 | #if DEBUG_TESTING |
6084 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 6084 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 38a648afc..4e332496c 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -970,7 +970,7 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
970 | char *data; | 970 | char *data; |
971 | size_t pos; | 971 | size_t pos; |
972 | struct GNUNET_PeerIdentity pid; | 972 | struct GNUNET_PeerIdentity pid; |
973 | struct stat frstat; | 973 | uint64_t fsize; |
974 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | 974 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; |
975 | unsigned int entries_found; | 975 | unsigned int entries_found; |
976 | struct Peer *fl; | 976 | struct Peer *fl; |
@@ -987,7 +987,8 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
987 | GNUNET_DISK_fn_write (fn, NULL, 0, | 987 | GNUNET_DISK_fn_write (fn, NULL, 0, |
988 | GNUNET_DISK_PERM_USER_READ | | 988 | GNUNET_DISK_PERM_USER_READ | |
989 | GNUNET_DISK_PERM_USER_WRITE); | 989 | GNUNET_DISK_PERM_USER_WRITE); |
990 | if (0 != STAT (fn, &frstat)) | 990 | if (GNUNET_OK != GNUNET_DISK_file_size (fn, |
991 | &fsize, GNUNET_NO, GNUNET_YES)) | ||
991 | { | 992 | { |
992 | if ((friends_only) || (minimum_friend_count > 0)) | 993 | if ((friends_only) || (minimum_friend_count > 0)) |
993 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 994 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -995,14 +996,14 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
995 | GNUNET_free (fn); | 996 | GNUNET_free (fn); |
996 | return; | 997 | return; |
997 | } | 998 | } |
998 | if (frstat.st_size == 0) | 999 | if (fsize == 0) |
999 | { | 1000 | { |
1000 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Friends file `%s' is empty.\n"), | 1001 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Friends file `%s' is empty.\n"), |
1001 | fn); | 1002 | fn); |
1002 | GNUNET_free (fn); | 1003 | GNUNET_free (fn); |
1003 | return; | 1004 | return; |
1004 | } | 1005 | } |
1005 | data = GNUNET_malloc_large (frstat.st_size); | 1006 | data = GNUNET_malloc_large (fsize); |
1006 | if (data == NULL) | 1007 | if (data == NULL) |
1007 | { | 1008 | { |
1008 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1009 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1011,7 +1012,7 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1011 | GNUNET_free (fn); | 1012 | GNUNET_free (fn); |
1012 | return; | 1013 | return; |
1013 | } | 1014 | } |
1014 | if (frstat.st_size != GNUNET_DISK_fn_read (fn, data, frstat.st_size)) | 1015 | if (fsize != GNUNET_DISK_fn_read (fn, data, fsize)) |
1015 | { | 1016 | { |
1016 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1017 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1017 | _("Failed to read friends list from `%s'\n"), fn); | 1018 | _("Failed to read friends list from `%s'\n"), fn); |
@@ -1021,11 +1022,11 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1021 | } | 1022 | } |
1022 | entries_found = 0; | 1023 | entries_found = 0; |
1023 | pos = 0; | 1024 | pos = 0; |
1024 | while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) | 1025 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) |
1025 | pos++; | 1026 | pos++; |
1026 | while ((frstat.st_size >= sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) && | 1027 | while ((fsize >= sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) && |
1027 | (pos <= | 1028 | (pos <= |
1028 | frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) | 1029 | fsize - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) |
1029 | { | 1030 | { |
1030 | memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 1031 | memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); |
1031 | if (!isspace | 1032 | if (!isspace |
@@ -1037,7 +1038,7 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1037 | ("Syntax error in topology specification at offset %llu, skipping bytes.\n"), | 1038 | ("Syntax error in topology specification at offset %llu, skipping bytes.\n"), |
1038 | (unsigned long long) pos); | 1039 | (unsigned long long) pos); |
1039 | pos++; | 1040 | pos++; |
1040 | while ((pos < frstat.st_size) && (!isspace ((unsigned char) data[pos]))) | 1041 | while ((pos < fsize) && (!isspace ((unsigned char) data[pos]))) |
1041 | pos++; | 1042 | pos++; |
1042 | continue; | 1043 | continue; |
1043 | } | 1044 | } |
@@ -1068,7 +1069,7 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1068 | } | 1069 | } |
1069 | } | 1070 | } |
1070 | pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); | 1071 | pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); |
1071 | while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) | 1072 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) |
1072 | pos++; | 1073 | pos++; |
1073 | } | 1074 | } |
1074 | GNUNET_free (data); | 1075 | GNUNET_free (data); |
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 2089949f7..10362681c 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -221,7 +221,7 @@ read_blacklist_file () | |||
221 | size_t colon_pos; | 221 | size_t colon_pos; |
222 | int tsize; | 222 | int tsize; |
223 | struct GNUNET_PeerIdentity pid; | 223 | struct GNUNET_PeerIdentity pid; |
224 | struct stat frstat; | 224 | uint64_t fsize; |
225 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | 225 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; |
226 | unsigned int entries_found; | 226 | unsigned int entries_found; |
227 | char *transport_name; | 227 | char *transport_name; |
@@ -241,14 +241,15 @@ read_blacklist_file () | |||
241 | GNUNET_DISK_fn_write (fn, NULL, 0, | 241 | GNUNET_DISK_fn_write (fn, NULL, 0, |
242 | GNUNET_DISK_PERM_USER_READ | | 242 | GNUNET_DISK_PERM_USER_READ | |
243 | GNUNET_DISK_PERM_USER_WRITE); | 243 | GNUNET_DISK_PERM_USER_WRITE); |
244 | if (0 != STAT (fn, &frstat)) | 244 | if (GNUNET_OK != GNUNET_DISK_file_size (fn, |
245 | &fsize, GNUNET_NO, GNUNET_YES)) | ||
245 | { | 246 | { |
246 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 247 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
247 | _("Could not read blacklist file `%s'\n"), fn); | 248 | _("Could not read blacklist file `%s'\n"), fn); |
248 | GNUNET_free (fn); | 249 | GNUNET_free (fn); |
249 | return; | 250 | return; |
250 | } | 251 | } |
251 | if (frstat.st_size == 0) | 252 | if (fsize == 0) |
252 | { | 253 | { |
253 | #if DEBUG_TRANSPORT | 254 | #if DEBUG_TRANSPORT |
254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"), | 255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"), |
@@ -258,9 +259,9 @@ read_blacklist_file () | |||
258 | return; | 259 | return; |
259 | } | 260 | } |
260 | /* FIXME: use mmap */ | 261 | /* FIXME: use mmap */ |
261 | data = GNUNET_malloc_large (frstat.st_size); | 262 | data = GNUNET_malloc_large (fsize); |
262 | GNUNET_assert (data != NULL); | 263 | GNUNET_assert (data != NULL); |
263 | if (frstat.st_size != GNUNET_DISK_fn_read (fn, data, frstat.st_size)) | 264 | if (fsize != GNUNET_DISK_fn_read (fn, data, fsize)) |
264 | { | 265 | { |
265 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 266 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
266 | _("Failed to read blacklist from `%s'\n"), fn); | 267 | _("Failed to read blacklist from `%s'\n"), fn); |
@@ -270,17 +271,17 @@ read_blacklist_file () | |||
270 | } | 271 | } |
271 | entries_found = 0; | 272 | entries_found = 0; |
272 | pos = 0; | 273 | pos = 0; |
273 | while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) | 274 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) |
274 | pos++; | 275 | pos++; |
275 | while ((frstat.st_size >= sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) && | 276 | while ((fsize >= sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) && |
276 | (pos <= | 277 | (pos <= |
277 | frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) | 278 | fsize - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) |
278 | { | 279 | { |
279 | colon_pos = pos; | 280 | colon_pos = pos; |
280 | while ((colon_pos < frstat.st_size) && (data[colon_pos] != ':') && | 281 | while ((colon_pos < fsize) && (data[colon_pos] != ':') && |
281 | (!isspace ((unsigned char) data[colon_pos]))) | 282 | (!isspace ((unsigned char) data[colon_pos]))) |
282 | colon_pos++; | 283 | colon_pos++; |
283 | if (colon_pos >= frstat.st_size) | 284 | if (colon_pos >= fsize) |
284 | { | 285 | { |
285 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 286 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
286 | _ | 287 | _ |
@@ -298,12 +299,12 @@ read_blacklist_file () | |||
298 | ("Syntax error in blacklist file at offset %llu, skipping bytes.\n"), | 299 | ("Syntax error in blacklist file at offset %llu, skipping bytes.\n"), |
299 | (unsigned long long) colon_pos); | 300 | (unsigned long long) colon_pos); |
300 | pos = colon_pos; | 301 | pos = colon_pos; |
301 | while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) | 302 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) |
302 | pos++; | 303 | pos++; |
303 | continue; | 304 | continue; |
304 | } | 305 | } |
305 | tsize = colon_pos - pos; | 306 | tsize = colon_pos - pos; |
306 | if ((pos >= frstat.st_size) || (pos + tsize >= frstat.st_size) || | 307 | if ((pos >= fsize) || (pos + tsize >= fsize) || |
307 | (tsize == 0)) | 308 | (tsize == 0)) |
308 | { | 309 | { |
309 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 310 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -336,7 +337,7 @@ read_blacklist_file () | |||
336 | ("Syntax error in blacklist file at offset %llu, skipping bytes.\n"), | 337 | ("Syntax error in blacklist file at offset %llu, skipping bytes.\n"), |
337 | (unsigned long long) pos); | 338 | (unsigned long long) pos); |
338 | pos++; | 339 | pos++; |
339 | while ((pos < frstat.st_size) && (!isspace ((unsigned char) data[pos]))) | 340 | while ((pos < fsize) && (!isspace ((unsigned char) data[pos]))) |
340 | pos++; | 341 | pos++; |
341 | GNUNET_free_non_null (transport_name); | 342 | GNUNET_free_non_null (transport_name); |
342 | continue; | 343 | continue; |
@@ -367,7 +368,7 @@ read_blacklist_file () | |||
367 | } | 368 | } |
368 | pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); | 369 | pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); |
369 | GNUNET_free_non_null (transport_name); | 370 | GNUNET_free_non_null (transport_name); |
370 | while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) | 371 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) |
371 | pos++; | 372 | pos++; |
372 | } | 373 | } |
373 | GNUNET_STATISTICS_update (GST_stats, "# Transport entries blacklisted", | 374 | GNUNET_STATISTICS_update (GST_stats, "# Transport entries blacklisted", |
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 8ec5a5e43..68b6a2a4f 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -95,12 +95,13 @@ static char * | |||
95 | server_load_file (const char *file) | 95 | server_load_file (const char *file) |
96 | { | 96 | { |
97 | struct GNUNET_DISK_FileHandle *gn_file; | 97 | struct GNUNET_DISK_FileHandle *gn_file; |
98 | struct stat fstat; | 98 | uint64_t fsize; |
99 | char *text = NULL; | 99 | char *text = NULL; |
100 | 100 | ||
101 | if (0 != STAT (file, &fstat)) | 101 | if (GNUNET_OK != GNUNET_DISK_file_size (file, |
102 | &fsize, GNUNET_NO, GNUNET_YES)) | ||
102 | return NULL; | 103 | return NULL; |
103 | text = GNUNET_malloc (fstat.st_size + 1); | 104 | text = GNUNET_malloc (fsize + 1); |
104 | gn_file = | 105 | gn_file = |
105 | GNUNET_DISK_file_open (file, GNUNET_DISK_OPEN_READ, | 106 | GNUNET_DISK_file_open (file, GNUNET_DISK_OPEN_READ, |
106 | GNUNET_DISK_PERM_USER_READ); | 107 | GNUNET_DISK_PERM_USER_READ); |
@@ -109,13 +110,13 @@ server_load_file (const char *file) | |||
109 | GNUNET_free (text); | 110 | GNUNET_free (text); |
110 | return NULL; | 111 | return NULL; |
111 | } | 112 | } |
112 | if (GNUNET_SYSERR == GNUNET_DISK_file_read (gn_file, text, fstat.st_size)) | 113 | if (GNUNET_SYSERR == GNUNET_DISK_file_read (gn_file, text, fsize)) |
113 | { | 114 | { |
114 | GNUNET_free (text); | 115 | GNUNET_free (text); |
115 | GNUNET_DISK_file_close (gn_file); | 116 | GNUNET_DISK_file_close (gn_file); |
116 | return NULL; | 117 | return NULL; |
117 | } | 118 | } |
118 | text[fstat.st_size] = '\0'; | 119 | text[fsize] = '\0'; |
119 | GNUNET_DISK_file_close (gn_file); | 120 | GNUNET_DISK_file_close (gn_file); |
120 | return text; | 121 | return text; |
121 | } | 122 | } |
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 752106bfe..fd5cc4701 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -661,7 +661,7 @@ GNUNET_TRANSPORT_TESTING_init () | |||
661 | return NULL; | 661 | return NULL; |
662 | } | 662 | } |
663 | 663 | ||
664 | if (GNUNET_YES != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES)) | 664 | if (GNUNET_OK != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES, GNUNET_YES)) |
665 | fs = 0; | 665 | fs = 0; |
666 | 666 | ||
667 | if (0 != (fs % HOSTKEYFILESIZE)) | 667 | if (0 != (fs % HOSTKEYFILESIZE)) |
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index aaf5175d7..57e37f3fd 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -220,7 +220,7 @@ GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | |||
220 | return NULL; | 220 | return NULL; |
221 | } | 221 | } |
222 | fhc->bsize = blocksize; | 222 | fhc->bsize = blocksize; |
223 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fhc->fsize, GNUNET_NO)) | 223 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fhc->fsize, GNUNET_NO, GNUNET_YES)) |
224 | { | 224 | { |
225 | GNUNET_free (fhc->filename); | 225 | GNUNET_free (fhc->filename); |
226 | GNUNET_free (fhc); | 226 | GNUNET_free (fhc); |
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index ee7e5e9f8..0106f43be 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -726,7 +726,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
726 | 726 | ||
727 | return NULL; | 727 | return NULL; |
728 | } | 728 | } |
729 | if (GNUNET_YES != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES)) | 729 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) |
730 | fs = 0; | 730 | fs = 0; |
731 | if (fs < sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded)) | 731 | if (fs < sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded)) |
732 | { | 732 | { |
diff --git a/src/util/disk.c b/src/util/disk.c index b6b458f15..ae3ac4c41 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -112,6 +112,11 @@ struct GetFileSizeData | |||
112 | * GNUNET_YES if symbolic links should be included. | 112 | * GNUNET_YES if symbolic links should be included. |
113 | */ | 113 | */ |
114 | int include_sym_links; | 114 | int include_sym_links; |
115 | |||
116 | /** | ||
117 | * GNUNET_YES if mode is file-only (return total == -1 for directories). | ||
118 | */ | ||
119 | int single_file_mode; | ||
115 | }; | 120 | }; |
116 | 121 | ||
117 | 122 | ||
@@ -176,6 +181,11 @@ getSizeRec (void *cls, const char *fn) | |||
176 | return GNUNET_SYSERR; | 181 | return GNUNET_SYSERR; |
177 | } | 182 | } |
178 | #endif | 183 | #endif |
184 | if ((S_ISDIR (buf.st_mode)) && (gfsd->single_file_mode == GNUNET_YES)) | ||
185 | { | ||
186 | errno = EISDIR; | ||
187 | return GNUNET_SYSERR; | ||
188 | } | ||
179 | if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)) | 189 | if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)) |
180 | gfsd->total += buf.st_size; | 190 | gfsd->total += buf.st_size; |
181 | if ((S_ISDIR (buf.st_mode)) && (0 == ACCESS (fn, X_OK)) && | 191 | if ((S_ISDIR (buf.st_mode)) && (0 == ACCESS (fn, X_OK)) && |
@@ -290,11 +300,13 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, OFF_T offset, | |||
290 | * of all sizes of files in the directory) | 300 | * of all sizes of files in the directory) |
291 | * @param includeSymLinks should symbolic links be | 301 | * @param includeSymLinks should symbolic links be |
292 | * included? | 302 | * included? |
303 | * @param singleFileMode GNUNET_YES to only get size of one file | ||
304 | * and return GNUNET_SYSERR for directories. | ||
293 | * @return GNUNET_SYSERR on error, GNUNET_OK on success | 305 | * @return GNUNET_SYSERR on error, GNUNET_OK on success |
294 | */ | 306 | */ |
295 | int | 307 | int |
296 | GNUNET_DISK_file_size (const char *filename, uint64_t * size, | 308 | GNUNET_DISK_file_size (const char *filename, uint64_t * size, |
297 | int includeSymLinks) | 309 | int includeSymLinks, int singleFileMode) |
298 | { | 310 | { |
299 | struct GetFileSizeData gfsd; | 311 | struct GetFileSizeData gfsd; |
300 | int ret; | 312 | int ret; |
@@ -302,6 +314,7 @@ GNUNET_DISK_file_size (const char *filename, uint64_t * size, | |||
302 | GNUNET_assert (size != NULL); | 314 | GNUNET_assert (size != NULL); |
303 | gfsd.total = 0; | 315 | gfsd.total = 0; |
304 | gfsd.include_sym_links = includeSymLinks; | 316 | gfsd.include_sym_links = includeSymLinks; |
317 | gfsd.single_file_mode = singleFileMode; | ||
305 | ret = getSizeRec (&gfsd, filename); | 318 | ret = getSizeRec (&gfsd, filename); |
306 | *size = gfsd.total; | 319 | *size = gfsd.total; |
307 | return ret; | 320 | return ret; |
@@ -1350,7 +1363,7 @@ GNUNET_DISK_file_copy (const char *src, const char *dst) | |||
1350 | struct GNUNET_DISK_FileHandle *in; | 1363 | struct GNUNET_DISK_FileHandle *in; |
1351 | struct GNUNET_DISK_FileHandle *out; | 1364 | struct GNUNET_DISK_FileHandle *out; |
1352 | 1365 | ||
1353 | if (GNUNET_OK != GNUNET_DISK_file_size (src, &size, GNUNET_YES)) | 1366 | if (GNUNET_OK != GNUNET_DISK_file_size (src, &size, GNUNET_YES, GNUNET_YES)) |
1354 | return GNUNET_SYSERR; | 1367 | return GNUNET_SYSERR; |
1355 | pos = 0; | 1368 | pos = 0; |
1356 | in = GNUNET_DISK_file_open (src, GNUNET_DISK_OPEN_READ, | 1369 | in = GNUNET_DISK_file_open (src, GNUNET_DISK_OPEN_READ, |
diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c index c2b95832e..d2efdc98f 100644 --- a/src/util/pseudonym.c +++ b/src/util/pseudonym.c | |||
@@ -320,7 +320,7 @@ GNUNET_PSEUDONYM_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
320 | 320 | ||
321 | len = 0; | 321 | len = 0; |
322 | if (0 == STAT (fn, &sbuf)) | 322 | if (0 == STAT (fn, &sbuf)) |
323 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (fn, &len, GNUNET_YES)); | 323 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (fn, &len, GNUNET_YES, GNUNET_YES)); |
324 | fh = GNUNET_DISK_file_open (fn, | 324 | fh = GNUNET_DISK_file_open (fn, |
325 | GNUNET_DISK_OPEN_CREATE | | 325 | GNUNET_DISK_OPEN_CREATE | |
326 | GNUNET_DISK_OPEN_READWRITE, | 326 | GNUNET_DISK_OPEN_READWRITE, |
@@ -475,7 +475,7 @@ GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
475 | GNUNET_assert (fn != NULL); | 475 | GNUNET_assert (fn != NULL); |
476 | 476 | ||
477 | if ((GNUNET_OK != GNUNET_DISK_file_test (fn) || | 477 | if ((GNUNET_OK != GNUNET_DISK_file_test (fn) || |
478 | (GNUNET_OK != GNUNET_DISK_file_size (fn, &len, GNUNET_YES))) || | 478 | (GNUNET_OK != GNUNET_DISK_file_size (fn, &len, GNUNET_YES, GNUNET_YES))) || |
479 | ((idx + 1) * sizeof (GNUNET_HashCode) > len)) | 479 | ((idx + 1) * sizeof (GNUNET_HashCode) > len)) |
480 | { | 480 | { |
481 | GNUNET_free (fn); | 481 | GNUNET_free (fn); |
diff --git a/src/util/test_disk.c b/src/util/test_disk.c index 546277256..149cec0b2 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c | |||
@@ -97,7 +97,7 @@ testOpenClose () | |||
97 | GNUNET_break (5 == GNUNET_DISK_file_write (fh, "Hello", 5)); | 97 | GNUNET_break (5 == GNUNET_DISK_file_write (fh, "Hello", 5)); |
98 | GNUNET_DISK_file_close (fh); | 98 | GNUNET_DISK_file_close (fh); |
99 | GNUNET_break (GNUNET_OK == | 99 | GNUNET_break (GNUNET_OK == |
100 | GNUNET_DISK_file_size (".testfile", &size, GNUNET_NO)); | 100 | GNUNET_DISK_file_size (".testfile", &size, GNUNET_NO, GNUNET_YES)); |
101 | if (size != 5) | 101 | if (size != 5) |
102 | return 1; | 102 | return 1; |
103 | GNUNET_break (0 == UNLINK (".testfile")); | 103 | GNUNET_break (0 == UNLINK (".testfile")); |