[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20793 - gnunet-fuse/src/ext
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20793 - gnunet-fuse/src/ext |
Date: |
Wed, 28 Mar 2012 10:09:39 +0200 |
Author: mauricio
Date: 2012-03-28 10:09:39 +0200 (Wed, 28 Mar 2012)
New Revision: 20793
Modified:
gnunet-fuse/src/ext/gnunet-fuse.c
gnunet-fuse/src/ext/gnunet-fuse.h
gnunet-fuse/src/ext/readdir.c
Log:
-changes
Modified: gnunet-fuse/src/ext/gnunet-fuse.c
===================================================================
--- gnunet-fuse/src/ext/gnunet-fuse.c 2012-03-28 07:28:13 UTC (rev 20792)
+++ gnunet-fuse/src/ext/gnunet-fuse.c 2012-03-28 08:09:39 UTC (rev 20793)
@@ -33,7 +33,6 @@
#include <gnunet/gnunet_container_lib.h>
#include <gnunet/gnunet_crypto_lib.h>
-//struct GNUNET_CONTAINER_MultiHashMap *map;
static int ret;
@@ -83,6 +82,40 @@
};
+struct GNUNET_FUSE_path_info *
+create_path_info (const char *path, const struct GNUNET_FS_Uri *uri)
+{
+ struct GNUNET_FUSE_path_info * pi;
+
+ 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);
+
+ return pi;
+}
+
+void
+delete_path_info (struct GNUNET_FUSE_path_info *pi)
+{
+ GNUNET_free (pi->path);
+ // FIX free uri
+ GNUNET_free (pi);
+}
+
+int cleanup_path_info (void *cls,
+ const GNUNET_HashCode * key,
+ void *value)
+{
+ struct GNUNET_FUSE_path_info *pi = value;
+
+ delete_path_info (pi);
+}
+
+
/**
* Main function that will be run by the scheduler.
*
@@ -98,7 +131,10 @@
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
int argc;
+ struct GNUNET_FUSE_path_info *pi;
+ struct GNUNET_FS_Uri *uri;
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);
@@ -138,17 +174,24 @@
a[3] = "-f";
a[4] = "-d";
}
+ /* create MultiHashMap */
+ map = GNUNET_CONTAINER_multihashmap_create (10);
+ GNUNET_HashCode path_hash;
+ char * path = "/";
+ GNUNET_CRYPTO_hash (path, strlen (path), &path_hash);
-/* create MultiHashMap */
-unsigned int len = strlen(directory);
+ /* new path */
+ // FIX parse source string to uri
+ pi = create_path_info (path, uri);
+ GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(map,
&path_hash, pi, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-struct GNUNET_CONTAINER_MultiHashMap *map;
-map = GNUNET_CONTAINER_multihashmap_create (len);
+ /* main function of fuse */
+ fuse_main(argc, a, &fops, NULL);
+ GNUNET_CONTAINER_multihashmap_iterate(map, &cleanup_path_info, NULL);
-/* main function of fuse */
- fuse_main(argc, a, &fops, NULL);
+ GNUNET_CONTAINER_multihashmap_destroy(map);
}
/**
Modified: gnunet-fuse/src/ext/gnunet-fuse.h
===================================================================
--- gnunet-fuse/src/ext/gnunet-fuse.h 2012-03-28 07:28:13 UTC (rev 20792)
+++ gnunet-fuse/src/ext/gnunet-fuse.h 2012-03-28 08:09:39 UTC (rev 20793)
@@ -44,26 +44,30 @@
static char *source;
static char *directory;
+struct GNUNET_CONTAINER_MultiHashMap *map;
-
/* struct containing mapped Path, with URI and other Information like
Attributes etc. */
struct GNUNET_FUSE_path_info
{
/* uri to corresponding path */
- char* source;
+ struct GNUNET_FS_Uri *uri;
/* pathname */
char* path;
-/* key */
- GNUNET_HashCode hash;
+
/*name of temporary file */
char* tmpfile;
/*file attributes*/
struct stat;
};
+struct GNUNET_FUSE_path_info *
+create_path_info (path, uri);
+void
+delet_path_info (struct GNUNET_FUSE_path_info *pi);
+
/* FUSE function files */
int gn_getattr(const char *path, struct stat *stbuf);
int gn_mknod(const char *path, mode_t mode, dev_t rdev);
Modified: gnunet-fuse/src/ext/readdir.c
===================================================================
--- gnunet-fuse/src/ext/readdir.c 2012-03-28 07:28:13 UTC (rev 20792)
+++ gnunet-fuse/src/ext/readdir.c 2012-03-28 08:09:39 UTC (rev 20793)
@@ -72,8 +72,13 @@
struct GNUNET_FS_Uri *uri;
+char *emsg;
+struct GNUNET_FUSE_path_info *r;
+
+
+
static void
cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
@@ -170,7 +175,7 @@
const struct GNUNET_SCHEDULER_TaskContext*
tc)
{
- char *emsg;
+
enum GNUNET_FS_DownloadOptions options;
@@ -206,7 +211,7 @@
options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY;
struct GNUNET_FS_DownloadContext* dc;
- dc = GNUNET_FS_download_start (fs, uri, NULL, w->tmpfile, NULL, 0,
+ dc = GNUNET_FS_download_start (fs, uri, NULL, r->tmpfile, NULL, 0,
GNUNET_FS_uri_chk_get_file_size(uri),
anonymity,
options, NULL, NULL);
@@ -226,29 +231,52 @@
int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
-
+ struct GNUNET_FUSE_path_info * path_info = NULL;
+ printf("FUSE PATH gives me: `%s'\n", path);
(void) fi;
(void) offset;
- struct GNUNET_FUSE_path_info *r;
+
+ GNUNET_HashCode path_hash;
+ GNUNET_CRYPTO_hash (path, strlen (path), &path_hash);
+ 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));
+ }
+ else
+ {
+ /* existing path */
+ path_info = GNUNET_CONTAINER_multihashmap_get (map, &path_hash);
+ }
+
+ GNUNET_assert (path_info != NULL);
+
+#if 0
+ r = GNUNET_malloc (sizeof (struct GNUNET_FUSE_path_info));
+
int len = strlen(path);
int exist = 0;
+ r->path = path;
- r = GNUNET_malloc (sizeof (struct GNUNET_FUSE_path_info));
+ /* compute key */
- exist = GNUNET_CONTAINER_multihashmap_contains (map, r->hash,);
- if ( exist == GNUNET_NO)
+ GNUNET_CRYPTO_hash (r->path, len, r->hash);
-/* compute key */
- GNUNET_CRYPTO_hash (r->path, len, r->hash);
+ exist = GNUNET_CONTAINER_multihashmap_contains (map, r->hash);
+ if ( exist == GNUNET_NO)
+ {
+
+
/* Store a key-value pair in the map */
- GNUNET_CONTAINER_multihashmap_put (map, directory, source,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ GNUNET_CONTAINER_multihashmap_put (map, r->hash, r->path,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
/* store to temporary file */
r->tmpfile = GNUNET_DISK_mktemp("gnunet-fuse-tempfile");
/* find value with given key */
- r->source = GNUNET_CONTAINER_multihashmap_get (map, r->path);
+ r->source = GNUNET_CONTAINER_multihashmap_get (map, r->hash);
/* parse uri from given source */
uri = GNUNET_FS_uri_parse(r->source, &emsg);
@@ -258,7 +286,22 @@
filler(buf, "..", NULL, 0);
return 0;
+ }
+ else
+ {
+ uri = GNUNET_FS_uri_parse(r->source, &emsg);
+ GNUNET_SCHEDULER_run(&readdir_task, NULL);
+
+ filler(buf, ".", NULL, 0);
+ filler(buf, "..", NULL, 0);
+ return 0;
+ }
+#endif
+
+ filler(buf, ".", NULL, 0);
+ filler(buf, "..", NULL, 0);
+ return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20793 - gnunet-fuse/src/ext,
gnunet <=