gnunet-fuse

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

commit 49b0ca7160af463278e07a461b1084d579069c23
parent 8237e5c8e4559e732108bfed0298ef009a22dfc9
Author: David Barksdale <amatus.amongus@gmail.com>
Date:   Sat,  9 Jun 2007 05:02:04 +0000

Added .uri files which read the uri of the containing directory

Diffstat:
MChangeLog | 2++
MMakefile.am | 1+
Mconfigure.ac | 2+-
Mgetattr.c | 14++++++++++++++
Mgnfs.h | 7+++++++
Mopen.c | 10++++++++++
Mread.c | 24+++++++++++++++++++++++-
Mreaddir.c | 1+
8 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,5 @@ +2007-06-08 David Barksdale <amatus@gnu.org> 0.4 +* Added .uri files which read the uri of the containing directory 2007-05-30 David Barksdale <amatus@gnu.org> 0.3 * Added support for ECRS_downloadPartialFile (requires GNUnet > 0.7.1c) 2007-05-29 David Barksdale <amatus@gnu.org> 0.2 diff --git a/Makefile.am b/Makefile.am @@ -7,6 +7,7 @@ gnunet_fs_SOURCES = \ open.c \ read.c \ readdir.c \ + special_file.c \ gnfs.h \ gettext.h diff --git a/configure.ac b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(gnunet-fuse, 0.3) +AC_INIT(gnunet-fuse, 0.4) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) diff --git a/getattr.c b/getattr.c @@ -28,10 +28,24 @@ int gn_getattr(const char *path, struct stat *stbuf) { struct dirent *de; + char *special; GE_LOG(ectx, GE_BULK | GE_DEVELOPER | GE_DEBUG, "getattr for '%s'\n", path); + /* Check to see if this is a special file */ + special = gn_get_special_file(path); + if(special != NULL) + { + memset(stbuf, 0, sizeof(*stbuf)); + stbuf->st_mode = 0555 | S_IFREG; + stbuf->st_nlink = 1; + stbuf->st_size = strlen(special); + FREE(special); + return 0; + } + + /* Fill in dirent stat info */ de = gn_dirent_find(path); if(de == NULL) return -ENOENT; diff --git a/gnfs.h b/gnfs.h @@ -32,6 +32,9 @@ #define _(x) x #define STRERROR strerror +#define URI_FILE ".uri" +#define URI_LEN 4 + struct dirent { gchar *de_path; @@ -66,6 +69,7 @@ struct dirent *gn_dirent_find(const gchar *path); int gn_directory_for_each(struct dirent *de, gn_dir_for_each_callback cb, void *data); +/* FUSE function files */ int gn_getattr(const char *path, struct stat *stbuf); int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi); @@ -73,4 +77,7 @@ 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); +/* special_file.c */ +char *gn_get_special_file(const char *path); + #endif /* _GNFS_H_ */ diff --git a/open.c b/open.c @@ -27,10 +27,20 @@ int gn_open(const char *path, struct fuse_file_info *fi) { struct dirent *de; + char *special; (void)fi; GE_LOG(ectx, GE_BULK | GE_DEVELOPER | GE_DEBUG, "open for '%s'\n", path); + + /* Check for special file */ + special = gn_get_special_file(path); + if(special != NULL) + { + FREE(special); + return 0; + } + de = gn_dirent_find(path); if(de == NULL) { diff --git a/read.c b/read.c @@ -74,13 +74,35 @@ int gn_read(const char *path, char *buf, size_t size, off_t offset, { struct dirent *de; struct read_data d; - int ret; + char *special; + int ret, slen; guint64 len; (void)fi; GE_LOG(ectx, GE_BULK | GE_DEVELOPER | GE_DEBUG, "read '%s' %d bytes\n", path, size); + + /* Check for special file */ + special = gn_get_special_file(path); + if(special != NULL) + { + slen = strlen(special); + if(offset >= slen) + { + FREE(special); + return 0; + } + if(offset + size > slen) + { + size = slen - offset; + } + memcpy(buf, special + offset, size); + FREE(special); + return size; + } + + /* Lookup dirent for path */ de = gn_dirent_find(path); if(de == NULL) { diff --git a/readdir.c b/readdir.c @@ -81,6 +81,7 @@ int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler, } filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); + filler(buf, URI_FILE, NULL, 0); d.filler = filler; d.buf = buf; ret = gn_directory_for_each(de, readdir_callback, &d);