[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9287 - in gnunet/src: include peerinfo util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9287 - in gnunet/src: include peerinfo util |
Date: |
Sun, 25 Oct 2009 13:28:48 -0600 |
Author: grothoff
Date: 2009-10-25 13:28:48 -0600 (Sun, 25 Oct 2009)
New Revision: 9287
Modified:
gnunet/src/include/gnunet_disk_lib.h
gnunet/src/peerinfo/gnunet-service-peerinfo.c
gnunet/src/util/disk.c
gnunet/src/util/pseudonym.c
gnunet/src/util/test_disk.c
Log:
more consistent disk API
Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h 2009-10-25 19:28:32 UTC (rev
9286)
+++ gnunet/src/include/gnunet_disk_lib.h 2009-10-25 19:28:48 UTC (rev
9287)
@@ -327,6 +327,7 @@
*/
struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking);
+
/**
* Closes an interprocess channel
* @param p pipe
@@ -334,6 +335,7 @@
*/
int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
+
/**
* Close an open file.
*
@@ -342,6 +344,7 @@
*/
int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
+
/**
* Get the handle to a particular pipe end
* @param p pipe
@@ -384,7 +387,7 @@
* @param h handle to open file
* @param buffer the data to write
* @param n number of bytes to write
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return number of bytes written on success, GNUNET_SYSERR on error
*/
ssize_t GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h,
const void *buffer,
Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c 2009-10-25 19:28:32 UTC
(rev 9286)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c 2009-10-25 19:28:48 UTC
(rev 9287)
@@ -477,9 +477,10 @@
else
{
trust = htonl (host->trust);
- if (GNUNET_OK == GNUNET_DISK_fn_write (fn, &trust, sizeof(uint32_t),
- GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE
- | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ))
+ if (sizeof(uint32_t) == GNUNET_DISK_fn_write (fn, &trust,
+ sizeof(uint32_t),
+ GNUNET_DISK_PERM_USER_READ
| GNUNET_DISK_PERM_USER_WRITE
+ |
GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ))
host->disk_trust = host->trust;
}
GNUNET_free (fn);
Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c 2009-10-25 19:28:32 UTC (rev 9286)
+++ gnunet/src/util/disk.c 2009-10-25 19:28:48 UTC (rev 9287)
@@ -653,7 +653,7 @@
* @param buffer the data to write
* @param n number of bytes to write
* @param mode file permissions
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return number of bytes written on success, GNUNET_SYSERR on error
*/
ssize_t
GNUNET_DISK_fn_write (const char * fn, const void *buffer,
@@ -661,7 +661,7 @@
enum GNUNET_DISK_AccessPermissions mode)
{
struct GNUNET_DISK_FileHandle *fh;
- int ret;
+ ssize_t ret;
fh = GNUNET_DISK_file_open (fn,
GNUNET_DISK_OPEN_WRITE
@@ -669,9 +669,8 @@
| GNUNET_DISK_OPEN_CREATE, mode);
if (!fh)
return GNUNET_SYSERR;
- ret = (n == GNUNET_DISK_file_write (fh, buffer, n)) ? GNUNET_OK :
GNUNET_SYSERR;
+ ret = GNUNET_DISK_file_write (fh, buffer, n);
GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fh));
-
return ret;
}
Modified: gnunet/src/util/pseudonym.c
===================================================================
--- gnunet/src/util/pseudonym.c 2009-10-25 19:28:32 UTC (rev 9286)
+++ gnunet/src/util/pseudonym.c 2009-10-25 19:28:48 UTC (rev 9287)
@@ -209,8 +209,9 @@
off + 1],
size,
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL));
- GNUNET_DISK_fn_write (fn, buf, tag, GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_GROUP_READ);
+ GNUNET_break
+ (tag != GNUNET_DISK_fn_write (fn, buf, tag, GNUNET_DISK_PERM_USER_READ
+ | GNUNET_DISK_PERM_USER_WRITE |
GNUNET_DISK_PERM_GROUP_READ));
GNUNET_free (fn);
GNUNET_free (buf);
/* create entry for pseudonym name in names */
Modified: gnunet/src/util/test_disk.c
===================================================================
--- gnunet/src/util/test_disk.c 2009-10-25 19:28:32 UTC (rev 9286)
+++ gnunet/src/util/test_disk.c 2009-10-25 19:28:48 UTC (rev 9287)
@@ -36,8 +36,10 @@
char tmp[100 + 1];
int ret;
- if (GNUNET_OK != GNUNET_DISK_fn_write (".testfile", TESTSTRING, strlen (
- TESTSTRING), GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE))
+ if (strlen(TESTSTRING) !=
+ GNUNET_DISK_fn_write (".testfile", TESTSTRING,
+ strlen (TESTSTRING),
+ GNUNET_DISK_PERM_USER_READ |
GNUNET_DISK_PERM_USER_WRITE))
return 1;
if (GNUNET_OK != GNUNET_DISK_file_test (".testfile"))
return 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9287 - in gnunet/src: include peerinfo util,
gnunet <=