gnunet-fuse

GNUnet file-sharing directory mounting via FUSE
Log | Files | Refs | Submodules | README | LICENSE

commit 59ed22771b8e0818e049aecb00dfce2e554a5268
parent 1832dd9806b5d4ceacbe80baf2c10cd03cf8486d
Author: Mauricio Günther <mauricio@140774ce-b5e7-0310-ab8b-a85725594a96>
Date:   Fri, 16 Mar 2012 16:21:08 +0000

-working changes


Diffstat:
MINSTALL | 9++-------
Msrc/ext/Makefile.am | 20++++++--------------
Msrc/ext/gnunet-fuse.c | 197++++++++++++++++++++++++-------------------------------------------------------
3 files changed, 67 insertions(+), 159 deletions(-)

diff --git a/INSTALL b/INSTALL @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, -Inc. +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -226,11 +226,6 @@ order to use an ANSI C compiler: and if that doesn't work, install pre-built binaries of GCC for HP-UX. - HP-UX `make' updates targets which have the same time stamps as -their prerequisites, which makes it generally unusable when shipped -generated files such as `configure' are involved. Use GNU `make' -instead. - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `<wchar.h>' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended diff --git a/src/ext/Makefile.am b/src/ext/Makefile.am @@ -9,33 +9,25 @@ INCLUDES = \ bin_PROGRAMS = gnunet-fuse gnunet_fuse_SOURCES = \ - gnunet-fuse.c - directory.c \ - dirent.c \ - file.c \ - getattr.c \ mkdir.c \ + gnunet-fuse.c \ mknod.c \ - open.c \ - read.c \ - readdir.c \ release.c \ rename.c \ rmdir.c \ - special_file.c \ truncate.c \ unlink.c \ utimens.c \ write.c \ - gnfs.h \ - gettext.h + readdir.c \ + read.c \ + open.c \ + getattr.c gnunet_fuse_LDADD = \ -lgnunetutil \ -lfuse \ - -lgnunetfs + -lgnunetfs \ $(INTLLIBS) -gnunet_fuse_LDFLAGS = \ - -export-dynamic gnunet_fuse_CPPFLAGS = \ -D_FILE_OFFSET_BITS=64 \ -DFUSE_USE_VERSION=26 diff --git a/src/ext/gnunet-fuse.c b/src/ext/gnunet-fuse.c @@ -26,18 +26,17 @@ #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/platform.h> #include <gnunet/gnunet_util_lib.h> -#include <fuse.h> #include <gnunet/gnunet_fs_service.h> - - -static int ret; - -static char *source; -static char *directory; - +#include <sys/stat.h> +#include <string.h> +#include <errno.h> +#include <fuse.h> +#include <gnunet-fuse.h> #include "gnunet/gnunet_common.h" #include "gnunet/gnunet_configuration_lib.h" @@ -50,161 +49,79 @@ static char *directory; #include "gnunet/gnunet_scheduler_lib.h" #include <gcrypt.h> -#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) +static int ret; +static char *source; +static char *directory; -/** - * Context for the command. - */ +/* Context for the command. */ struct CommandContext { - /** - * Argv argument. - */ + /* Argv argument. */ char *const *args; - /** - * Name of the configuration file used, can be NULL! - */ + /* Name of the configuration file used, can be NULL! */ char *cfgfile; - /** - * Main function to run. - */ + /* Main function to run. */ GNUNET_PROGRAM_Main task; - /** - * Closure for task. - */ + /* Closure for task. */ void *task_cls; - /** - * Configuration to use. - */ + /* Configuration to use. */ const struct GNUNET_CONFIGURATION_Handle *cfg; - }; -/** - * Initial task called by the scheduler for each - * program. Runs the program-specific main task. - */ -static void -program_main (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct CommandContext *cc = cls; - GNUNET_RESOLVER_connect (cc->cfg); - cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); +// calling fuse operations +/* +int gn_open(const char *path, struct fuse_file_info *fi) +{ + return 0; } - -/** - * Compare function for 'qsort' to sort command-line arguments by the - * short option. - * - * @param a1 first command line option - * @param a2 second command line option - */ -static int -cmd_sorter (__const void *a1, __const void *a2) +int gn_read(const char *path, char *buf, size_t size, off_t offset, + struct fuse_file_info *fi) { - __const struct GNUNET_GETOPT_CommandLineOption *c1 = a1; - __const struct GNUNET_GETOPT_CommandLineOption *c2 = a2; - - if (toupper ((unsigned char) c1->shortName) > - toupper ((unsigned char) c2->shortName)) - return 1; - if (toupper ((unsigned char) c1->shortName) < - toupper ((unsigned char) c2->shortName)) - return -1; - if (c1->shortName > c2->shortName) - return 1; - if (c1->shortName < c2->shortName) - return -1; - return 0; + return -2; } - -/** - * Run a standard GNUnet command startup sequence (initialize loggers - * and configuration, parse options). - * - * @param argc number of command line arguments - * @param argv command line arguments - * @param binaryName our expected name - * @param binaryHelp help text for the program - * @param options command line options - * @param task main function to run - * @param task_cls closure for task - * @return GNUNET_SYSERR on error, GNUNET_OK on success - */ - - - - -#include <sys/stat.h> -#include <string.h> -#include <errno.h> -#include <fuse.h> -//#include "gnfs.h" - -static int ret; +int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler, + off_t offset, struct fuse_file_info *fi) +{ + return -2; +} 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]) -{}; - - +{ + return 0; +} +*/ /*struct with renamed fuseoperations*/ static struct fuse_operations fops = { - .getattr = gn_getattr, - .mknod = gn_mknod, + .mkdir = gn_mkdir, - .unlink = gn_unlink, - .rmdir = gn_rmdir, + .mknod = gn_mknod, + + + + .release = gn_release, .rename = gn_rename, + .rmdir = gn_rmdir, .truncate = gn_truncate, - .open = gn_open, - .read = gn_read, + .unlink = gn_unlink, + .utimens = gn_utimens, .write = gn_write, - .release = gn_release, + + .getattr = gn_getattr, .readdir = gn_readdir, - .utimens = gn_utimens, + .open = gn_open, + .read = gn_read, }; - - - - - /** * Main function that will be run by the scheduler. * @@ -221,19 +138,25 @@ run (void *cls, { int argc; ret = 0; - if (NULL == directory) - { - printf("ERROR\n-d option for mountpoint required\n"); - ret = 1; - return; - } + //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"); + ret = 1; + return; + } + + if (NULL == directory) { - printf("ERROR\n-s option for mountpoint required\n"); + printf("ERROR\n-d option for mountpoint missing\n"); ret = 2; return; } + if (GNUNET_YES == TESTING) { argc = 3; @@ -249,8 +172,6 @@ run (void *cls, { a[2] = "-s"; } - - fuse_main(argc, a, &fops, NULL); }