diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-12-19 18:43:38 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-12-19 18:43:38 +0100 |
commit | 3636ea628d051cf2ba7a9038c50528c561d0aeaa (patch) | |
tree | 87664b904950052e8b6997a371ed5ecb1ea4b310 /src/peerinfo/gnunet-service-peerinfo.c | |
parent | 74d7528e6bd53cf5acc939c63a5be74a001e5ce1 (diff) | |
download | gnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.tar.gz gnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.zip |
change GNUNET_DISK_fn_write() to always do atomic writes and to NOT overwrite existing files; also change the return value to not return the size of the written file but GNUNET_OK on success, and integrate creating the directory if needed; breaks API, hence bumping libgnunetutil version
Diffstat (limited to 'src/peerinfo/gnunet-service-peerinfo.c')
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 79af90dd4..1b1232ecb 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -807,13 +807,14 @@ update_hello (const struct GNUNET_PeerIdentity *peer, | |||
807 | } | 807 | } |
808 | GNUNET_assert (pos == size); | 808 | GNUNET_assert (pos == size); |
809 | 809 | ||
810 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, | 810 | if (GNUNET_SYSERR == |
811 | buffer, | 811 | GNUNET_DISK_fn_write (fn, |
812 | size, | 812 | buffer, |
813 | GNUNET_DISK_PERM_USER_READ | 813 | size, |
814 | | GNUNET_DISK_PERM_USER_WRITE | 814 | GNUNET_DISK_PERM_USER_READ |
815 | | GNUNET_DISK_PERM_GROUP_READ | 815 | | GNUNET_DISK_PERM_USER_WRITE |
816 | | GNUNET_DISK_PERM_OTHER_READ)) | 816 | | GNUNET_DISK_PERM_GROUP_READ |
817 | | GNUNET_DISK_PERM_OTHER_READ)) | ||
817 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); | 818 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); |
818 | else | 819 | else |
819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 820 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -987,13 +988,15 @@ discard_hosts_helper (void *cls, const char *fn) | |||
987 | 988 | ||
988 | if (0 < write_pos) | 989 | if (0 < write_pos) |
989 | { | 990 | { |
990 | GNUNET_DISK_fn_write (fn, | 991 | (void) GNUNET_DISK_directory_remove (fn); |
991 | writebuffer, | 992 | GNUNET_assert (GNUNET_OK == |
992 | write_pos, | 993 | GNUNET_DISK_fn_write (fn, |
993 | GNUNET_DISK_PERM_USER_READ | 994 | writebuffer, |
994 | | GNUNET_DISK_PERM_USER_WRITE | 995 | write_pos, |
995 | | GNUNET_DISK_PERM_GROUP_READ | 996 | GNUNET_DISK_PERM_USER_READ |
996 | | GNUNET_DISK_PERM_OTHER_READ); | 997 | | GNUNET_DISK_PERM_USER_WRITE |
998 | | GNUNET_DISK_PERM_GROUP_READ | ||
999 | | GNUNET_DISK_PERM_OTHER_READ)); | ||
997 | } | 1000 | } |
998 | else if (0 != unlink (fn)) | 1001 | else if (0 != unlink (fn)) |
999 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | 1002 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |