gnunet-fuse

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

commit 877d2f9f81060ae5df224528a0a290fa369c3aae
parent 50e740d331cf5aabba4ab8be25bae9c366d7909c
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Mon,  9 Dec 2024 17:31:32 +0100

v0.23.0

Diffstat:
Mconfigure.ac | 2+-
Msrc/fuse/gnunet-fuse.c | 168++++++++++++++++++++++++++++++++++++++++---------------------------------------
2 files changed, 87 insertions(+), 83 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -20,7 +20,7 @@ # Process this file with autoconf to produce a configure script. # AC_PREREQ([2.71]) -AC_INIT([gnunet-fuse],[0.22.0],[bug-gnunet@gnu.org]) +AC_INIT([gnunet-fuse],[0.23.0],[bug-gnunet@gnu.org]) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(gnunet_fuse_config.h) diff --git a/src/fuse/gnunet-fuse.c b/src/fuse/gnunet-fuse.c @@ -81,13 +81,13 @@ static struct GNUNET_FUSE_PathInfo *root; */ static void process_directory_entry (void *cls, - const char *filename, - const struct GNUNET_FS_Uri * - uri, - const struct - GNUNET_FS_MetaData * - meta, size_t length, - const void *data) + const char *filename, + const struct GNUNET_FS_Uri * + uri, + const struct + GNUNET_FS_MetaData * + meta, size_t length, + const void *data) { struct GNUNET_FUSE_PathInfo *parent = cls; struct GNUNET_FUSE_PathInfo *pi; @@ -96,9 +96,9 @@ process_directory_entry (void *cls, if (NULL == filename) return; /* info about the directory itself */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding file `%s' to directory `%s'\n", - filename, - parent->filename); + "Adding file `%s' to directory `%s'\n", + filename, + parent->filename); is_directory = GNUNET_FS_meta_data_test_for_directory (meta); if (GNUNET_SYSERR == is_directory) is_directory = GNUNET_NO; /* if in doubt, say no */ @@ -116,7 +116,7 @@ process_directory_entry (void *cls, */ int GNUNET_FUSE_load_directory (struct GNUNET_FUSE_PathInfo *pi, - int * eno) + int *eno) { size_t size; void *data; @@ -125,12 +125,13 @@ GNUNET_FUSE_load_directory (struct GNUNET_FUSE_PathInfo *pi, /* Need to download directory; store to temporary file */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Downloading directory `%s'\n", - pi->filename); + "Downloading directory `%s'\n", + pi->filename); pi->tmpfile = GNUNET_DISK_mktemp ("gnunet-fuse-tempfile"); if (GNUNET_OK != GNUNET_FUSE_download_file (pi, - 0, - GNUNET_FS_uri_chk_get_file_size (pi->uri))) + 0, + GNUNET_FS_uri_chk_get_file_size ( + pi->uri))) { unlink (pi->tmpfile); GNUNET_free (pi->tmpfile); @@ -141,28 +142,28 @@ GNUNET_FUSE_load_directory (struct GNUNET_FUSE_PathInfo *pi, size = (size_t) GNUNET_FS_uri_chk_get_file_size (pi->uri); fh = GNUNET_DISK_file_open (pi->tmpfile, - GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE); + GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); if (NULL == fh) { *eno = EIO; return GNUNET_SYSERR; } data = GNUNET_DISK_file_map (fh, - &mh, - GNUNET_DISK_MAP_TYPE_READ, - size); + &mh, + GNUNET_DISK_MAP_TYPE_READ, + size); if (NULL == data) { GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); - return - ENOMEM; + return -ENOMEM; } *eno = 0; if (GNUNET_OK != GNUNET_FS_directory_list_contents (size, - data, 0LL, - &process_directory_entry, - pi)) + data, 0LL, + &process_directory_entry, + pi)) *eno = ENOTDIR; GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_unmap (mh)); GNUNET_DISK_file_close (fh); @@ -181,7 +182,7 @@ GNUNET_FUSE_load_directory (struct GNUNET_FUSE_PathInfo *pi, */ struct GNUNET_FUSE_PathInfo * GNUNET_FUSE_path_info_get (const char *path, - int *eno) + int *eno) { size_t slen = strlen (path) + 1; char buf[slen]; @@ -192,41 +193,41 @@ GNUNET_FUSE_path_info_get (const char *path, memcpy (buf, path, slen); pi = root; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Looking up path `%s'\n", - path); + "Looking up path `%s'\n", + path); GNUNET_mutex_lock (pi->lock); for (tok = strtok (buf, "/"); NULL != tok; tok = strtok (NULL, "/")) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Searching for token `%s'\n", - tok); + "Searching for token `%s'\n", + tok); if (NULL == pi->tmpfile) { if (GNUNET_OK != GNUNET_FUSE_load_directory (pi, eno)) { - GNUNET_mutex_unlock (pi->lock); - return NULL; + GNUNET_mutex_unlock (pi->lock); + return NULL; } } pos = pi->child_head; while ( (NULL != pos) && - (0 != strcmp (tok, - pos->filename)) ) + (0 != strcmp (tok, + pos->filename)) ) pos = pos->next; if (NULL == pos) { GNUNET_mutex_unlock (pi->lock); *eno = ENOENT; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "No file with name `%s' in directory `%s'\n", - tok, - pi->filename); + "No file with name `%s' in directory `%s'\n", + tok, + pi->filename); return NULL; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Descending into directory `%s'\n", - tok); + "Descending into directory `%s'\n", + tok); GNUNET_mutex_lock (pos->lock); GNUNET_mutex_unlock (pi->lock); pi = pos; @@ -250,9 +251,9 @@ GNUNET_FUSE_path_info_get (const char *path, */ struct GNUNET_FUSE_PathInfo * GNUNET_FUSE_path_info_create (struct GNUNET_FUSE_PathInfo *parent, - const char *filename, - const struct GNUNET_FS_Uri *uri, - int is_directory) + const char *filename, + const struct GNUNET_FS_Uri *uri, + int is_directory) { struct GNUNET_FUSE_PathInfo *pi; size_t len; @@ -285,8 +286,8 @@ GNUNET_FUSE_path_info_create (struct GNUNET_FUSE_PathInfo *parent, if (NULL != parent) { GNUNET_CONTAINER_DLL_insert_tail (parent->child_head, - parent->child_tail, - pi); + parent->child_tail, + pi); GNUNET_mutex_unlock (parent->lock); } return pi; @@ -332,14 +333,14 @@ GNUNET_FUSE_path_info_delete (struct GNUNET_FUSE_PathInfo *pi) GNUNET_mutex_lock (parent->lock); GNUNET_mutex_lock (pi->lock); GNUNET_CONTAINER_DLL_remove (parent->child_head, - parent->child_tail, - pi); + parent->child_tail, + pi); pi->parent = NULL; GNUNET_mutex_unlock (parent->lock); } else { - ret = - ENOENT; + ret = -ENOENT; GNUNET_mutex_lock (pi->lock); } rc = --pi->rc; @@ -419,31 +420,32 @@ run (void *cls, cfg = c; ret = 0; if (NULL == source) - { - fprintf (stderr, _("`%s' option for URI missing\n"), "-s"); - ret = 1; - return; - } + { + 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; - } + { + 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; - } + { + fprintf (stderr, "%s\n", emsg); + GNUNET_free (emsg); + ret = 3; + return; + } if ( (GNUNET_YES != GNUNET_FS_uri_test_chk (uri)) && (GNUNET_YES != GNUNET_FS_uri_test_loc (uri)) ) { fprintf (stderr, - _("The given URI is not for a directory and can thus not be mounted\n")); + _ ( + "The given URI is not for a directory and can thus not be mounted\n")); ret = 4; GNUNET_FS_uri_destroy (uri); return; @@ -454,9 +456,9 @@ run (void *cls, GNUNET_FUSE_load_directory (root, &eno)) { fprintf (stderr, - _("Failed to mount `%s': %s\n"), - source, - strerror (eno)); + _ ("Failed to mount `%s': %s\n"), + source, + strerror (eno)); ret = 5; cleanup_path_info (root); GNUNET_FS_uri_destroy (uri); @@ -473,11 +475,11 @@ run (void *cls, a[0] = "gnunet-fuse"; a[1] = directory; if (GNUNET_YES == single_threaded) - { - a[2] = "-s"; - a[3] = "-f"; - a[4] = "-d"; - } + { + a[2] = "-s"; + a[3] = "-f"; + a[4] = "-d"; + } a[argc] = NULL; fuse_main (argc, a, &fops, NULL); } @@ -515,18 +517,20 @@ main (int argc, char *const *argv) }; GNUNET_log_setup ("gnunet-fuse", - "DEBUG", - NULL); + "DEBUG", + NULL); return (GNUNET_OK == - GNUNET_PROGRAM_run2 (argc, - argv, - "gnunet-fuse -s URI [-- FUSE-OPTIONS] DIRECTORYNAME", - gettext_noop - ("fuse"), - options, - &run, - NULL, - GNUNET_YES)) ? ret : 1; + GNUNET_PROGRAM_run2 (GNUNET_OS_project_data_gnunet (), + argc, + argv, + "gnunet-fuse -s URI [-- FUSE-OPTIONS] DIRECTORYNAME", + gettext_noop + ("fuse"), + options, + &run, + NULL, + GNUNET_YES)) ? ret : 1; } + /* end of gnunet-fuse.c */