aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_disk_lib.h5
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c7
-rw-r--r--src/util/disk.c7
-rw-r--r--src/util/pseudonym.c5
-rw-r--r--src/util/test_disk.c6
5 files changed, 18 insertions, 12 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index 69f7fb825..fc5b9b5eb 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -327,6 +327,7 @@ struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn,
327 */ 327 */
328struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking); 328struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking);
329 329
330
330/** 331/**
331 * Closes an interprocess channel 332 * Closes an interprocess channel
332 * @param p pipe 333 * @param p pipe
@@ -334,6 +335,7 @@ struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking);
334 */ 335 */
335int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); 336int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
336 337
338
337/** 339/**
338 * Close an open file. 340 * Close an open file.
339 * 341 *
@@ -342,6 +344,7 @@ int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
342 */ 344 */
343int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); 345int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
344 346
347
345/** 348/**
346 * Get the handle to a particular pipe end 349 * Get the handle to a particular pipe end
347 * @param p pipe 350 * @param p pipe
@@ -384,7 +387,7 @@ ssize_t GNUNET_DISK_fn_read (const char *fn,
384 * @param h handle to open file 387 * @param h handle to open file
385 * @param buffer the data to write 388 * @param buffer the data to write
386 * @param n number of bytes to write 389 * @param n number of bytes to write
387 * @return GNUNET_OK on success, GNUNET_SYSERR on error 390 * @return number of bytes written on success, GNUNET_SYSERR on error
388 */ 391 */
389ssize_t GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, 392ssize_t GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h,
390 const void *buffer, 393 const void *buffer,
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 3608dab84..b9b242522 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -477,9 +477,10 @@ flush_trust (struct HostEntry *host)
477 else 477 else
478 { 478 {
479 trust = htonl (host->trust); 479 trust = htonl (host->trust);
480 if (GNUNET_OK == GNUNET_DISK_fn_write (fn, &trust, sizeof(uint32_t), 480 if (sizeof(uint32_t) == GNUNET_DISK_fn_write (fn, &trust,
481 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE 481 sizeof(uint32_t),
482 | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ)) 482 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE
483 | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ))
483 host->disk_trust = host->trust; 484 host->disk_trust = host->trust;
484 } 485 }
485 GNUNET_free (fn); 486 GNUNET_free (fn);
diff --git a/src/util/disk.c b/src/util/disk.c
index 40d637ee3..b0c648b25 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -653,7 +653,7 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, const void *buff
653 * @param buffer the data to write 653 * @param buffer the data to write
654 * @param n number of bytes to write 654 * @param n number of bytes to write
655 * @param mode file permissions 655 * @param mode file permissions
656 * @return GNUNET_OK on success, GNUNET_SYSERR on error 656 * @return number of bytes written on success, GNUNET_SYSERR on error
657 */ 657 */
658ssize_t 658ssize_t
659GNUNET_DISK_fn_write (const char * fn, const void *buffer, 659GNUNET_DISK_fn_write (const char * fn, const void *buffer,
@@ -661,7 +661,7 @@ GNUNET_DISK_fn_write (const char * fn, const void *buffer,
661 enum GNUNET_DISK_AccessPermissions mode) 661 enum GNUNET_DISK_AccessPermissions mode)
662{ 662{
663 struct GNUNET_DISK_FileHandle *fh; 663 struct GNUNET_DISK_FileHandle *fh;
664 int ret; 664 ssize_t ret;
665 665
666 fh = GNUNET_DISK_file_open (fn, 666 fh = GNUNET_DISK_file_open (fn,
667 GNUNET_DISK_OPEN_WRITE 667 GNUNET_DISK_OPEN_WRITE
@@ -669,9 +669,8 @@ GNUNET_DISK_fn_write (const char * fn, const void *buffer,
669 | GNUNET_DISK_OPEN_CREATE, mode); 669 | GNUNET_DISK_OPEN_CREATE, mode);
670 if (!fh) 670 if (!fh)
671 return GNUNET_SYSERR; 671 return GNUNET_SYSERR;
672 ret = (n == GNUNET_DISK_file_write (fh, buffer, n)) ? GNUNET_OK : GNUNET_SYSERR; 672 ret = GNUNET_DISK_file_write (fh, buffer, n);
673 GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fh)); 673 GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fh));
674
675 return ret; 674 return ret;
676} 675}
677 676
diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c
index 04a6a1f78..40165800b 100644
--- a/src/util/pseudonym.c
+++ b/src/util/pseudonym.c
@@ -209,8 +209,9 @@ write_pseudonym_info (const struct GNUNET_CONFIGURATION_Handle *cfg,
209 off + 1], 209 off + 1],
210 size, 210 size,
211 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)); 211 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL));
212 GNUNET_DISK_fn_write (fn, buf, tag, GNUNET_DISK_PERM_USER_READ 212 GNUNET_break
213 | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_GROUP_READ); 213 (tag != GNUNET_DISK_fn_write (fn, buf, tag, GNUNET_DISK_PERM_USER_READ
214 | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_GROUP_READ));
214 GNUNET_free (fn); 215 GNUNET_free (fn);
215 GNUNET_free (buf); 216 GNUNET_free (buf);
216 /* create entry for pseudonym name in names */ 217 /* create entry for pseudonym name in names */
diff --git a/src/util/test_disk.c b/src/util/test_disk.c
index 705a24abf..8b485edc5 100644
--- a/src/util/test_disk.c
+++ b/src/util/test_disk.c
@@ -36,8 +36,10 @@ testReadWrite ()
36 char tmp[100 + 1]; 36 char tmp[100 + 1];
37 int ret; 37 int ret;
38 38
39 if (GNUNET_OK != GNUNET_DISK_fn_write (".testfile", TESTSTRING, strlen ( 39 if (strlen(TESTSTRING) !=
40 TESTSTRING), GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)) 40 GNUNET_DISK_fn_write (".testfile", TESTSTRING,
41 strlen (TESTSTRING),
42 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE))
41 return 1; 43 return 1;
42 if (GNUNET_OK != GNUNET_DISK_file_test (".testfile")) 44 if (GNUNET_OK != GNUNET_DISK_file_test (".testfile"))
43 return 1; 45 return 1;