[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21745 - in gnunet-fuse: po src/fuse
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21745 - in gnunet-fuse: po src/fuse |
Date: |
Sun, 3 Jun 2012 19:46:23 +0200 |
Author: grothoff
Date: 2012-06-03 19:46:22 +0200 (Sun, 03 Jun 2012)
New Revision: 21745
Modified:
gnunet-fuse/po/POTFILES.in
gnunet-fuse/src/fuse/Makefile.am
gnunet-fuse/src/fuse/gnunet-fuse.c
gnunet-fuse/src/fuse/gnunet-fuse.h
gnunet-fuse/src/fuse/read.c
gnunet-fuse/src/fuse/readdir.c
Log:
-making code compile
Modified: gnunet-fuse/po/POTFILES.in
===================================================================
--- gnunet-fuse/po/POTFILES.in 2012-06-03 16:37:12 UTC (rev 21744)
+++ gnunet-fuse/po/POTFILES.in 2012-06-03 17:46:22 UTC (rev 21745)
@@ -1,2 +1,2 @@
# List of source files which contain translatable strings.
-src/ext/gnunet-ext.c
+src/fuse/gnunet-fuse.c
Modified: gnunet-fuse/src/fuse/Makefile.am
===================================================================
--- gnunet-fuse/src/fuse/Makefile.am 2012-06-03 16:37:12 UTC (rev 21744)
+++ gnunet-fuse/src/fuse/Makefile.am 2012-06-03 17:46:22 UTC (rev 21745)
@@ -27,7 +27,7 @@
-lgnunetutil \
-lfuse \
-lgnunetfs \
- $(INTLLIBS)
+ $(INTLLIBS) $(GNUNET_LIBS)
gnunet_fuse_CPPFLAGS = \
-D_FILE_OFFSET_BITS=64 \
-DFUSE_USE_VERSION=26
Modified: gnunet-fuse/src/fuse/gnunet-fuse.c
===================================================================
--- gnunet-fuse/src/fuse/gnunet-fuse.c 2012-06-03 16:37:12 UTC (rev 21744)
+++ gnunet-fuse/src/fuse/gnunet-fuse.c 2012-06-03 17:46:22 UTC (rev 21745)
@@ -1,128 +1,102 @@
/*
- This file is part of GNUnet.
- (C)
+ This file is part of gnunet-fuse.
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ 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
+ as published by the Free Software Foundation.
+
+ gnunet-fuse is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
*/
/**
* @file fuse/gnunet-fuse.c
* @brief fuse tool
- * @author
+ * @author Christian Grothoff
+ * @author Mauricio Günther
*/
-
-#define FUSE_USE_VERSION 26
-#define TESTING GNUNET_YES
#include "gnunet-fuse.h"
-#include <gnunet/gnunet_container_lib.h>
-#include <gnunet/gnunet_crypto_lib.h>
+
+/**
+ * Return code from 'main' (0 on success).
+ */
static int ret;
+/**
+ * Flag to determine if we should run in single-threaded mode.
+ */
+static int single_threaded;
+/**
+ * Mounted URI (as string).
+ */
+static char *source;
-/* Context for the command. */
-struct CommandContext
-{
- /* Argv argument. */
- char *const *args;
+/**
+ * Mount point.
+ */
+static char *directory;
- /* Name of the configuration file used, can be NULL! */
- char *cfgfile;
+/**
+ * Global mapping of paths to GNUnet URIs (and file names) for
+ * the respective entries.
+ */
+struct GNUNET_CONTAINER_MultiHashMap *map;
- /* Main function to run. */
- GNUNET_PROGRAM_Main task;
- /* Closure for task. */
- void *task_cls;
-
- /* Configuration to use. */
- const struct GNUNET_CONFIGURATION_Handle *cfg;
-};
-
-
-
-// calling fuse operations
-
-/*struct with renamed fuseoperations*/
-static struct fuse_operations fops = {
-
- // .mkdir = gn_mkdir,
- // .mknod = gn_mknod,
- // .release = gn_release,
- // .rename = gn_rename,
- // .rmdir = gn_rmdir,
- // .truncate = gn_truncate,
- // .unlink = gn_unlink,
- // .utimens = gn_utimens,
- // .write = gn_write,
- .getattr = gn_getattr,
- .readdir = gn_readdir,
- .open = gn_open,
- .read = gn_read,
-};
-
-
-
-
-struct GNUNET_FUSE_path_info *
+struct GNUNET_FUSE_PathInfo *
create_path_info (const char *path, const struct GNUNET_FS_Uri *uri)
{
- struct GNUNET_FUSE_path_info * pi;
+ struct GNUNET_FUSE_PathInfo * 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);
- pi->uri = GNUNET_FS_uri_dup(uri);
-
- return pi;
-
+ pi = GNUNET_malloc (sizeof (struct GNUNET_FUSE_PathInfo));
+ pi->path = GNUNET_strdup (path);
+ pi->uri = GNUNET_FS_uri_dup(uri);
+ return pi;
}
+
void
-delete_path_info (struct GNUNET_FUSE_path_info *pi)
+delete_path_info (struct GNUNET_FUSE_PathInfo *pi)
{
- /* free path */
- GNUNET_free (pi->path);
+ GNUNET_free (pi->path);
+ GNUNET_FS_uri_destroy (pi->uri);
+ GNUNET_free (pi);
- /* free uri */
- GNUNET_FS_uri_destroy (pi->uri);
-
- /* free pi */
- GNUNET_free (pi);
}
-int cleanup_path_info (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+
+/**
+ * Called on each entry in our global 'map' to clean it up.
+ *
+ * @param cls closure, NULL
+ * @param key current key code
+ * @param value value in the hash map, a 'struct GNUNET_FUSE_PathInfo'
+ * @return GNUNET_YES (we should continue to iterate)
+ */
+static int
+cleanup_path_info (void *cls,
+ const GNUNET_HashCode * key,
+ void *value)
{
- struct GNUNET_FUSE_path_info *pi = value;
+ struct GNUNET_FUSE_PathInfo *pi = value;
- delete_path_info (pi);
- return 0;
+ delete_path_info (pi);
+ return GNUNET_YES;
}
-
-
/**
- * Main function that will be run by the scheduler.
+ * Main function that will be run (without the scheduler!)
*
* @param cls closure
* @param args remaining command-line arguments
@@ -135,100 +109,90 @@
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- int argc;
- struct GNUNET_FUSE_path_info *pi;
- const struct GNUNET_FS_Uri *uri;
- char *emsg;
+ static struct fuse_operations fops = {
+ // .mkdir = gn_mkdir,
+ // .mknod = gn_mknod,
+ // .release = gn_release,
+ // .rename = gn_rename,
+ // .rmdir = gn_rmdir,
+ // .truncate = gn_truncate,
+ // .unlink = gn_unlink,
+ // .utimens = gn_utimens,
+ // .write = gn_write,
+ .getattr = gn_getattr,
+ .readdir = gn_readdir,
+ .open = gn_open,
+ .read = gn_read
+ };
- ret = 0;
+ int argc;
+ struct GNUNET_FUSE_PathInfo *pi;
+ struct GNUNET_FS_Uri *uri;
+ char *emsg;
+ GNUNET_HashCode path_hash;
+ const char *path = "/";
+
+ ret = 0;
+ if (NULL == source)
+ {
+ fprintf(stderr,
+ _("`%s' option for URI missing\n"),
+ "-s");
+ ret = 1;
+ return;
+ }
+ if (NULL == directory)
+ {
+ fprintf(stderr,
+ _("`%s' option for mountpoint missing\n"),
+ "-d");
+ ret = 2;
+ return;
+ }
+ /* parse source string to uri */
+ if (NULL == (uri = GNUNET_FS_uri_parse(source, &emsg)))
+ {
+ fprintf(stderr,
+ "%s\n", emsg);
+ GNUNET_free (emsg);
+ ret = 3;
+ return;
+ }
- if (NULL == source)
- {
- printf("\n-s option for URI missing\n\n");
- ret = 1;
- return;
- }
+ map = GNUNET_CONTAINER_multihashmap_create (10);
+ GNUNET_CRYPTO_hash (path, strlen (path), &path_hash);
+ pi = create_path_info (path, uri);
+ GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(map,
+ &path_hash, pi,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- if (NULL == directory)
- {
- printf("\n-d option for mountpoint missing\n\n");
- ret = 2;
- return;
- }
-/* checking for muti- or singlethreading */
-
- if (GNUNET_YES == TESTING)
- {
- argc = 5;
- }
- else
- {
- argc = 2;
- }
- char *a[argc];
- a[0]="gnunet-fuse";
- a[1]= directory;
- if (GNUNET_YES == TESTING)
- {
- a[2] = "-s";
- a[3] = "-f";
- a[4] = "-d";
- }
-
-
- /* 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 = "/" ;
-
- /* create hashkey */
- GNUNET_CRYPTO_hash (path, strlen (path), &path_hash);
-
- /* new path */
-
- /* 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);
+ if (GNUNET_YES == single_threaded)
+ argc = 5;
+ else
+ argc = 2;
+ {
+ char *a[argc+1];
+ a[0]="gnunet-fuse";
+ a[1]= directory;
+ if (GNUNET_YES == single_threaded)
+ {
+ a[2] = "-s";
+ a[3] = "-f";
+ a[4] = "-d";
+ }
+ a[argc] = NULL;
+ fuse_main(argc, a, &fops, NULL);
+ }
+ GNUNET_CONTAINER_multihashmap_iterate(map, &cleanup_path_info, NULL);
+ GNUNET_CONTAINER_multihashmap_destroy(map);
+ GNUNET_FS_uri_destroy (uri);
}
+
/**
- * The main function to fuse.
+ * The main function for gnunet-fuse.
*
* @param argc number of arguments from the command line
* @param argv command line arguments
@@ -236,19 +200,19 @@
*/
int
main (int argc, char *const *argv)
-{
-
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'s', "source", "URI",
- gettext_noop ("Source you get the URI from"), 1,
- &GNUNET_GETOPT_set_string, &source},
- {'d', "directory", "PATH",
- gettext_noop ("path to your mountpoint"), 1,
- &GNUNET_GETOPT_set_string, &directory},
- GNUNET_GETOPT_OPTION_END };
-
-
-
+{
+ static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ {'s', "source", "URI",
+ gettext_noop ("Source you get the URI from"), 1,
+ &GNUNET_GETOPT_set_string, &source},
+ {'d', "directory", "PATH",
+ gettext_noop ("path to your mountpoint"), 1,
+ &GNUNET_GETOPT_set_string, &directory},
+ {'t', "single-threaded", NULL,
+ gettext_noop ("run in single-threaded mode"), 0,
+ &GNUNET_GETOPT_set_one, &single_threaded},
+ GNUNET_GETOPT_OPTION_END
+ };
return (GNUNET_OK ==
GNUNET_PROGRAM_run2(argc,
argv,
Modified: gnunet-fuse/src/fuse/gnunet-fuse.h
===================================================================
--- gnunet-fuse/src/fuse/gnunet-fuse.h 2012-06-03 16:37:12 UTC (rev 21744)
+++ gnunet-fuse/src/fuse/gnunet-fuse.h 2012-06-03 17:46:22 UTC (rev 21745)
@@ -1,93 +1,112 @@
/*
- * gnfs.h - types and stuff
- *
- * Created on: Mar 16, 2012
- * Author: Mauricio Günther
- *
- *
- *
- *
- * This file is part of gnunet-fuse.
- *
- * 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
- * as published by the Free Software Foundation.
- *
- * gnunet-fuse is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ This file is part of gnunet-fuse.
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ 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
+ as published by the Free Software Foundation.
+
+ gnunet-fuse is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+/**
+ * @file fuse/gnunet-fuse.h
+ * @brief global definitions for gnunet-fuse
+ * @author Christian Grothoff
+ * @author Mauricio Günther
*/
+#ifndef GNUNET_FUSE_H
+#define GNUNET_FUSE_H
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_directories.h>
+#include <gnunet/gnunet_resolver_service.h>
+#include <gnunet/gnunet_fs_service.h>
-#ifndef GNUNETFUSE_H_
-#define GNUNETFUSE_H_
-
-#include <gnunet/platform.h>
-#include "gnunet/gnunet_common.h"
-#include "gnunet/gnunet_configuration_lib.h"
-#include "gnunet/gnunet_crypto_lib.h"
-#include "gnunet/gnunet_directories.h"
-#include "gnunet/gnunet_getopt_lib.h"
-#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"
+#define FUSE_USE_VERSION 26
#include <fuse.h>
+/**
+ * Global mapping of paths to GNUnet URIs (and file names) for
+ * the respective entries.
+ */
+extern struct GNUNET_CONTAINER_MultiHashMap *map;
-/* Variables from commandline for gnunet-fuse */
-char *source;
-char *directory;
-struct GNUNET_CONTAINER_MultiHashMap *map;
+/**
+ * struct containing mapped Path, with URI and other Information like
Attributes etc.
+ */
+struct GNUNET_FUSE_PathInfo
+{
+ /**
+ * uri to corresponding path
+ */
+ struct GNUNET_FS_Uri *uri;
+ /**
+ * pathname
+ */
+ char* path;
-/* struct containing mapped Path, with URI and other Information like
Attributes etc. */
-
-struct GNUNET_FUSE_path_info
-{
-/* uri to corresponding path */
- 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*/
- struct stat;
+ /**
+ * name of temporary file
+ */
+ char* tmpfile;
+
+ /**
+ * file attributes
+ */
+ struct stat attributes;
};
-struct GNUNET_FUSE_path_info *
+
+struct GNUNET_FUSE_PathInfo *
create_path_info (const char *path, const struct GNUNET_FS_Uri *uri);
+
void
-delete_path_info (struct GNUNET_FUSE_path_info *pi);
+delete_path_info (struct GNUNET_FUSE_PathInfo *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);
+
int gn_mkdir(const char *path, mode_t mode);
+
int gn_unlink(const char *path);
+
int gn_rmdir(const char *path);
+
int gn_rename(const char *from, const char *to);
+
int gn_truncate(const char *path, off_t size);
+
int gn_open(const char *path, struct fuse_file_info *fi);
+
int gn_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi);
+
int gn_write(const char *path, const char *buf, size_t size, off_t offset,
struct fuse_file_info *fi);
+
int gn_release(const char *path, struct fuse_file_info *fi);
+
int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi);
+
int gn_utimens(const char *path, const struct timespec ts[2]);
-#endif /* GNUNETFUSE_H_ */
+#endif
+/* GNUNET_FUSE_H */
Modified: gnunet-fuse/src/fuse/read.c
===================================================================
--- gnunet-fuse/src/fuse/read.c 2012-06-03 16:37:12 UTC (rev 21744)
+++ gnunet-fuse/src/fuse/read.c 2012-06-03 17:46:22 UTC (rev 21745)
@@ -17,11 +17,7 @@
* Changed in version 2.2
*/
-//#include <string.h>
-//#include <errno.h>
-#include <unistd.h>
-#include <fuse.h>
-#include <gnunet-fuse.h>
+#include "gnunet-fuse.h"
@@ -71,6 +67,7 @@
else return -ENOENT;
*/
+ return -ENOENT;
}
Modified: gnunet-fuse/src/fuse/readdir.c
===================================================================
--- gnunet-fuse/src/fuse/readdir.c 2012-06-03 16:37:12 UTC (rev 21744)
+++ gnunet-fuse/src/fuse/readdir.c 2012-06-03 17:46:22 UTC (rev 21745)
@@ -27,15 +27,7 @@
* Introduced in version 2.3
*/
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.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>
+#include "gnunet-fuse.h"
static int ret;
@@ -67,7 +59,7 @@
char *emsg;
-struct GNUNET_FUSE_path_info *r;
+struct GNUNET_FUSE_PathInfo *r;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21745 - in gnunet-fuse: po src/fuse,
gnunet <=