aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-07-07 15:25:41 +0200
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-07-08 12:48:08 +0200
commite870a0427adb50a64dc8bcbacfacb089872c6908 (patch)
tree454e310cc66d048ee2e45493b6abaafcb80d1749 /lib
parent79b446d22ce8cfb387549bef2a0ddcaf6fbb3331 (diff)
Added public fuse_lib_help(), bumped minor version
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am4
-rw-r--r--lib/fuse.c125
-rw-r--r--lib/fuse_misc.h11
-rw-r--r--lib/fuse_versionscript6
-rw-r--r--lib/helper.c12
-rw-r--r--lib/meson.build6
6 files changed, 111 insertions, 53 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 2ed8b5f..5631f75 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
AM_CPPFLAGS = -I$(top_srcdir)/include -DFUSERMOUNT_DIR=\"$(bindir)\" \
- -D_REENTRANT -DFUSE_USE_VERSION=30
+ -D_REENTRANT -DFUSE_USE_VERSION=31
lib_LTLIBRARIES = libfuse3.la
@@ -33,7 +33,7 @@ libfuse3_la_SOURCES = \
$(iconv_source) \
$(mount_source)
-libfuse3_la_LDFLAGS = -pthread @libfuse_libs@ -version-number 3:0:2 \
+libfuse3_la_LDFLAGS = -pthread @libfuse_libs@ -version-number 3:1:0 \
-Wl,--version-script,$(srcdir)/fuse_versionscript
if NETBSD
diff --git a/lib/fuse.c b/lib/fuse.c
index d7a7c82..ce29819 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -4400,8 +4400,6 @@ int fuse_interrupted(void)
#define FUSE_LIB_OPT(t, p, v) { t, offsetof(struct fuse_config, p), v }
static const struct fuse_opt fuse_lib_opts[] = {
- FUSE_LIB_OPT("-h", show_help, 1),
- FUSE_LIB_OPT("--help", show_help, 1),
FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP),
FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP),
FUSE_LIB_OPT("debug", debug, 1),
@@ -4426,7 +4424,34 @@ static const struct fuse_opt fuse_lib_opts[] = {
FUSE_OPT_END
};
-static void fuse_lib_help(void)
+static int fuse_lib_opt_proc(void *data, const char *arg, int key,
+ struct fuse_args *outargs)
+{
+ (void) arg; (void) outargs; (void) data; (void) key;
+
+ /* Pass through unknown options */
+ return 1;
+}
+
+
+static const struct fuse_opt fuse_help_opts[] = {
+ FUSE_LIB_OPT("modules=%s", modules, 1),
+ FUSE_OPT_KEY("modules=%s", FUSE_OPT_KEY_KEEP),
+ FUSE_OPT_END
+};
+
+static void print_module_help(const char *name,
+ fuse_module_factory_t *fac)
+{
+ struct fuse_args a = FUSE_ARGS_INIT(0, NULL);
+ if (fuse_opt_add_arg(&a, "") == -1 ||
+ fuse_opt_add_arg(&a, "-h") == -1)
+ return;
+ printf("\nOptions for %s module:\n", name);
+ (*fac)(&a, NULL);
+}
+
+void fuse_lib_help(struct fuse_args *args)
{
/* These are not all options, but only the ones that
may be of interest to an end-user */
@@ -4443,37 +4468,42 @@ static void fuse_lib_help(void)
" -o noforget never forget cached inodes\n"
" -o remember=T remember cached inodes for T seconds (0s)\n"
" -o modules=M1[:M2...] names of modules to push onto filesystem stack\n");
-}
-static void fuse_lib_help_modules(void)
-{
+
+ /* Print low-level help */
+ fuse_lowlevel_help();
+
+ /* Print help for builtin modules */
+ print_module_help("subdir", &fuse_module_subdir_factory);
+ print_module_help("iconv", &fuse_module_iconv_factory);
+
+ /* Parse command line options in case we need to
+ activate more modules */
+ struct fuse_config conf = { .modules = NULL };
+ if (fuse_opt_parse(args, &conf, fuse_help_opts,
+ fuse_lib_opt_proc) == -1
+ || !conf.modules)
+ return;
+
+ char *module;
+ char *next;
struct fuse_module *m;
- printf("\nModule options:\n");
- pthread_mutex_lock(&fuse_context_lock);
- for (m = fuse_modules; m; m = m->next) {
- struct fuse_fs *fs = NULL;
- struct fuse_fs *newfs;
- struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
- if (fuse_opt_add_arg(&args, "") != -1 &&
- fuse_opt_add_arg(&args, "-h") != -1) {
- printf("\n[%s]\n", m->name);
- newfs = m->factory(&args, &fs);
- assert(newfs == NULL);
- }
- fuse_opt_free_args(&args);
- }
- pthread_mutex_unlock(&fuse_context_lock);
-}
-static int fuse_lib_opt_proc(void *data, const char *arg, int key,
- struct fuse_args *outargs)
-{
- (void) arg; (void) outargs; (void) data; (void) key;
+ // Iterate over all modules
+ for (module = conf.modules; module; module = next) {
+ char *p;
+ for (p = module; *p && *p != ':'; p++);
+ next = *p ? p + 1 : NULL;
+ *p = '\0';
- /* Pass through unknown options */
- return 1;
+ m = fuse_get_module(module);
+ if (m)
+ print_module_help(module, &m->factory);
+ }
}
+
+
static int fuse_init_intr_signal(int signum, int *installed)
{
struct sigaction old_sa;
@@ -4595,6 +4625,33 @@ void fuse_stop_cleanup_thread(struct fuse *f)
}
}
+
+/* Emulates 3.0-style fuse_new(), which processes
+ --help */
+FUSE_SYMVER(".symver fuse_new_30,fuse_new@FUSE_3.0");
+FUSE_SYMVER(".symver fuse_new,fuse_new@@FUSE_3.1");
+struct fuse *fuse_new_30(struct fuse_args *args,
+ const struct fuse_operations *op,
+ size_t op_size, void *user_data)
+{
+ struct fuse_config conf;
+ const struct fuse_opt opts[] = {
+ FUSE_LIB_OPT("-h", show_help, 1),
+ FUSE_LIB_OPT("--help", show_help, 1),
+ FUSE_OPT_END
+ };
+
+ if (fuse_opt_parse(args, &conf, opts,
+ fuse_lib_opt_proc) == -1)
+ return NULL;
+
+ if (conf.show_help) {
+ fuse_lib_help(args);
+ return NULL;
+ } else
+ return fuse_new(args, op, op_size, user_data);
+}
+
struct fuse *fuse_new(struct fuse_args *args,
const struct fuse_operations *op,
size_t op_size, void *user_data)
@@ -4620,13 +4677,6 @@ struct fuse *fuse_new(struct fuse_args *args,
fuse_lib_opt_proc) == -1)
goto out_free;
- if (f->conf.show_help) {
- fuse_lib_help();
- fuse_lowlevel_help();
- /* Defer printing module help until modules
- have been loaded */
- }
-
pthread_mutex_lock(&fuse_context_lock);
static int builtin_modules_registered = 0;
/* Have the builtin modules already been registered? */
@@ -4673,11 +4723,6 @@ struct fuse *fuse_new(struct fuse_args *args,
}
}
- if(f->conf.show_help) {
- fuse_lib_help_modules();
- goto out_free_fs;
- }
-
if (!f->conf.ac_attr_timeout_set)
f->conf.ac_attr_timeout = f->conf.attr_timeout;
diff --git a/lib/fuse_misc.h b/lib/fuse_misc.h
index 1839a67..2f6663e 100644
--- a/lib/fuse_misc.h
+++ b/lib/fuse_misc.h
@@ -8,6 +8,17 @@
#include <pthread.h>
+/*
+ Versioned symbols cannot be used in some cases because it
+ - confuse the dynamic linker in uClibc
+ - not supported on MacOSX (in MachO binary format)
+*/
+#if (!defined(__UCLIBC__) && !defined(__APPLE__))
+#define FUSE_SYMVER(x) __asm__(x)
+#else
+#define FUSE_SYMVER(x)
+#endif
+
#ifndef USE_UCLIBC
#define fuse_mutex_init(mut) pthread_mutex_init(mut, NULL)
#else
diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript
index 164e254..5fa3264 100644
--- a/lib/fuse_versionscript
+++ b/lib/fuse_versionscript
@@ -132,6 +132,12 @@ FUSE_3.0 {
*;
};
+FUSE_3.1 {
+ global:
+ fuse_lib_help;
+ fuse_new_30;
+} FUSE_3.0;
+
# Local Variables:
# indent-tabs-mode: t
# End:
diff --git a/lib/helper.c b/lib/helper.c
index 31640b6..5032b68 100644
--- a/lib/helper.c
+++ b/lib/helper.c
@@ -272,18 +272,15 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
goto out1;
}
- /* Re-add --help for later processing by fuse_new()
- (that way we also get help for modules options) */
if (opts.show_help) {
if(args.argv[0] != '\0')
printf("usage: %s [options] <mountpoint>\n\n",
args.argv[0]);
printf("FUSE options:\n");
fuse_cmdline_help();
- if (fuse_opt_add_arg(&args, "--help") == -1) {
- res = 1;
- goto out1;
- }
+ fuse_lib_help(&args);
+ res = 0;
+ goto out1;
}
if (!opts.show_help &&
@@ -294,10 +291,9 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
}
- /* --help is processed here and will result in NULL */
fuse = fuse_new(&args, op, op_size, user_data);
if (fuse == NULL) {
- res = opts.show_help ? 0 : 1;
+ res = 1;
goto out1;
}
diff --git a/lib/meson.build b/lib/meson.build
index 9997187..1cfface 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -25,11 +25,11 @@ if host_machine.system().startswith('netbsd')
endif
fusermount_path = join_paths(get_option('prefix'), get_option('bindir'))
-libfuse = library('fuse3', libfuse_sources, version: '3.0.0', install: true,
+libfuse = library('fuse3', libfuse_sources, version: meson.project_version(),
soversion: '3', include_directories: include_dirs,
- dependencies: deps,
+ dependencies: deps, install: true,
link_depends: 'fuse_versionscript',
- c_args: [ '-DFUSE_USE_VERSION=30',
+ c_args: [ '-DFUSE_USE_VERSION=31',
'-DFUSERMOUNT_DIR="{}"'.format(fusermount_path) ],
link_args: ['-Wl,--version-script,' + meson.current_source_dir()
+ '/fuse_versionscript' ])