gnunet-fuse

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

commit 72b3524cf9bfb7f55e4416d2a068a93372117d8d
parent c7f3b7128015f609f0fe8f67e70bc61c90bf91d0
Author: Mauricio Günther <mauricio@140774ce-b5e7-0310-ab8b-a85725594a96>
Date:   Tue, 20 Mar 2012 15:27:38 +0000

-changes


Diffstat:
Msrc/ext/getattr.c | 102++++++++++++++------------------------------------------------------------------
Msrc/ext/gnunet-fuse.c | 4++++
Msrc/ext/open.c | 60+-----------------------------------------------------------
Msrc/ext/read.c | 134+++++--------------------------------------------------------------------------
Msrc/ext/readdir.c | 89+++----------------------------------------------------------------------------
5 files changed, 33 insertions(+), 356 deletions(-)

diff --git a/src/ext/getattr.c b/src/ext/getattr.c @@ -20,16 +20,28 @@ int gn_getattr(const char *path, struct stat *stbuf) { - int ret = 0; + + + 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); + + + + + + + /* int ret = 0; //GNUNET_break (0); memset(stbuf, 0, sizeof(struct stat)); - if(strcmp(path, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount") == 0) + if(strcmp(path, "") == 0) { stbuf->st_mode = S_IFDIR | 0755; stbuf->st_nlink = 1; // changed from 2 } - +*/ /* else if(strcmp(path, directory) == 0) @@ -49,9 +61,9 @@ int gn_getattr(const char *path, struct stat *stbuf) */ - else return -ENOENT; +/* else return -ENOENT; - return ret; + return ret; */ @@ -59,83 +71,3 @@ int gn_getattr(const char *path, struct stat *stbuf) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/* -static const char *archive_path = "/"; -static const char *archive_str = "/Archive\n"; - -static const char *britney_path = "/Britney Spears"; -static const char *britney_str = "Britney Spears\n"; - -static const char *britney_br_path = "/Britney Spears/Britney"; -static const char *britney_br_str = "Britney\n"; - -static const char *b_br_1_path = "/Britney Spears/Britney/I'm a Slave 4 U"; - static const char *b_br_1_str = "3:23 U\n"; - - -int gn_getattr(const char *path, struct stat *stbuf) -{ - -int res = 0; - - memset(stbuf, 0, sizeof(struct stat)); - - if(strcmp(path, "/") == 0) { //attr. fuer parent vz - stbuf->st_mode = S_IFDIR | 0755; - stbuf->st_nlink = 3; - } - - else if(strcmp(path, britney_path) == 0) { //attr. fuer unterverzeichnis Britney - stbuf->st_mode = S_IFDIR | 0755; - stbuf->st_nlink = 3; - } - - else if(strcmp(path, britney_br_path) == 0) { //Attribute fuer UnterUnterverzeichnis Britney - stbuf->st_mode = S_IFDIR | 0755; - stbuf->st_nlink = 1; - - } - else if(strcmp(path, b_br_1_path) == 0 ){ //Songnummer 1 - stbuf->st_mode = S_IFREG | 0444; - stbuf->st_nlink = 1; - stbuf->st_size = strlen(b_br_1_str); - } - - else res = -ENOENT; - - return res; -} - -*/ diff --git a/src/ext/gnunet-fuse.c b/src/ext/gnunet-fuse.c @@ -111,6 +111,7 @@ run (void *cls, return; } + printf("%s\n", directory); /* checking for muti- or singlethreading */ if (GNUNET_YES == TESTING) @@ -152,6 +153,9 @@ main (int argc, char *const *argv) &GNUNET_GETOPT_set_string, &directory}, GNUNET_GETOPT_OPTION_END }; + + + return (GNUNET_OK == GNUNET_PROGRAM_run2(argc, argv, diff --git a/src/ext/open.c b/src/ext/open.c @@ -35,7 +35,7 @@ int gn_open(const char *path, struct fuse_file_info *fi) { - if (strcmp(path, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount") | strcmp(path, "/") == 0) + if (strcmp(path, "/home/mg/gnunet-fuse2/gnunet-fuse/src/ext/monti") == 0) return 0; else if ((fi->flags & 3) != O_RDONLY) @@ -48,61 +48,3 @@ int gn_open(const char *path, struct fuse_file_info *fi) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/* -static const char *archive_path = "/"; -static const char *archive_str = "/Archive\n"; - -static const char *britney_path = "/Britney Spears"; -static const char *britney_str = "Britney Spears\n"; - -static const char *britney_br_path = "/Britney Spears/Britney"; -static const char *britney_br_str = "Britney\n"; - -static const char *b_br_1_path = "/Britney Spears/Britney/I'm a Slave 4 U"; - static const char *b_br_1_str = "3:23 U\n"; - - - if((strcmp(path, archive_path) | strcmp(path, britney_path) | strcmp(path, britney_br_path))==0) - // return -ENOENT; - return 0; - - else if ( (fi->flags & 3) != O_RDONLY ) - return -EACCES; - - else return 0; - - - -*/ diff --git a/src/ext/read.c b/src/ext/read.c @@ -30,15 +30,19 @@ int gn_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { size_t len; - if (strcmp(path, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount") == 0) + +//until now read-function isn't used.... + + +/* if (strcmp(path, "") == 0) { - len = strlen("/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount"); + len = strlen(""); if (offset < len) { if (offset + size > len) size = len - offset; - memcpy(buf, "/" + offset, size); + memcpy(buf, "" + offset, size); } else size = 0; @@ -46,131 +50,9 @@ int gn_read(const char *path, char *buf, size_t size, off_t offset, return size; } - +*/ } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/* - * - * - -static const char *archive_path = "/"; -static const char *archive_str = "/Archive\n"; - -static const char *britney_path = "/Britney Spears"; -static const char *britney_str = "Britney Spears\n"; - -static const char *britney_br_path = "/Britney Spears/Britney"; -static const char *britney_br_str = "Britney\n"; - -static const char *b_br_1_path = "/Britney Spears/Britney/I'm a Slave 4 U"; - static const char *b_br_1_str = "3:23 U\n"; - - - - -size_t len; - (void) fi; - - - if (strcmp(path, archive_path) == 0) - { - len = strlen(archive_str); - if (offset < len) - { - if (offset + size > len) - size = len - offset; - memcpy(buf, archive_str + offset, size); - } - else - size = 0; - - return size; - } - - - else if(strcmp(path, britney_path) == 0) - { - len = strlen(britney_str); - if (offset < len) { - if (offset + size > len) - size = len - offset; - memcpy(buf, britney_str + offset, size); - } - else - size = 0; - - return size; - } - - else if(strcmp(path, britney_br_path) == 0) // ab hier das verzeichnis britney spears - { - len = strlen(britney_br_str); - if (offset < len) { - if (offset + size > len) - size = len - offset; - memcpy(buf, britney_br_str + offset, size); - } - else - size = 0; - - return size; - } - - else if(strcmp(path, b_br_1_path) == 0) // ab hier album Britney-Lied1 - { - len = strlen(b_br_1_str); - if (offset < len) - { - if (offset + size > len) - size = len - offset; - memcpy(buf, b_br_1_str + offset, size); - } - else - size = 0; - - return size; - } - else return -ENOENT; - -*/ diff --git a/src/ext/readdir.c b/src/ext/readdir.c @@ -51,47 +51,16 @@ int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler, //int len = strlen(directory); // GNUNET_asprintf(); - if (strcmp(path, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount") == 0) - { - filler(buf, ".", NULL, 0); - filler(buf, "..", NULL, 0); - filler(buf, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount"+1, NULL, 0); - return 0; - } - - /* - else if (strcmp(path, directory) == 0) // mounted directory with content - { filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); - filler(buf, track+len, NULL, 0); // path to directory mal - return 0; - } - - */ - - else return -ENOENT; - -} - - - - - - - - - - - - - - + //filler(buf, "/home/mg/gnunet-fuse2/gnunet-fuse/src/ext/monti"+1, NULL, 0); + //return 0; +} @@ -102,55 +71,3 @@ int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler, - - - -/* - -static const char *archive_path = "/"; -static const char *archive_str = "/Archive\n"; - -static const char *britney_path = "/Britney Spears"; -static const char *britney_str = "Britney Spears\n"; - -static const char *britney_br_path = "/Britney Spears/Britney"; -static const char *britney_br_str = "Britney\n"; - -static const char *b_br_1_path = "/Britney Spears/Britney/I'm a Slave 4 U"; - static const char *b_br_1_str = "3:23 U\n"; - - - -if(strcmp(path, "/") == 0) - { - filler(buf, ".", NULL, 0); - filler(buf, "..", NULL, 0); - - filler(buf, britney_path + 1, NULL, 0); - //filler(buf, metallica_path + 1, NULL, 0); - return 0; - } - - else if(strcmp(path, "/Britney Spears") == 0) - { - filler(buf, ".", NULL, 0); - filler(buf, "..", NULL, 0); - //filler(buf, britney_omt_path + 16, NULL, 0); - filler(buf, britney_br_path + 16, NULL, 0); - return 0; - } - - else if(strcmp(path, britney_br_path) == 0) // ab hier das album britney - { - filler(buf, ".", NULL, 0); - filler(buf, "..", NULL, 0); - filler(buf, b_br_1_path + 24 , NULL, 0); - - return 0; - } - - else return -ENOENT; - - - -*/