gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r234 - in GNUnet/src: applications/fs applications/fs/ecrs


From: grothoff
Subject: [GNUnet-SVN] r234 - in GNUnet/src: applications/fs applications/fs/ecrs applications/fs/module include
Date: Thu, 10 Feb 2005 16:37:18 -0800 (PST)

Author: grothoff
Date: 2005-02-10 16:37:17 -0800 (Thu, 10 Feb 2005)
New Revision: 234

Modified:
   GNUnet/src/applications/fs/ecrs/keyspace.c
   GNUnet/src/applications/fs/ecrs/unindex.c
   GNUnet/src/applications/fs/ecrs/upload.c
   GNUnet/src/applications/fs/ecrs_core.c
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/applications/fs/module/ondemand.c
   GNUnet/src/include/ecrs_core.h
Log:
multiple bugfixes

Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c  2005-02-10 23:55:11 UTC (rev 
233)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c  2005-02-11 00:37:17 UTC (rev 
234)
@@ -66,6 +66,7 @@
   char ** keywords;
   unsigned int keywordCount;
   int i;
+  EncName enc;
 
   if (! ECRS_isKeywordURI(uri)) {
     BREAK();
@@ -122,9 +123,12 @@
     hash(keywords[i],
         strlen(keywords[i]),
         &hc);
+    IFLOG(LOG_DEBUG,
+         hash2enc(&hc,
+                  &enc));
     LOG(LOG_DEBUG,
-       "Encrypting KBlock with key %u.\n",
-       hc.a);
+       "Encrypting KBlock with key %s.\n",
+       &enc);
     ECRS_encryptInPlace(&hc,
                        &kb[1],
                        mdsize + strlen(dstURI) + 1);

Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c   2005-02-10 23:55:11 UTC (rev 
233)
+++ GNUnet/src/applications/fs/ecrs/unindex.c   2005-02-11 00:37:17 UTC (rev 
234)
@@ -65,11 +65,11 @@
   present = size / sizeof(CHK);
   db = (DBlock*) &iblocks[level][1];
   if (present == CHK_PER_INODE) {
-    fileBlockGetKey((char*) db,
-                   size,
+    fileBlockGetKey(db,
+                   size + sizeof(DBlock),
                    &ichk.key);
-    fileBlockGetQuery((char*) db,
-                     size,
+    fileBlockGetQuery(db,
+                     size + sizeof(DBlock),
                      &ichk.query);
     if (OK != pushBlock(sock, &ichk, level+1, iblocks))
       return SYSERR;
@@ -329,15 +329,14 @@
                        filename);
       goto FAILURE;
     }   
-    size = DBLOCK_SIZE + sizeof(DBlock); /* padding! */
     if (tt != NULL)
       if (OK != tt(ttClosure))
        goto FAILURE;
-    fileBlockGetKey((char*) &dblock[1],
-                   size,
+    fileBlockGetKey(db,
+                   size + sizeof(DBlock),
                    &chk.key);
-    fileBlockGetQuery((char*) &dblock[1],
-                     size,
+    fileBlockGetQuery(db,
+                     size + sizeof(DBlock),
                      &chk.query);
     if (OK != pushBlock(sock,
                        &chk,
@@ -369,11 +368,11 @@
   for (i=0;i<treedepth;i++) {
     size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
     db = (DBlock*) &iblocks[i];
-    fileBlockGetKey((char*) db,
-                   size,
+    fileBlockGetKey(db,
+                   size + sizeof(DBlock),
                    &chk.key);
-    fileBlockGetQuery((char*) db,
-                     size,
+    fileBlockGetQuery(db,
+                     size + sizeof(DBlock),
                      &chk.query);   
     if (OK != pushBlock(sock, 
                        &chk,

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2005-02-10 23:55:11 UTC (rev 
233)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2005-02-11 00:37:17 UTC (rev 
234)
@@ -59,12 +59,19 @@
   present = size / sizeof(CHK);
   db = (DBlock*) &iblocks[level][1];
   if (present == CHK_PER_INODE) {
-    fileBlockGetKey((char*) db,
-                   size,
+    fileBlockGetKey(db,
+                   size + sizeof(DBlock),
                    &ichk.key);
-    fileBlockGetQuery((char*) db,
-                     size,
+    fileBlockGetQuery(db,
+                     size + sizeof(DBlock),
                      &ichk.query);
+    IFLOG(LOG_DEBUG,
+         hash2enc(&ichk.query,
+                  &enc));
+    LOG(LOG_DEBUG,
+       "Query for current iblock at level %u is %s\n",
+       level,
+       &enc);
     if (OK != pushBlock(sock, &ichk, level+1, iblocks))
       return SYSERR;
     fileBlockEncode(db,
@@ -217,8 +224,10 @@
   cron_t now;
   char * uris;
   FileIdentifier fid; 
+  EncName enc;
 
   cronTime(&start);
+  memset(&chk, 0, sizeof(CHK));
   if (isDirectory(filename)) {
     BREAK();
     return SYSERR;
@@ -301,21 +310,21 @@
       LOG_FILE_STRERROR(LOG_WARNING, "READ", filename);
       goto FAILURE;
     }   
-    size = DBLOCK_SIZE; /* padding! */
     if (tt != NULL)
       if (OK != tt(ttClosure))
        goto FAILURE;
-    fileBlockGetKey((char*) &dblock[1],
-                   size,
+    fileBlockGetKey(db,
+                   size + sizeof(DBlock),
                    &chk.key);
-    fileBlockGetQuery((char*) &dblock[1],
-                     size,
+    fileBlockGetQuery(db,
+                     size + sizeof(DBlock),
                      &chk.query);
-    if (OK != pushBlock(sock,
-                       &chk,
-                       0, /* dblocks are on level 0 */
-                       iblocks))
-      goto FAILURE;
+    IFLOG(LOG_DEBUG,
+         hash2enc(&chk.query,
+                  &enc));
+    LOG(LOG_DEBUG,
+       "Query for current block is %s\n",
+       &enc);
     if (doIndex) {
       if (SYSERR == FS_index(sock,
                             &fileId,
@@ -335,6 +344,8 @@
       }
       FREE(value);
     }
+    if (treedepth == 0)
+      goto NOTREE;
     pos += size;
     cronTime(&now);
     if (pos > 0) {
@@ -342,6 +353,11 @@
                      (((double)(now - start)/(double)pos)) 
                      * (double)filesize);
     }
+    if (OK != pushBlock(sock,
+                       &chk,
+                       0, /* dblocks are on level 0 */
+                       iblocks))
+      goto FAILURE;
   }
   if (tt != NULL)
     if (OK != tt(ttClosure))
@@ -351,12 +367,23 @@
     if (size == sizeof(DBlock))
       continue;
     db = (DBlock*) &iblocks[i];
-    fileBlockGetKey((char*) db,
-                   size,
+    fileBlockGetKey(db,
+                   size + sizeof(DBlock),
                    &chk.key);
-    fileBlockGetQuery((char*) db,
-                     size,
+    LOG(LOG_DEBUG,
+       "Computing query for %u bytes content %.*s\n",
+       size,
+       size, db);
+    fileBlockGetQuery(db,
+                     size + sizeof(DBlock),
                      &chk.query);   
+    IFLOG(LOG_DEBUG,
+         hash2enc(&chk.query,
+                  &enc));
+    LOG(LOG_DEBUG,
+       "Query for current block at level %u is %s\n",
+       treedepth,
+       &enc);
     if (OK != pushBlock(sock, 
                        &chk,
                        i+1, 
@@ -375,11 +402,18 @@
     FREE(iblocks[i]);
     iblocks[i] = NULL;
   }
+ NOTREE:
   if (doIndex) {
     trySymlinking(filename,
                  &fileId,
                  sock);
   }
+  IFLOG(LOG_DEBUG,
+       hash2enc(&chk.query,
+                &enc));
+  LOG(LOG_DEBUG,
+      "Query for top block is %s\n",
+      &enc);  
   /* build URI */
   fid.file_length = htonll(filesize);
   fid.chk = chk;

Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c      2005-02-10 23:55:11 UTC (rev 
233)
+++ GNUnet/src/applications/fs/ecrs_core.c      2005-02-11 00:37:17 UTC (rev 
234)
@@ -92,12 +92,12 @@
  * Get the key that will be used to decrypt
  * a certain block of data.
  */
-void fileBlockGetKey(const char * data,
+void fileBlockGetKey(const DBlock * data,
                     unsigned int len,
                     HashCode160 * key) {
-  GNUNET_ASSERT(len >= sizeof(unsigned int));
-  hash(&data[sizeof(unsigned int)], 
-       len - sizeof(unsigned int), 
+  GNUNET_ASSERT(len >= sizeof(DBlock));
+  hash(&data[1],
+       len - sizeof(DBlock), 
        key);
 }
 
@@ -105,17 +105,18 @@
  * Get the query that will be used to query for
  * a certain block of data.
  */
-void fileBlockGetQuery(const char * data,
+void fileBlockGetQuery(const DBlock * db,
                       unsigned int len,
                       HashCode160 * query) {
   char * tmp;
+  const char * data;
   HashCode160 hc;
   SESSIONKEY skey;
   unsigned char iv[BLOWFISH_BLOCK_LENGTH];
 
-  GNUNET_ASSERT(len >= sizeof(unsigned int));
-  data = &data[sizeof(unsigned int)];
-  len -= sizeof(unsigned int);
+  GNUNET_ASSERT(len >= sizeof(DBlock));
+  data = (const char*) &db[1];
+  len -= sizeof(DBlock);
   hash(data, len, &hc);
   hashToKey(&hc,
            &skey,
@@ -158,7 +159,9 @@
     return SYSERR;
   switch (type) {
   case D_BLOCK: 
-    fileBlockGetKey(data, size, query);
+    fileBlockGetKey((const DBlock*)data,
+                   size, 
+                   query);
     return OK;  
   case S_BLOCK: {
     SBlock * sb;

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-02-10 23:55:11 UTC (rev 
233)
+++ GNUnet/src/applications/fs/module/fs.c      2005-02-11 00:37:17 UTC (rev 
234)
@@ -360,8 +360,6 @@
   int ret;
   const RequestIndex * ri;
   
-  LOG(LOG_DEBUG,
-      "Received index request from client\n");
   if (ntohs(req->size) < sizeof(RequestIndex)) {
     BREAK();
     return SYSERR;

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2005-02-10 23:55:11 UTC 
(rev 233)
+++ GNUnet/src/applications/fs/module/ondemand.c        2005-02-11 00:37:17 UTC 
(rev 234)
@@ -122,6 +122,7 @@
   int ret;
   OnDemandBlock odb;
   HashCode160 key;
+  EncName enc;
 
   if (size <= sizeof(DBlock)) {
     BREAK();
@@ -166,6 +167,12 @@
   fileBlockGetQuery(content,
                    size,
                    &key);  
+  IFLOG(LOG_DEBUG,
+       hash2enc(&key, &enc));
+  LOG(LOG_DEBUG,
+      "Storing on-demand content for query '%s'\n",
+      &enc);
+
   ret = datastore->get(&key,
                       ONDEMAND_BLOCK,
                       &checkPresent,

Modified: GNUnet/src/include/ecrs_core.h
===================================================================
--- GNUnet/src/include/ecrs_core.h      2005-02-10 23:55:11 UTC (rev 233)
+++ GNUnet/src/include/ecrs_core.h      2005-02-11 00:37:17 UTC (rev 234)
@@ -170,7 +170,7 @@
  * Get the query that will be used to query for
  * a certain block of data.
  */
-void fileBlockGetQuery(const char * data,
+void fileBlockGetQuery(const DBlock * data,
                       unsigned int len,
                       HashCode160 * query);
 
@@ -179,7 +179,7 @@
  * Get the key that will be used to decrypt
  * a certain block of data.
  */
-void fileBlockGetKey(const char * data,
+void fileBlockGetKey(const DBlock * data,
                     unsigned int len,
                     HashCode160 * key);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]