[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r490 - in GNUnet: . src/applications/fs/lib src/application
From: |
grothoff |
Subject: |
[GNUnet-SVN] r490 - in GNUnet: . src/applications/fs/lib src/applications/fs/module |
Date: |
Sat, 26 Mar 2005 10:28:38 -0800 (PST) |
Author: grothoff
Date: 2005-03-26 10:28:36 -0800 (Sat, 26 Mar 2005)
New Revision: 490
Modified:
GNUnet/src/applications/fs/lib/check.conf
GNUnet/src/applications/fs/lib/fslibtest.c
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/fs/module/ondemand.c
GNUnet/src/applications/fs/module/ondemand.h
GNUnet/todo
Log:
fixing fslib problems
Modified: GNUnet/src/applications/fs/lib/check.conf
===================================================================
--- GNUnet/src/applications/fs/lib/check.conf 2005-03-26 17:57:29 UTC (rev
489)
+++ GNUnet/src/applications/fs/lib/check.conf 2005-03-26 18:28:36 UTC (rev
490)
@@ -6,7 +6,7 @@
[GNUNETD]
VALGRIND = 300
HELOEXPIRES = 60
-LOGLEVEL = WARNING
+LOGLEVEL = NOTHING
LOGFILE = $GNUNETD_HOME/logs
KEEPLOG = 0
PIDFILE = $GNUNETD_HOME/gnunetd.pid
Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c 2005-03-26 17:57:29 UTC (rev
489)
+++ GNUnet/src/applications/fs/lib/fslibtest.c 2005-03-26 18:28:36 UTC (rev
490)
@@ -220,6 +220,8 @@
HashCode512 hc;
HashCode512 query;
int i;
+ char * tmpName;
+ int fd;
cronTime(&now);
daemon = fork();
@@ -269,6 +271,7 @@
hash(&((DBlock*)&block[1])[1],
ntohl(block->size) - sizeof(Datastore_Value) - sizeof(DBlock),
&hc);
+ /* indexing without symlink */
CHECK(OK == FS_index(sock,
&hc,
block,
@@ -277,6 +280,25 @@
CHECK(OK == FS_unindex(sock,
MAX_BUFFER_SIZE,
&hc));
+ /* indexing with symlink */
+ tmpName = STRDUP("/tmp/symlinkTestXXXXXX");
+ CHECK(-1 != (fd = mkstemp(tmpName)));
+ CHECK(-1 != WRITE(fd,
+ &((DBlock*)&block[1])[1],
+ ntohl(block->size) - sizeof(Datastore_Value) -
sizeof(DBlock)));
+ CLOSE(fd);
+ CHECK(FS_initIndex(sock,
+ &hc,
+ tmpName) == YES);
+ CHECK(OK == FS_index(sock,
+ &hc,
+ block,
+ 0));
+ CHECK(OK == trySearch(ctx, i));
+ CHECK(OK == FS_unindex(sock,
+ MAX_BUFFER_SIZE,
+ &hc));
+ UNLINK(tmpName);
FREE(block);
}
for (i=32;i<MAX_BUFFER_SIZE;i*=2) {
@@ -336,8 +358,8 @@
/* just to check if it crashes... */
FS_getAveragePriority(sock);
+ /* END OF TEST CODE */
- /* END OF TEST CODE */
FAILURE:
if (ctx != NULL)
FS_SEARCH_destroyContext(ctx);
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2005-03-26 17:57:29 UTC (rev
489)
+++ GNUnet/src/applications/fs/module/fs.c 2005-03-26 18:28:36 UTC (rev
490)
@@ -1071,7 +1071,7 @@
GNUNET_ASSERT(SYSERR != coreAPI->unregisterClientHandler(AFS_CS_PROTO_INDEX,
&csHandleRequestIndex));
GNUNET_ASSERT(SYSERR !=
coreAPI->unregisterClientHandler(AFS_CS_PROTO_INIT_INDEX,
- &csHandleRequestInitIndex));
+
&csHandleRequestInitIndex));
GNUNET_ASSERT(SYSERR != coreAPI->unregisterClientHandler(AFS_CS_PROTO_DELETE,
&csHandleRequestDelete));
GNUNET_ASSERT(SYSERR !=
coreAPI->unregisterClientHandler(AFS_CS_PROTO_UNINDEX,
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2005-03-26 17:57:29 UTC
(rev 489)
+++ GNUnet/src/applications/fs/module/ondemand.c 2005-03-26 18:28:36 UTC
(rev 490)
@@ -102,16 +102,19 @@
/**
* Creates a symlink to the given file in the shared directory
+ *
* @param fn the file that was indexed
* @param fileId the file's hash code
- * @return SYSERR on error, YES on success
+ * @return SYSERR on error, NO if symlinking failed,
+ * YES on success
*/
int ONDEMAND_initIndex(const HashCode512 * fileId,
- const char *fn) {
+ const char *fn) {
EncName enc;
char * serverDir;
char * serverFN;
char unavail_key[256];
+ HashCode512 linkId;
serverDir
= getConfigurationString("FS",
@@ -127,7 +130,15 @@
strlen("/data/shared/") + 1);
strcat(serverDir, "/data/shared/");
}
+ if ( (SYSERR == getFileHash(fn,
+ &linkId)) ||
+ (! equalsHashCode512(&linkId,
+ fileId)) ) {
+ FREE(serverDir);
+ return NO;
+ }
+
serverFN = MALLOC(strlen(serverDir) + 2 + sizeof(EncName));
strcpy(serverFN,
serverDir);
@@ -145,7 +156,7 @@
if (0 != SYMLINK(fn, serverFN)) {
LOG_FILE_STRERROR(LOG_ERROR, "symlink", fn);
FREE(serverFN);
- return SYSERR;
+ return NO;
}
SNPRINTF(unavail_key,
256,
@@ -160,8 +171,6 @@
* Writes the given content to the file at the specified offset
* and stores an OnDemandBlock into the datastore.
*
- *
- *
* @return NO if already present, YES on success,
* SYSERR on other error (i.e. datastore full)
*/
@@ -177,12 +186,59 @@
OnDemandBlock odb;
HashCode512 key;
EncName enc;
+ struct stat sbuf;
+ char * fn;
if (size <= sizeof(DBlock)) {
BREAK();
return SYSERR;
}
+ fn = getOnDemandFile(fileId);
+ if ( (0 != stat(fn,
+ &sbuf))
+#ifdef S_ISLNK
+ || (! S_ISLNK(sbuf.st_mode))
+#endif
+ ) {
+ int fd;
+
+ /* not sym-linked, write content to offset! */
+ LOG(LOG_DEBUG,
+ "Storing on-demand encoded data in '%s'.\n",
+ fn);
+ fd = OPEN(fn,
+#ifdef O_LARGEFILE
+ O_CREAT|O_WRONLY|O_LARGEFILE,
+#else
+ O_CREAT|O_WRONLY,
+#endif
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /* 644 */
+ if(fd == -1) {
+ LOG_FILE_STRERROR(LOG_ERROR, "open", fn);
+ FREE(fn);
+ return SYSERR;
+ }
+ lseek(fd,
+ fileOffset,
+ SEEK_SET);
+ ret = WRITE(fd,
+ &content[1],
+ size - sizeof(DBlock));
+ if (ret == size - sizeof(DBlock)) {
+ ret = OK;
+ } else {
+ LOG_FILE_STRERROR(LOG_ERROR, "write", fn);
+ ret = SYSERR;
+ }
+ CLOSE(fd);
+ if (ret == SYSERR) {
+ FREE(fn);
+ return ret;
+ }
+ }
+ FREE(fn);
+
odb.header.size = htonl(sizeof(OnDemandBlock));
odb.header.type = htonl(ONDEMAND_BLOCK);
odb.header.prio = htonl(prio);
@@ -196,7 +252,7 @@
fileBlockGetQuery(content,
size,
&key);
- /* extra check */
+#if EXTRA_CHECKS
{
Datastore_Value * dsvalue;
if (OK != fileBlockEncode(content,
@@ -208,7 +264,7 @@
FREE(dsvalue);
}
}
- /* end extra check */
+#endif
IFLOG(LOG_DEBUG,
hash2enc(&key, &enc));
Modified: GNUnet/src/applications/fs/module/ondemand.h
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.h 2005-03-26 17:57:29 UTC
(rev 489)
+++ GNUnet/src/applications/fs/module/ondemand.h 2005-03-26 18:28:36 UTC
(rev 490)
@@ -29,8 +29,12 @@
#include "gnunet_util.h"
#include "gnunet_datastore_service.h"
+#define EXTRA_CHECKS YES
+
/**
* Creates a symlink to the given file in the shared directory
+ * @return SYSERR on error, NO if symlinking failed,
+ * YES on success
*/
int ONDEMAND_initIndex(const HashCode512 * fileId,
const char *fn);
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-03-26 17:57:29 UTC (rev 489)
+++ GNUnet/todo 2005-03-26 18:28:36 UTC (rev 490)
@@ -1,8 +1,5 @@
0.7.0pre1 [4'05] (aka "preview"):
TESTING / TESTCASES:
-- FSLIB:
- * Nils's symlink "improvements" broke the code, fslibtest fails
- (first bug, a deadlock due to synchronous del has been fixed)
- multi-peer: (see sessiontest.c and tbenchtest.c for templates)
* gap
* dht / gnunet-dht-join and gnunet-dht-query
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r490 - in GNUnet: . src/applications/fs/lib src/applications/fs/module,
grothoff <=