gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r20708 - gnunet-fuse/src/ext
Date: Fri, 23 Mar 2012 11:13:27 +0100

Author: mauricio
Date: 2012-03-23 11:13:27 +0100 (Fri, 23 Mar 2012)
New Revision: 20708

Modified:
   gnunet-fuse/src/ext/getattr.c
   gnunet-fuse/src/ext/gnunet-fuse.h
   gnunet-fuse/src/ext/open.c
   gnunet-fuse/src/ext/read.c
   gnunet-fuse/src/ext/readdir.c
Log:
-changes


Modified: gnunet-fuse/src/ext/getattr.c
===================================================================
--- gnunet-fuse/src/ext/getattr.c       2012-03-23 09:52:47 UTC (rev 20707)
+++ gnunet-fuse/src/ext/getattr.c       2012-03-23 10:13:27 UTC (rev 20708)
@@ -23,51 +23,14 @@
 
 
        memset(stbuf, 0, sizeof(*stbuf));
-               stbuf->st_mode = S_IFDIR | 0555;
-               stbuf->st_nlink = 1;
-       //      stbuf->st_size = GNUNET_ECRS_uri_get_file_size(de->de_fi.uri);
 
+       stbuf->st_mode = S_IFDIR | 0555;
+       stbuf->st_nlink = 1;
 
+       return 0;
 
 
 
-
-       /*      int ret = 0;
-       //GNUNET_break (0);
-       memset(stbuf, 0, sizeof(struct stat));
-
-       if(strcmp(path, "") == 0)
-       {
-       stbuf->st_mode = S_IFDIR | 0755;
-       stbuf->st_nlink = 1; // changed from 2
-       }
-*/
-
-       /*
-       else if(strcmp(path, directory) == 0)
-       {
-               stbuf->st_mode = S_IFDIR | 0755;
-               stbuf->st_nlink = 1;
-       }
-
-
-
-       else if(strcmp(path, "/probe/mal") == 0)
-       {
-               stbuf->st_mode = S_IFREG | 0444;
-                               stbuf->st_nlink = 1;
-                               stbuf->st_size = strlen("/probe/mal/inhalt");
-       }
-
-       */
-
-/*     else return -ENOENT;
-
-       return ret; */
-
-
-
-
 }
 
 

Modified: gnunet-fuse/src/ext/gnunet-fuse.h
===================================================================
--- gnunet-fuse/src/ext/gnunet-fuse.h   2012-03-23 09:52:47 UTC (rev 20707)
+++ gnunet-fuse/src/ext/gnunet-fuse.h   2012-03-23 10:13:27 UTC (rev 20708)
@@ -7,7 +7,6 @@
  *
  *
  * This file is part of gnunet-fuse.
- * Copyright (C) 2007 David Barksdale
  *
  * gnunet-fuse is free software; you can redistribute it and/or
  * modify if under the terms of version 2 of the GNU General Public License

Modified: gnunet-fuse/src/ext/open.c
===================================================================
--- gnunet-fuse/src/ext/open.c  2012-03-23 09:52:47 UTC (rev 20707)
+++ gnunet-fuse/src/ext/open.c  2012-03-23 10:13:27 UTC (rev 20708)
@@ -35,16 +35,20 @@
 {
 
 
-       if (strcmp(path, "/home/mg/gnunet-fuse2/gnunet-fuse/src/ext/monti") == 
0)
-               return 0;
+       //if (strcmp(path, "/home/mg/gnunet-fuse2/gnunet-fuse/src/ext/monti") 
== 0)
+       //      return 0;
+//
+//     else if ((fi->flags & 3) != O_RDONLY)
+//             return -EACCES;
 
-       else if ((fi->flags & 3) != O_RDONLY)
-               return -EACCES;
 
+//     else return 0;
 
-       else return 0;
 
+/*
+ * when user is allowed to open, return 0
+ */
+       return 0;
  }
 
 
-

Modified: gnunet-fuse/src/ext/read.c
===================================================================
--- gnunet-fuse/src/ext/read.c  2012-03-23 09:52:47 UTC (rev 20707)
+++ gnunet-fuse/src/ext/read.c  2012-03-23 10:13:27 UTC (rev 20708)
@@ -29,20 +29,37 @@
 int gn_read(const char *path, char *buf, size_t size, off_t offset,
                struct fuse_file_info *fi)
 {
+/*     (void) fi;
        size_t len;
 
 //until now read-function isn't used....
 
+if(strcmp(path, "/") == 0)
+{
+       len = strlen("/");
+       if (offset < len)
+         {
+         if (offset + size > len)
+            size = len - offset;
+         memcpy(buf, "/" + offset, size);
+       }
+       else
+         size = 0;
 
-/*     if (strcmp(path, "") == 0)
+       return size;
+ }
+
+
+if (strcmp(path, 
"/home/mg/gnunet-fuse2/gnunet-fuse/fuse/src/ext/monti/prueba") == 0)
        {
-               len = strlen("");
 
+       len = strlen("test");
+
                if (offset < len)
                {
                        if (offset + size > len)
                                size = len - offset;
-                               memcpy(buf, "" + offset, size);
+                               memcpy(buf, "test" + offset, size);
                }
                else
                        size = 0;
@@ -50,9 +67,10 @@
        return size;
        }
 
-*/
 
 
+else return -ENOENT;
+*/
 }
 
 

Modified: gnunet-fuse/src/ext/readdir.c
===================================================================
--- gnunet-fuse/src/ext/readdir.c       2012-03-23 09:52:47 UTC (rev 20707)
+++ gnunet-fuse/src/ext/readdir.c       2012-03-23 10:13:27 UTC (rev 20708)
@@ -2,7 +2,8 @@
  * reddir.c - FUSE read directory function
  *
  *  Created on: Mar 14, 2012
- *      Author: mg
+ *      Author: mg, Christian Grothoff, Matthias Wachs,
+ *                     Krista Bennett, James Blackwell, Igor Wronsky
  *
  * Read directory
  *
@@ -36,29 +37,193 @@
 #include <fuse.h>
 //#include <GNUnet/gnunet_ecrs_lib.h>
 #include <gnunet-fuse.h>
+#include <gnunet/gnunet_fs_service.h>
 
+static int ret;
 
+static int verbose;
 
+static int delete_incomplete;
 
+static struct GNUNET_FS_DownloadContext *dc;
 
+static unsigned int parallelism = 16;
+
+static unsigned int request_parallelism = 4092;
+
+static int do_recursive;
+
+static int local_only;
+
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+static unsigned int anonymity = 1;
+
+struct GNUNET_FS_Handle *fs;
+
+static struct GNUNET_FS_Handle *ctx;
+
+static void
+cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_FS_stop (ctx);
+  ctx = NULL;
+}
+
+static void
+shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_FS_DownloadContext *d;
+
+  if (dc != NULL)
+  {
+    d = dc;
+    dc = NULL;
+    GNUNET_FS_download_stop (d, delete_incomplete);
+  }
+}
+
+
+
+void *progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo * info)
+{
+
+       char *s;
+       char*s2;
+       char *t;
+
+       switch (info->status)
+       {
+       case GNUNET_FS_STATUS_DOWNLOAD_START:
+         if (verbose > 1)
+                 FPRINTF (stderr, _("Starting download `%s'.\n"),
+                              info->value.download.filename);
+         break;
+       case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
+         if (verbose)
+       {
+         s = GNUNET_STRINGS_relative_time_to_string (info->value.download.eta);
+         if 
(info->value.download.specifics.progress.block_download_duration.rel_value
+             == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
+            s2 = GNUNET_strdup (_("<unknown time>"));
+         else
+           s2 = GNUNET_STRINGS_relative_time_to_string (
+                
info->value.download.specifics.progress.block_download_duration);
+         t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed *
+                                                         1000LL /
+                                                         (info->value.download.
+                                                          duration.rel_value + 
1));
+         FPRINTF (stdout,
+                  _("Downloading `%s' at %llu/%llu (%s remaining, %s/s). Block 
took %s to download\n"),
+                  info->value.download.filename,
+                  (unsigned long long) info->value.download.completed,
+                  (unsigned long long) info->value.download.size, s, t, s2);
+        GNUNET_free (s);
+        GNUNET_free (s2);
+        GNUNET_free (t);
+       }
+       break;
+       case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
+       FPRINTF (stderr, _("Error downloading: %s.\n"),
+                info->value.download.specifics.error.message);
+       GNUNET_SCHEDULER_shutdown ();
+       break;
+       case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
+       s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 
1000 /
+                                           (info->value.download.
+                                            duration.rel_value + 1));
+       FPRINTF (stdout, _("Downloading `%s' done (%s/s).\n"),
+                info->value.download.filename, s);
+       GNUNET_free (s);
+       if (info->value.download.dc == dc)
+         GNUNET_SCHEDULER_shutdown ();
+       break;
+       case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
+         if (info->value.download.dc == dc)
+           GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL,
+                                              
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+         break;
+       case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
+       case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
+         break;
+       default:
+         FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
+         break;
+       }
+
+return NULL;
+}
+
+
+void readdir_task (void *cls,
+                                  const struct GNUNET_SCHEDULER_TaskContext* 
tc)
+{
+       struct GNUNET_FS_Uri *uri;
+       char *emsg;
+       enum GNUNET_FS_DownloadOptions options;
+       char* filename = GNUNET_DISK_mktemp(source);
+
+       uri = GNUNET_FS_uri_parse(source, &emsg);
+
+       if (NULL == uri)
+       {
+         FPRINTF (stderr, _("Failed to parse URI: %s\n"), emsg);
+         GNUNET_free (emsg);
+       }
+
+
+       fs = GNUNET_FS_start (cfg, "gnunet-fuse", &progress_cb, NULL,
+                                               GNUNET_FS_FLAGS_NONE,
+                                               
GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, parallelism,
+                                               
GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, request_parallelism,
+                                               GNUNET_FS_OPTIONS_END);
+
+       if (NULL == fs)
+         {
+           FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
+           GNUNET_FS_uri_destroy (uri);
+           ret = 1;
+           return;
+         }
+
+       options = GNUNET_FS_DOWNLOAD_OPTION_NONE;
+         if (do_recursive)
+           options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
+         if (local_only)
+           options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY;
+
+       struct GNUNET_FS_DownloadContext* dc;
+       dc = GNUNET_FS_download_start (fs, uri, NULL, filename, NULL, 0,
+                                                               
GNUNET_FS_uri_chk_get_file_size(uri),
+                                                               anonymity, 
options, NULL, NULL);
+
+       GNUNET_FS_uri_destroy (uri);
+       if (dc == NULL)
+       {
+       GNUNET_FS_stop (ctx);
+       ctx = NULL;
+       return;
+       }
+
+       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 
&shutdown_task, NULL);
+
+}
+
 int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
        off_t offset, struct fuse_file_info *fi)
 {
 
-       //char* track = "mal";
-       //char  var[strlen(directory)+strlen(track)+1];
-       //memcpy(var,directory,strlen(directory));
-       //int len = strlen(directory);
-// GNUNET_asprintf();
+       (void) fi;
+       (void) offset;
 
+//     GNUNET_SCHEDULER_run(readdir_task, NULL);
 
-               filler(buf, ".", NULL, 0);
-               filler(buf, "..", NULL, 0);
-       //filler(buf, "/home/mg/gnunet-fuse2/gnunet-fuse/src/ext/monti"+1, 
NULL, 0);
-               //return 0;
 
 
+       filler(buf, ".", NULL, 0);
+       filler(buf, "..", NULL, 0);
 
+       return 0;
 
 }
 
@@ -71,3 +236,6 @@
 
 
 
+
+
+




reply via email to

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