gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20799 - gnunet-fuse/src/ext


From: gnunet
Subject: [GNUnet-SVN] r20799 - gnunet-fuse/src/ext
Date: Wed, 28 Mar 2012 16:20:59 +0200

Author: mauricio
Date: 2012-03-28 16:20:59 +0200 (Wed, 28 Mar 2012)
New Revision: 20799

Modified:
   gnunet-fuse/src/ext/gnunet-fuse.c
   gnunet-fuse/src/ext/gnunet-fuse.h
   gnunet-fuse/src/ext/readdir.c
Log:
working changes
his line, and those below, will be ignored--

M    ext/gnunet-fuse.c
M    ext/gnunet-fuse.h
M    ext/readdir.c


Modified: gnunet-fuse/src/ext/gnunet-fuse.c
===================================================================
--- gnunet-fuse/src/ext/gnunet-fuse.c   2012-03-28 12:42:34 UTC (rev 20798)
+++ gnunet-fuse/src/ext/gnunet-fuse.c   2012-03-28 14:20:59 UTC (rev 20799)
@@ -26,20 +26,14 @@
 
 #define FUSE_USE_VERSION 26
 #define TESTING GNUNET_YES
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file 
(kind, "util", syscall, filename)
-
 #include "gnunet-fuse.h"
 #include <gnunet/gnunet_container_lib.h>
 #include <gnunet/gnunet_crypto_lib.h>
 
-
 static int ret;
 
 
 
-
-
 /* Context for the command. */
 struct CommandContext
 {
@@ -82,27 +76,35 @@
 };
 
 
+
+
 struct GNUNET_FUSE_path_info *
 create_path_info (const char *path, const struct GNUNET_FS_Uri *uri)
 {
        struct GNUNET_FUSE_path_info * pi;
 
+       /* check if path or uri are NULL, if yes, abort */
        GNUNET_assert (NULL != path);
        GNUNET_assert (NULL != uri);
 
        pi = GNUNET_malloc (sizeof (struct GNUNET_FUSE_path_info));
        pi->path = strdup (path);
-       //FIX
-       //pi->source = strdup (uri);
+       pi->uri = GNUNET_FS_uri_dup(uri);
 
        return pi;
+
 }
 
 void
 delete_path_info (struct GNUNET_FUSE_path_info *pi)
 {
+       /* free path */
        GNUNET_free (pi->path);
-       // FIX free uri
+
+       /* free uri */
+       GNUNET_FS_uri_destroy (pi->uri);
+
+       /* free pi */
        GNUNET_free (pi);
 }
 
@@ -113,9 +115,12 @@
        struct GNUNET_FUSE_path_info *pi = value;
 
        delete_path_info (pi);
+       return 0;
 }
 
 
+
+
 /**
  * Main function that will be run by the scheduler.
  *
@@ -132,31 +137,28 @@
 {
        int argc;
        struct GNUNET_FUSE_path_info *pi;
-       struct GNUNET_FS_Uri *uri;
+       const struct GNUNET_FS_Uri *uri;
+       char *emsg;
+
        ret = 0;
 
-       //char * test= GNUNET_malloc(500);
-       //GNUNET_free (test);
-       //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR\n-d option for mountpoint 
required %s\n", test);
 
        if (NULL == source)
                {
-                       printf("ERROR\n-s option for URI missing\n");
+                       printf("\n-s option for URI missing\n\n");
                        ret = 1;
                        return;
                }
 
        if (NULL == directory)
        {
-               printf("ERROR\n-d option for mountpoint missing\n");
+               printf("\n-d option for mountpoint missing\n\n");
                ret = 2;
                return;
        }
 
-       printf("%s\n", directory);
 /* checking for muti- or singlethreading */
 
-
        if (GNUNET_YES == TESTING)
        {
                argc = 5;
@@ -174,23 +176,54 @@
           a[3] = "-f";
           a[4] = "-d";
        }
-       /* create MultiHashMap */
+
+
+       /* parse source string to uri */
+               uri = GNUNET_FS_uri_parse(source, &emsg);
+
+       /* check if uri is valid entry */
+       if (NULL == uri)
+               {
+                       printf("\n%s\n\n", emsg);
+                       ret = 3;
+                       return;
+               }
+
+
+
+       /* create MultiHashMap, setting len arbitrarily to 10 */
        map = GNUNET_CONTAINER_multihashmap_create (10);
 
        GNUNET_HashCode path_hash;
-       char * path = "/";
+       char*path = "/" ;
+
+       /* create hashkey */
        GNUNET_CRYPTO_hash (path, strlen (path), &path_hash);
 
        /* new path */
-       // FIX parse source string to uri
+
+       /* print content of variable source, just for personal interest */
+       printf("%s\n", source);
+
+       /*check if content of uri isn't NULL, otherwise call abort... */
+       GNUNET_assert (NULL != uri);
+
+       /** Mapping path and uri. Store it in struct pi.
+        * fuse gives us "/" as default.
+        */
        pi = create_path_info (path, uri);
+
+       /* after having used uri, you must free it */
+       GNUNET_FS_uri_destroy (uri);
+
+       /* check if your put was successfull */
        GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(map, 
&path_hash, pi, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
 
        /* main function of fuse */
        fuse_main(argc, a, &fops, NULL);
 
+       /* after fuse operations iterate and destroy multihashmap map */
        GNUNET_CONTAINER_multihashmap_iterate(map, &cleanup_path_info, NULL);
-
        GNUNET_CONTAINER_multihashmap_destroy(map);
 }
 
@@ -219,7 +252,7 @@
   return (GNUNET_OK ==
           GNUNET_PROGRAM_run2(argc,
                               argv,
-                              "gnunet-fuse -s URI [-- FUSE-OPTIONS] 
DIRECTORYNAME", //"gnunet-fuse [options [value]]",
+                              "gnunet-fuse -s URI [-- FUSE-OPTIONS] 
DIRECTORYNAME",
                               gettext_noop
                               ("fuse"),
                               options, &run, NULL, GNUNET_YES)) ? ret : 1;

Modified: gnunet-fuse/src/ext/gnunet-fuse.h
===================================================================
--- gnunet-fuse/src/ext/gnunet-fuse.h   2012-03-28 12:42:34 UTC (rev 20798)
+++ gnunet-fuse/src/ext/gnunet-fuse.h   2012-03-28 14:20:59 UTC (rev 20799)
@@ -2,10 +2,11 @@
  * gnfs.h - types and stuff
  *
  *  Created on: Mar 16, 2012
- *      Author: mg
+ *      Author: Mauricio Günther
  *
  *
  *
+ *
  * This file is part of gnunet-fuse.
  *
  * gnunet-fuse is free software; you can redistribute it and/or
@@ -35,6 +36,7 @@
 #include "gnunet/gnunet_os_lib.h"
 #include "gnunet/gnunet_program_lib.h"
 #include "gnunet/gnunet_resolver_service.h"
+#include "gnunet/gnunet_fs_service.h"
 #include "gnunet/gnunet_scheduler_lib.h"
 #include <fuse.h>
 
@@ -42,8 +44,8 @@
 
 /* Variables from commandline for gnunet-fuse */
 
-static char *source;
-static char *directory;
+char *source;
+char *directory;
 struct GNUNET_CONTAINER_MultiHashMap *map;
 
 
@@ -52,10 +54,11 @@
 struct GNUNET_FUSE_path_info
 {
 /* uri to corresponding path */
-       struct GNUNET_FS_Uri *uri;
+       const struct GNUNET_FS_Uri *uri;
 /* pathname */
        char* path;
-
+/* source to corresponding path, needs to be parsed to uri */
+       char* source;
 /*name of temporary file */
        char* tmpfile;
 /*file attributes*/
@@ -63,10 +66,10 @@
 };
 
 struct GNUNET_FUSE_path_info *
-create_path_info (path, uri);
+create_path_info (const char *path, const struct GNUNET_FS_Uri *uri);
 
 void
-delet_path_info (struct GNUNET_FUSE_path_info *pi);
+delete_path_info (struct GNUNET_FUSE_path_info *pi);
 
 /* FUSE function files */
 int gn_getattr(const char *path, struct stat *stbuf);

Modified: gnunet-fuse/src/ext/readdir.c
===================================================================
--- gnunet-fuse/src/ext/readdir.c       2012-03-28 12:42:34 UTC (rev 20798)
+++ gnunet-fuse/src/ext/readdir.c       2012-03-28 14:20:59 UTC (rev 20799)
@@ -2,7 +2,7 @@
  * reddir.c - FUSE read directory function
  *
  *  Created on: Mar 14, 2012
- *      Author: mg, Christian Grothoff, Matthias Wachs,
+ *      Author: MG, Christian Grothoff, Matthias Wachs,
  *                     Krista Bennett, James Blackwell, Igor Wronsky
  *
  * Read directory
@@ -27,22 +27,15 @@
  * Introduced in version 2.3
  */
 
-//#include <string.h>
-//#include <errno.h>
-//#include <glib.h>
-//#include <GNUnet/gnunet_ecrs_lib.h>
-
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <unistd.h>
-
-#include <fuse.h>
-
 #include <gnunet-fuse.h>
 #include <gnunet/gnunet_fs_service.h>
 #include <gnunet/gnunet_container_lib.h>
 #include "gnunet/gnunet_crypto_lib.h"
+#include <fuse.h>
 
 static int ret;
 
@@ -174,14 +167,8 @@
 void readdir_task (void *cls,
                                   const struct GNUNET_SCHEDULER_TaskContext* 
tc)
 {
-
-
        enum GNUNET_FS_DownloadOptions options;
 
-
-
-
-
        if (NULL == uri)
        {
          FPRINTF (stderr, _("Failed to parse URI: %s\n"), emsg);
@@ -238,11 +225,12 @@
 
        GNUNET_HashCode path_hash;
        GNUNET_CRYPTO_hash (path, strlen (path), &path_hash);
+       /* NOTE: Path can be like /.Trash/1000/files for the trash directory */
        if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(map, 
&path_hash))
        {
                /* new path */
-               path_info = create_path_info (path, NULL);
-               GNUNET_assert (GNUNET_OK == 
GNUNET_CONTAINER_multihashmap_put(map, &path_hash, path_info, 
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+               //path_info = create_path_info (path, NULL);
+               //GNUNET_assert (GNUNET_OK == 
GNUNET_CONTAINER_multihashmap_put(map, &path_hash, path_info, 
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
        }
        else
        {
@@ -250,7 +238,7 @@
            path_info = GNUNET_CONTAINER_multihashmap_get (map, &path_hash);
        }
 
-       GNUNET_assert (path_info != NULL);
+       //GNUNET_assert (path_info != NULL);
 
 #if 0
        r = GNUNET_malloc (sizeof (struct GNUNET_FUSE_path_info));
@@ -303,16 +291,3 @@
        filler(buf, "..", NULL, 0);
        return 0;
 }
-
-
-
-
-
-
-
-
-
-
-
-
-




reply via email to

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