diff options
author | Nils Durner <durner@gnunet.org> | 2009-06-15 20:11:51 +0000 |
---|---|---|
committer | Nils Durner <durner@gnunet.org> | 2009-06-15 20:11:51 +0000 |
commit | 1088905b5a89a24706d2c1877d289589e3f3c222 (patch) | |
tree | 38ec7cdc1b80502aa950c68ebefe1e3f42efa14b /src/peerinfo | |
parent | 7e3df72d6b8a32b15b02110b54c77f77e28928a2 (diff) | |
download | gnunet-1088905b5a89a24706d2c1877d289589e3f3c222.tar.gz gnunet-1088905b5a89a24706d2c1877d289589e3f3c222.zip |
more complete DISK API
Diffstat (limited to 'src/peerinfo')
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 0d383c0f1..eb2dc4264 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -197,14 +197,14 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | |||
197 | entry->identity = *identity; | 197 | entry->identity = *identity; |
198 | fn = get_trust_filename (identity); | 198 | fn = get_trust_filename (identity); |
199 | if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && | 199 | if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && |
200 | (sizeof (trust) == GNUNET_DISK_file_read (fn, sizeof (trust), &trust))) | 200 | (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) |
201 | entry->disk_trust = entry->trust = ntohl (trust); | 201 | entry->disk_trust = entry->trust = ntohl (trust); |
202 | GNUNET_free (fn); | 202 | GNUNET_free (fn); |
203 | 203 | ||
204 | fn = get_host_filename (identity); | 204 | fn = get_host_filename (identity); |
205 | if (GNUNET_DISK_file_test (fn) == GNUNET_YES) | 205 | if (GNUNET_DISK_file_test (fn) == GNUNET_YES) |
206 | { | 206 | { |
207 | size = GNUNET_DISK_file_read (fn, sizeof (buffer), buffer); | 207 | size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer)); |
208 | hello = (const struct GNUNET_HELLO_Message *) buffer; | 208 | hello = (const struct GNUNET_HELLO_Message *) buffer; |
209 | now = GNUNET_TIME_absolute_get (); | 209 | now = GNUNET_TIME_absolute_get (); |
210 | hello_clean = GNUNET_HELLO_iterate_addresses (hello, | 210 | hello_clean = GNUNET_HELLO_iterate_addresses (hello, |
@@ -371,7 +371,9 @@ bind_address (const struct GNUNET_PeerIdentity *peer, | |||
371 | host->hello = mrg; | 371 | host->hello = mrg; |
372 | } | 372 | } |
373 | fn = get_host_filename (peer); | 373 | fn = get_host_filename (peer); |
374 | GNUNET_DISK_file_write (fn, host->hello, GNUNET_HELLO_size (hello), "644"); | 374 | GNUNET_DISK_fn_write (fn, host->hello, GNUNET_HELLO_size (hello), |
375 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | ||
376 | | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ); | ||
375 | GNUNET_free (fn); | 377 | GNUNET_free (fn); |
376 | } | 378 | } |
377 | 379 | ||
@@ -455,8 +457,9 @@ flush_trust (struct HostEntry *host) | |||
455 | else | 457 | else |
456 | { | 458 | { |
457 | trust = htonl (host->trust); | 459 | trust = htonl (host->trust); |
458 | if (GNUNET_OK == | 460 | if (GNUNET_OK == GNUNET_DISK_fn_write (fn, &trust, sizeof(uint32_t), |
459 | GNUNET_DISK_file_write (fn, &trust, sizeof (uint32_t), "644")) | 461 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE |
462 | | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ)) | ||
460 | host->disk_trust = host->trust; | 463 | host->disk_trust = host->trust; |
461 | } | 464 | } |
462 | GNUNET_free (fn); | 465 | GNUNET_free (fn); |
@@ -497,7 +500,7 @@ discard_hosts_helper (void *cls, const char *fn) | |||
497 | struct GNUNET_HELLO_Message *new_hello; | 500 | struct GNUNET_HELLO_Message *new_hello; |
498 | int size; | 501 | int size; |
499 | 502 | ||
500 | size = GNUNET_DISK_file_read (fn, sizeof (buffer), buffer); | 503 | size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer)); |
501 | if ((size < sizeof (struct GNUNET_MessageHeader)) && (0 != UNLINK (fn))) | 504 | if ((size < sizeof (struct GNUNET_MessageHeader)) && (0 != UNLINK (fn))) |
502 | { | 505 | { |
503 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 506 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | |
@@ -513,9 +516,9 @@ discard_hosts_helper (void *cls, const char *fn) | |||
513 | GNUNET_ERROR_TYPE_BULK, "unlink", fn); | 516 | GNUNET_ERROR_TYPE_BULK, "unlink", fn); |
514 | if (new_hello != NULL) | 517 | if (new_hello != NULL) |
515 | { | 518 | { |
516 | GNUNET_DISK_file_write (fn, | 519 | GNUNET_DISK_fn_write (fn, new_hello, GNUNET_HELLO_size (new_hello), |
517 | new_hello, | 520 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE |
518 | GNUNET_HELLO_size (new_hello), "644"); | 521 | | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ); |
519 | GNUNET_free (new_hello); | 522 | GNUNET_free (new_hello); |
520 | } | 523 | } |
521 | return GNUNET_OK; | 524 | return GNUNET_OK; |