diff --git a/build/VStudio/installer/Product.wxs b/build/VStudio/installer/Product.wxs
index 5816f201..abada731 100644
--- a/build/VStudio/installer/Product.wxs
+++ b/build/VStudio/installer/Product.wxs
@@ -207,6 +207,9 @@
+
+
+
@@ -271,6 +274,7 @@
+
diff --git a/build/VStudio/winfsp_dll.vcxproj b/build/VStudio/winfsp_dll.vcxproj
index 3d79c16b..30711263 100644
--- a/build/VStudio/winfsp_dll.vcxproj
+++ b/build/VStudio/winfsp_dll.vcxproj
@@ -23,6 +23,7 @@
+
diff --git a/build/VStudio/winfsp_dll.vcxproj.filters b/build/VStudio/winfsp_dll.vcxproj.filters
index 416d74b9..619ad2d2 100644
--- a/build/VStudio/winfsp_dll.vcxproj.filters
+++ b/build/VStudio/winfsp_dll.vcxproj.filters
@@ -44,6 +44,9 @@
Include\fuse
+
+ Include\fuse
+
@@ -96,9 +99,6 @@
Source
-
- Source\fuse
-
@@ -108,4 +108,7 @@
Source
+
+
+
\ No newline at end of file
diff --git a/inc/fuse/fuse.h b/inc/fuse/fuse.h
index f3f191db..e8d30f36 100644
--- a/inc/fuse/fuse.h
+++ b/inc/fuse/fuse.h
@@ -102,61 +102,64 @@ struct fuse_context
#define fuse_main(argc, argv, ops, data)\
fuse_main_real(argc, argv, ops, sizeof *(ops), data)
-FSP_FUSE_API int fsp_fuse_main_real(int argc, char *argv[],
- const struct fuse_operations *ops, size_t opsize, void *data,
- int environment);
-FSP_FUSE_API int fsp_fuse_is_lib_option(const char *opt,
- FSP_FUSE_MEMFN_P);
-FSP_FUSE_API struct fuse *fsp_fuse_new(struct fuse_chan *ch, struct fuse_args *args,
- const struct fuse_operations *ops, size_t opsize, void *data,
- int environment);
-FSP_FUSE_API void fsp_fuse_destroy(struct fuse *f);
-FSP_FUSE_API int fsp_fuse_loop(struct fuse *f);
-FSP_FUSE_API int fsp_fuse_loop_mt(struct fuse *f);
-FSP_FUSE_API void fsp_fuse_exit(struct fuse *f);
-FSP_FUSE_API struct fuse_context *fsp_fuse_get_context(void);
+FSP_FUSE_API int fsp_fuse_main_real(struct fsp_fuse_env *env,
+ int argc, char *argv[],
+ const struct fuse_operations *ops, size_t opsize, void *data);
+FSP_FUSE_API int fsp_fuse_is_lib_option(struct fsp_fuse_env *env,
+ const char *opt);
+FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env,
+ struct fuse_chan *ch, struct fuse_args *args,
+ const struct fuse_operations *ops, size_t opsize, void *data);
+FSP_FUSE_API void fsp_fuse_destroy(struct fsp_fuse_env *env,
+ struct fuse *f);
+FSP_FUSE_API int fsp_fuse_loop(struct fsp_fuse_env *env,
+ struct fuse *f);
+FSP_FUSE_API int fsp_fuse_loop_mt(struct fsp_fuse_env *env,
+ struct fuse *f);
+FSP_FUSE_API void fsp_fuse_exit(struct fsp_fuse_env *env,
+ struct fuse *f);
+FSP_FUSE_API struct fuse_context *fsp_fuse_get_context(struct fsp_fuse_env *env);
static inline int fuse_main_real(int argc, char *argv[],
const struct fuse_operations *ops, size_t opsize, void *data)
{
- return fsp_fuse_main_real(argc, argv, ops, opsize, data, FSP_FUSE_ENVIRONMENT);
+ return fsp_fuse_main_real(fsp_fuse_env(), argc, argv, ops, opsize, data);
}
static inline int fuse_is_lib_option(const char *opt)
{
- return fsp_fuse_is_lib_option(opt,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_is_lib_option(fsp_fuse_env(), opt);
}
static inline struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
const struct fuse_operations *ops, size_t opsize, void *data)
{
- return fsp_fuse_new(ch, args, ops, opsize, data, FSP_FUSE_ENVIRONMENT);
+ return fsp_fuse_new(fsp_fuse_env(), ch, args, ops, opsize, data);
}
static inline void fuse_destroy(struct fuse *f)
{
- fsp_fuse_destroy(f);
+ fsp_fuse_destroy(fsp_fuse_env(), f);
}
static inline int fuse_loop(struct fuse *f)
{
- return fuse_loop(f);
+ return fsp_fuse_loop(fsp_fuse_env(), f);
}
static inline int fuse_loop_mt(struct fuse *f)
{
- return fsp_fuse_loop_mt(f);
+ return fsp_fuse_loop_mt(fsp_fuse_env(), f);
}
static inline void fuse_exit(struct fuse *f)
{
- fsp_fuse_exit(f);
+ fsp_fuse_exit(fsp_fuse_env(), f);
}
static inline struct fuse_context *fuse_get_context(void)
{
- return fsp_fuse_get_context();
+ return fsp_fuse_get_context(fsp_fuse_env());
}
static inline int fuse_getgroups(int size, fuse_gid_t list[])
diff --git a/inc/fuse/fuse_common.h b/inc/fuse/fuse_common.h
index 4aad6a19..e99b1a35 100644
--- a/inc/fuse/fuse_common.h
+++ b/inc/fuse/fuse_common.h
@@ -23,31 +23,13 @@
#ifndef FUSE_COMMON_H_
#define FUSE_COMMON_H_
-#include
+#include "winfsp_fuse.h"
#include "fuse_opt.h"
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(FSP_FUSE_API)
-#if defined(WINFSP_DLL_INTERNAL)
-#define FSP_FUSE_API __declspec(dllexport)
-#else
-#define FSP_FUSE_API __declspec(dllimport)
-#endif
-#endif
-
-#if !defined(FSP_FUSE_MEMFN_P)
-#define FSP_FUSE_MEMFN_P void *(*memalloc)(size_t), void (*memfree)(void *)
-#define FSP_FUSE_MEMFN_A memalloc, memfree
-#if defined(WINFSP_DLL_INTERNAL)
-#define FSP_FUSE_MEMFN_V MemAlloc, MemFree
-#else
-#define FSP_FUSE_MEMFN_V malloc, free
-#endif
-#endif
-
#define FUSE_MAJOR_VERSION 2
#define FUSE_MINOR_VERSION 8
#define FUSE_MAKE_VERSION(maj, min) ((maj) * 10 + (min))
@@ -65,108 +47,6 @@ extern "C" {
#define FUSE_IOCTL_RETRY (1 << 2)
#define FUSE_IOCTL_MAX_IOV 256
-/*
- * FUSE uses a number of types (notably: struct stat) that are OS specific.
- * Furthermore there are sometimes multiple definitions of the same type even
- * within the same OS. This is certainly true on Windows, where these types
- * are not even native.
- *
- * For this reason we will define our own fuse_* types which represent the
- * types as the WinFsp DLL expects to see them. When the file is included
- * by FUSE clients in different environments we will translate between their
- * understanding of the types and ours.
- */
-#if defined(_MSC_VER)
-typedef uint32_t fuse_uid_t;
-typedef uint32_t fuse_gid_t;
-typedef int32_t fuse_pid_t;
-
-typedef uint64_t fuse_dev_t;
-typedef uint64_t fuse_ino_t;
-typedef uint32_t fuse_mode_t;
-typedef uint32_t fuse_nlink_t;
-typedef int64_t fuse_off_t;
-
-typedef uint64_t fuse_fsblkcnt_t;
-typedef uint64_t fuse_fsfilcnt_t;
-typedef int32_t fuse_blksize_t;
-typedef int32_t fuse_blkcnt_t;
-
-struct fuse_timespec
-{
- time_t tv_sec;
- int tv_nsec;
-};
-
-struct fuse_stat
-{
- fuse_dev_t st_dev;
- fuse_ino_t st_ino;
- fuse_mode_t st_mode;
- fuse_nlink_t st_nlink;
- fuse_uid_t st_uid;
- fuse_gid_t st_gid;
- fuse_dev_t st_rdev;
- fuse_off_t st_size;
- struct fuse_timespec st_atim;
- struct fuse_timespec st_mtim;
- struct fuse_timespec st_ctim;
- fuse_blksize_t st_blksize;
- fuse_blkcnt_t st_blocks;
- struct fuse_timespec st_birthtim;
-};
-
-struct fuse_statvfs
-{
- unsigned int f_bsize;
- unsigned int f_frsize;
- fuse_fsblkcnt_t f_blocks;
- fuse_fsblkcnt_t f_bfree;
- fuse_fsblkcnt_t f_bavail;
- fuse_fsfilcnt_t f_files;
- fuse_fsfilcnt_t f_ffree;
- fuse_fsfilcnt_t f_favail;
- unsigned int f_fsid;
- unsigned int f_flag;
- unsigned int f_namemax;
-};
-
-#define FSP_FUSE_ENVIRONMENT 'W'
-
-#elif defined(__CYGWIN__)
-
-#include
-#include
-#include
-#include
-#include
-
-#define fuse_uid_t uid_t
-#define fuse_gid_t gid_t
-#define fuse_pid_t pid_t
-
-#define fuse_dev_t dev_t
-#define fuse_ino_t ino_t
-#define fuse_mode_t mode_t
-#define fuse_nlink_t nlink_t
-#define fuse_off_t off_t
-
-#define fuse_fsblkcnt_t fsblkcnt_t
-#define fuse_fsfilcnt_t fsfilcnt_t
-#define fuse_blksize_t blksize_t
-#define fuse_blkcnt_t blkcnt_t
-
-#define fuse_timespec timespec
-
-#define fuse_stat stat
-#define fuse_statvfs statvfs
-
-#define FSP_FUSE_ENVIRONMENT 'C'
-
-#else
-#error unsupported environment
-#endif
-
struct fuse_file_info
{
int flags;
@@ -197,33 +77,34 @@ struct fuse_session;
struct fuse_chan;
struct fuse_pollhandle;
-FSP_FUSE_API int fsp_fuse_version(void);
-FSP_FUSE_API struct fuse_chan *fsp_fuse_mount(const char *mountpoint, struct fuse_args *args);
-FSP_FUSE_API void fsp_fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
-FSP_FUSE_API int fsp_fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
- int *multithreaded, int *foreground,
- FSP_FUSE_MEMFN_P);
+FSP_FUSE_API int fsp_fuse_version(struct fsp_fuse_env *env);
+FSP_FUSE_API struct fuse_chan *fsp_fuse_mount(struct fsp_fuse_env *env,
+ const char *mountpoint, struct fuse_args *args);
+FSP_FUSE_API void fsp_fuse_unmount(struct fsp_fuse_env *env,
+ const char *mountpoint, struct fuse_chan *ch);
+FSP_FUSE_API int fsp_fuse_parse_cmdline(struct fsp_fuse_env *env,
+ struct fuse_args *args, char **mountpoint,
+ int *multithreaded, int *foreground);
static inline int fuse_version(void)
{
- return fsp_fuse_version();
+ return fsp_fuse_version(fsp_fuse_env());
}
static inline struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
{
- return fsp_fuse_mount(mountpoint, args);
+ return fsp_fuse_mount(fsp_fuse_env(), mountpoint, args);
}
static inline void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
{
- fsp_fuse_unmount(mountpoint, ch);
+ fsp_fuse_unmount(fsp_fuse_env(), mountpoint, ch);
}
static inline int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
int *multithreaded, int *foreground)
{
- return fsp_fuse_parse_cmdline(args, mountpoint, multithreaded, foreground,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_parse_cmdline(fsp_fuse_env(), args, mountpoint, multithreaded, foreground);
}
static inline void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
diff --git a/inc/fuse/fuse_opt.h b/inc/fuse/fuse_opt.h
index 1882243f..ef98f246 100644
--- a/inc/fuse/fuse_opt.h
+++ b/inc/fuse/fuse_opt.h
@@ -23,32 +23,12 @@
#ifndef FUSE_OPT_H_
#define FUSE_OPT_H_
-#if !defined(WINFSP_DLL_INTERNAL)
-#include
-#endif
+#include "winfsp_fuse.h"
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(FSP_FUSE_API)
-#if defined(WINFSP_DLL_INTERNAL)
-#define FSP_FUSE_API __declspec(dllexport)
-#else
-#define FSP_FUSE_API __declspec(dllimport)
-#endif
-#endif
-
-#if !defined(FSP_FUSE_MEMFN_P)
-#define FSP_FUSE_MEMFN_P void *(*memalloc)(size_t), void (*memfree)(void *)
-#define FSP_FUSE_MEMFN_A memalloc, memfree
-#if defined(WINFSP_DLL_INTERNAL)
-#define FSP_FUSE_MEMFN_V MemAlloc, MemFree
-#else
-#define FSP_FUSE_MEMFN_V malloc, free
-#endif
-#endif
-
#define FUSE_OPT_KEY(templ, key) { templ, -1, key }
#define FUSE_OPT_END { NULL, 0, 0 }
@@ -76,63 +56,56 @@ struct fuse_args
typedef int (*fuse_opt_proc_t)(void *data, const char *arg, int key,
struct fuse_args *outargs);
-FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
- const struct fuse_opt opts[], fuse_opt_proc_t proc,
- FSP_FUSE_MEMFN_P);
-FSP_FUSE_API int fsp_fuse_opt_add_arg(struct fuse_args *args, const char *arg,
- FSP_FUSE_MEMFN_P);
-FSP_FUSE_API int fsp_fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg,
- FSP_FUSE_MEMFN_P);
-FSP_FUSE_API void fsp_fuse_opt_free_args(struct fuse_args *args,
- FSP_FUSE_MEMFN_P);
-FSP_FUSE_API int fsp_fuse_opt_add_opt(char **opts, const char *opt,
- FSP_FUSE_MEMFN_P);
-FSP_FUSE_API int fsp_fuse_opt_add_opt_escaped(char **opts, const char *opt,
- FSP_FUSE_MEMFN_P);
-FSP_FUSE_API int fsp_fuse_opt_match(const struct fuse_opt opts[], const char *opt,
- FSP_FUSE_MEMFN_P);
+FSP_FUSE_API int fsp_fuse_opt_parse(struct fsp_fuse_env *env,
+ struct fuse_args *args, void *data,
+ const struct fuse_opt opts[], fuse_opt_proc_t proc);
+FSP_FUSE_API int fsp_fuse_opt_add_arg(struct fsp_fuse_env *env,
+ struct fuse_args *args, const char *arg);
+FSP_FUSE_API int fsp_fuse_opt_insert_arg(struct fsp_fuse_env *env,
+ struct fuse_args *args, int pos, const char *arg);
+FSP_FUSE_API void fsp_fuse_opt_free_args(struct fsp_fuse_env *env,
+ struct fuse_args *args);
+FSP_FUSE_API int fsp_fuse_opt_add_opt(struct fsp_fuse_env *env,
+ char **opts, const char *opt);
+FSP_FUSE_API int fsp_fuse_opt_add_opt_escaped(struct fsp_fuse_env *env,
+ char **opts, const char *opt);
+FSP_FUSE_API int fsp_fuse_opt_match(struct fsp_fuse_env *env,
+ const struct fuse_opt opts[], const char *opt);
static inline int fuse_opt_parse(struct fuse_args *args, void *data,
const struct fuse_opt opts[], fuse_opt_proc_t proc)
{
- return fsp_fuse_opt_parse(args, data, opts, proc,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_opt_parse(fsp_fuse_env(), args, data, opts, proc);
}
static inline int fuse_opt_add_arg(struct fuse_args *args, const char *arg)
{
- return fsp_fuse_opt_add_arg(args, arg,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_opt_add_arg(fsp_fuse_env(), args, arg);
}
static inline int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg)
{
- return fsp_fuse_opt_insert_arg(args, pos, arg,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_opt_insert_arg(fsp_fuse_env(), args, pos, arg);
}
static inline void fuse_opt_free_args(struct fuse_args *args)
{
- fsp_fuse_opt_free_args(args,
- FSP_FUSE_MEMFN_V);
+ fsp_fuse_opt_free_args(fsp_fuse_env(), args);
}
static inline int fuse_opt_add_opt(char **opts, const char *opt)
{
- return fsp_fuse_opt_add_opt(opts, opt,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_opt_add_opt(fsp_fuse_env(), opts, opt);
}
static inline int fuse_opt_add_opt_escaped(char **opts, const char *opt)
{
- return fsp_fuse_opt_add_opt_escaped(opts, opt,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_opt_add_opt_escaped(fsp_fuse_env(), opts, opt);
}
static inline int fuse_opt_match(const struct fuse_opt opts[], const char *opt)
{
- return fsp_fuse_opt_match(opts, opt,
- FSP_FUSE_MEMFN_V);
+ return fsp_fuse_opt_match(fsp_fuse_env(), opts, opt);
}
#ifdef __cplusplus
diff --git a/inc/fuse/winfsp_fuse.h b/inc/fuse/winfsp_fuse.h
new file mode 100644
index 00000000..4da6b6e6
--- /dev/null
+++ b/inc/fuse/winfsp_fuse.h
@@ -0,0 +1,162 @@
+/**
+ * @file fuse/winfsp_fuse.h
+ * WinFsp FUSE compatible API.
+ *
+ * @copyright 2015-2016 Bill Zissimopoulos
+ */
+/*
+ * This file is part of WinFsp.
+ *
+ * You can redistribute it and/or modify it under the terms of the
+ * GNU Affero General Public License version 3 as published by the
+ * Free Software Foundation.
+ *
+ * Licensees holding a valid commercial license may use this file in
+ * accordance with the commercial license agreement provided with the
+ * software.
+ */
+
+#ifndef FUSE_WINFSP_FUSE_H_INCLUDED
+#define FUSE_WINFSP_FUSE_H_INCLUDED
+
+#include
+#if !defined(WINFSP_DLL_INTERNAL)
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(WINFSP_DLL_INTERNAL)
+#define FSP_FUSE_API __declspec(dllexport)
+#else
+#define FSP_FUSE_API __declspec(dllimport)
+#endif
+
+/*
+ * FUSE uses a number of types (notably: struct stat) that are OS specific.
+ * Furthermore there are sometimes multiple definitions of the same type even
+ * within the same OS. This is certainly true on Windows, where these types
+ * are not even native.
+ *
+ * For this reason we will define our own fuse_* types which represent the
+ * types as the WinFsp DLL expects to see them. When the file is included
+ * by FUSE clients in different environments we will translate between their
+ * understanding of the types and ours.
+ */
+
+#if defined(_MSC_VER)
+
+typedef uint32_t fuse_uid_t;
+typedef uint32_t fuse_gid_t;
+typedef int32_t fuse_pid_t;
+
+typedef uint64_t fuse_dev_t;
+typedef uint64_t fuse_ino_t;
+typedef uint32_t fuse_mode_t;
+typedef uint32_t fuse_nlink_t;
+typedef int64_t fuse_off_t;
+
+typedef uint64_t fuse_fsblkcnt_t;
+typedef uint64_t fuse_fsfilcnt_t;
+typedef int32_t fuse_blksize_t;
+typedef int32_t fuse_blkcnt_t;
+
+struct fuse_timespec
+{
+ time_t tv_sec;
+ int tv_nsec;
+};
+
+struct fuse_stat
+{
+ fuse_dev_t st_dev;
+ fuse_ino_t st_ino;
+ fuse_mode_t st_mode;
+ fuse_nlink_t st_nlink;
+ fuse_uid_t st_uid;
+ fuse_gid_t st_gid;
+ fuse_dev_t st_rdev;
+ fuse_off_t st_size;
+ struct fuse_timespec st_atim;
+ struct fuse_timespec st_mtim;
+ struct fuse_timespec st_ctim;
+ fuse_blksize_t st_blksize;
+ fuse_blkcnt_t st_blocks;
+ struct fuse_timespec st_birthtim;
+};
+
+struct fuse_statvfs
+{
+ unsigned int f_bsize;
+ unsigned int f_frsize;
+ fuse_fsblkcnt_t f_blocks;
+ fuse_fsblkcnt_t f_bfree;
+ fuse_fsblkcnt_t f_bavail;
+ fuse_fsfilcnt_t f_files;
+ fuse_fsfilcnt_t f_ffree;
+ fuse_fsfilcnt_t f_favail;
+ unsigned int f_fsid;
+ unsigned int f_flag;
+ unsigned int f_namemax;
+};
+
+#if defined(WINFSP_DLL_INTERNAL)
+#define FSP_FUSE_ENV_INIT { 'W', MemAlloc, MemFree }
+#else
+#define FSP_FUSE_ENV_INIT { 'W', malloc, free }
+#endif
+
+#elif defined(__CYGWIN__)
+
+#include
+#include
+#include
+#include
+#include
+
+#define fuse_uid_t uid_t
+#define fuse_gid_t gid_t
+#define fuse_pid_t pid_t
+
+#define fuse_dev_t dev_t
+#define fuse_ino_t ino_t
+#define fuse_mode_t mode_t
+#define fuse_nlink_t nlink_t
+#define fuse_off_t off_t
+
+#define fuse_fsblkcnt_t fsblkcnt_t
+#define fuse_fsfilcnt_t fsfilcnt_t
+#define fuse_blksize_t blksize_t
+#define fuse_blkcnt_t blkcnt_t
+
+#define fuse_timespec timespec
+
+#define fuse_stat stat
+#define fuse_statvfs statvfs
+
+#define FSP_FUSE_ENV_INIT { 'C', malloc, free }
+
+#else
+#error unsupported environment
+#endif
+
+struct fsp_fuse_env
+{
+ unsigned environment;
+ void *(*memalloc)(size_t);
+ void (*memfree)(void *);
+};
+
+static inline struct fsp_fuse_env *fsp_fuse_env(void)
+{
+ static struct fsp_fuse_env env = FSP_FUSE_ENV_INIT;
+ return &env;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/dll/fuse/fuse.c b/src/dll/fuse/fuse.c
index e3462caa..6adb7115 100644
--- a/src/dll/fuse/fuse.c
+++ b/src/dll/fuse/fuse.c
@@ -92,12 +92,13 @@ static inline VOID fsp_fuse_initonce(VOID)
InitOnceExecuteOnce(&fsp_fuse_initonce_v, fsp_fuse_initonce_f, 0, 0);
}
-FSP_FUSE_API int fsp_fuse_version(void)
+FSP_FUSE_API int fsp_fuse_version(struct fsp_fuse_env *env)
{
return FUSE_VERSION;
}
-FSP_FUSE_API struct fuse_chan *fsp_fuse_mount(const char *mountpoint, struct fuse_args *args)
+FSP_FUSE_API struct fuse_chan *fsp_fuse_mount(struct fsp_fuse_env *env,
+ const char *mountpoint, struct fuse_args *args)
{
struct fuse_chan *ch = 0;
int Size;
@@ -125,29 +126,30 @@ fail:
return 0;
}
-FSP_FUSE_API void fsp_fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
+FSP_FUSE_API void fsp_fuse_unmount(struct fsp_fuse_env *env,
+ const char *mountpoint, struct fuse_chan *ch)
{
MemFree(ch);
}
-FSP_FUSE_API int fsp_fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
- int *multithreaded, int *foreground,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_parse_cmdline(struct fsp_fuse_env *env,
+ struct fuse_args *args, char **mountpoint,
+ int *multithreaded, int *foreground)
{
// !!!: NEEDIMPL
return 0;
}
-FSP_FUSE_API int fsp_fuse_main_real(int argc, char *argv[],
- const struct fuse_operations *ops, size_t opsize, void *data,
- int environment)
+FSP_FUSE_API int fsp_fuse_main_real(struct fsp_fuse_env *env,
+ int argc, char *argv[],
+ const struct fuse_operations *ops, size_t opsize, void *data)
{
// !!!: NEEDIMPL
return 0;
}
-FSP_FUSE_API int fsp_fuse_is_lib_option(const char *opt,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_is_lib_option(struct fsp_fuse_env *env,
+ const char *opt)
{
// !!!: NEEDIMPL
return 0;
@@ -169,9 +171,9 @@ static NTSTATUS fsp_fuse_svcstop(FSP_SERVICE *Service)
return STATUS_SUCCESS;
}
-FSP_FUSE_API struct fuse *fsp_fuse_new(struct fuse_chan *ch, struct fuse_args *args,
- const struct fuse_operations *ops, size_t opsize, void *data,
- int environment)
+FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env,
+ struct fuse_chan *ch, struct fuse_args *args,
+ const struct fuse_operations *ops, size_t opsize, void *data)
{
struct fuse *f = 0;
PWSTR ServiceName = FspDiagIdent();
@@ -216,7 +218,7 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fuse_chan *ch, struct fuse_args *a
f->Ops = ops;
f->OpSize = opsize;
f->Data = data;
- f->Environment = environment;
+ f->Environment = env->environment;
InitializeCriticalSection(&f->Lock);
@@ -239,7 +241,8 @@ fail:
return 0;
}
-FSP_FUSE_API void fsp_fuse_destroy(struct fuse *f)
+FSP_FUSE_API void fsp_fuse_destroy(struct fsp_fuse_env *env,
+ struct fuse *f)
{
DeleteCriticalSection(&f->Lock);
@@ -250,7 +253,8 @@ FSP_FUSE_API void fsp_fuse_destroy(struct fuse *f)
MemFree(f);
}
-FSP_FUSE_API int fsp_fuse_loop(struct fuse *f)
+FSP_FUSE_API int fsp_fuse_loop(struct fsp_fuse_env *env,
+ struct fuse *f)
{
NTSTATUS Result;
ULONG ExitCode;
@@ -274,17 +278,19 @@ fail:
return -1;
}
-FSP_FUSE_API int fsp_fuse_loop_mt(struct fuse *f)
+FSP_FUSE_API int fsp_fuse_loop_mt(struct fsp_fuse_env *env,
+ struct fuse *f)
{
- return fsp_fuse_loop(f);
+ return fsp_fuse_loop(env, f);
}
-FSP_FUSE_API void fsp_fuse_exit(struct fuse *f)
+FSP_FUSE_API void fsp_fuse_exit(struct fsp_fuse_env *env,
+ struct fuse *f)
{
FspServiceStop(f->Service);
}
-FSP_FUSE_API struct fuse_context *fsp_fuse_get_context(void)
+FSP_FUSE_API struct fuse_context *fsp_fuse_get_context(struct fsp_fuse_env *env)
{
struct fuse_context *context;
diff --git a/src/dll/fuse/fuse_opt.c b/src/dll/fuse/fuse_opt.c
index e1d397ee..3ee521ba 100644
--- a/src/dll/fuse/fuse_opt.c
+++ b/src/dll/fuse/fuse_opt.c
@@ -144,12 +144,11 @@ static const struct fuse_opt *fsp_fuse_opt_find(
return 0;
}
-static int fsp_fuse_opt_call_proc(void *data,
- fuse_opt_proc_t proc,
+static int fsp_fuse_opt_call_proc(struct fsp_fuse_env *env,
+ void *data, fuse_opt_proc_t proc,
const char *arg, const char *argend, const char *argl,
int key, int is_opt,
- struct fuse_args *outargs,
- FSP_FUSE_MEMFN_P)
+ struct fuse_args *outargs)
{
int result, len0, len1;
char *fullarg = 0;
@@ -169,7 +168,7 @@ static int fsp_fuse_opt_call_proc(void *data,
else
len1 = 0;
- fullarg = memalloc(len0 + len1 + 1);
+ fullarg = env->memalloc(len0 + len1 + 1);
if (0 == fullarg)
return -1;
@@ -193,45 +192,44 @@ static int fsp_fuse_opt_call_proc(void *data,
'-' == outargs->argv[1][0] && 'o' == outargs->argv[1][1] &&
'\0' == outargs->argv[1][2]))
{
- result = fsp_fuse_opt_insert_arg(outargs, 1, "-o", FSP_FUSE_MEMFN_A);
+ result = fsp_fuse_opt_insert_arg(env, outargs, 1, "-o");
if (-1 == result)
goto exit;
- result = fsp_fuse_opt_insert_arg(outargs, 2, "", FSP_FUSE_MEMFN_A);
+ result = fsp_fuse_opt_insert_arg(env, outargs, 2, "");
if (-1 == result)
goto exit;
}
- result = fsp_fuse_opt_add_opt(&outargs->argv[2], arg, FSP_FUSE_MEMFN_A);
+ result = fsp_fuse_opt_add_opt(env, &outargs->argv[2], arg);
if (-1 == result)
goto exit;
}
else
{
- result = fsp_fuse_opt_add_arg(outargs, arg, FSP_FUSE_MEMFN_A);
+ result = fsp_fuse_opt_add_arg(env, outargs, arg);
if (-1 == result)
goto exit;
}
exit:
if (0 != fullarg)
- memfree(fullarg);
+ env->memfree(fullarg);
return 0;
}
-static int fsp_fuse_opt_process_arg(void *data,
- const struct fuse_opt *opt, fuse_opt_proc_t proc,
+static int fsp_fuse_opt_process_arg(struct fsp_fuse_env *env,
+ void *data, const struct fuse_opt *opt, fuse_opt_proc_t proc,
const char *spec,
const char *arg, const char *argend, const char *argl,
int is_opt,
- struct fuse_args *outargs,
- FSP_FUSE_MEMFN_P)
+ struct fuse_args *outargs)
{
#define VAR(data, opt, type) *(type *)((char *)(data) + (opt)->offset)
if (-1L == opt->offset)
- return fsp_fuse_opt_call_proc(data, proc, arg, argend, argl, opt->value, is_opt, outargs,
- FSP_FUSE_MEMFN_A);
+ return fsp_fuse_opt_call_proc(env,
+ data, proc, arg, argend, argl, opt->value, is_opt, outargs);
else
{
int h, j, l, t, z;
@@ -312,7 +310,7 @@ static int fsp_fuse_opt_process_arg(void *data,
len = (int)(argend - argl);
else
len = lstrlenA(argl);
- s = memalloc(len + 1);
+ s = env->memalloc(len + 1);
if (0 == s)
return -1;
memcpy(s, argl, len);
@@ -329,12 +327,11 @@ static int fsp_fuse_opt_process_arg(void *data,
#undef VAR
}
-static int fsp_fuse_opt_parse_arg(void *data,
- const struct fuse_opt opts[], fuse_opt_proc_t proc,
+static int fsp_fuse_opt_parse_arg(struct fsp_fuse_env *env,
+ void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc,
const char *arg, const char *argend, const char *nextarg, int *pconsumed_nextarg,
int is_opt,
- struct fuse_args *outargs,
- FSP_FUSE_MEMFN_P)
+ struct fuse_args *outargs)
{
const struct fuse_opt *opt;
const char *spec, *argl;
@@ -354,8 +351,8 @@ static int fsp_fuse_opt_parse_arg(void *data,
*pconsumed_nextarg = 1;
}
- if (-1 == fsp_fuse_opt_process_arg(data, opt, proc, spec, arg, argend, argl,
- is_opt, outargs, FSP_FUSE_MEMFN_A))
+ if (-1 == fsp_fuse_opt_process_arg(env,
+ data, opt, proc, spec, arg, argend, argl, is_opt, outargs))
return -1;
processed++;
@@ -366,8 +363,8 @@ static int fsp_fuse_opt_parse_arg(void *data,
if (0 != processed)
return 0;
- return fsp_fuse_opt_call_proc(data, proc, arg, argend, arg, FUSE_OPT_KEY_OPT, is_opt, outargs,
- FSP_FUSE_MEMFN_A);
+ return fsp_fuse_opt_call_proc(env,
+ data, proc, arg, argend, arg, FUSE_OPT_KEY_OPT, is_opt, outargs);
}
static int fsp_fuse_opt_proc0(void *data, const char *arg, int key,
@@ -376,9 +373,9 @@ static int fsp_fuse_opt_proc0(void *data, const char *arg, int key,
return 1;
}
-FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
- const struct fuse_opt opts[], fuse_opt_proc_t proc,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_opt_parse(struct fsp_fuse_env *env,
+ struct fuse_args *args,
+ void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc)
{
static struct fuse_args args0 = FUSE_ARGS_INIT(0, 0);
static struct fuse_opt opts0[1] = { FUSE_OPT_END };
@@ -393,7 +390,7 @@ FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
if (0 == proc)
proc = fsp_fuse_opt_proc0;
- if (-1 == fsp_fuse_opt_add_arg(&outargs, args->argv[0], FSP_FUSE_MEMFN_A))
+ if (-1 == fsp_fuse_opt_add_arg(env, &outargs, args->argv[0]))
return -1;
for (int argi = 1; args->argc > argi; argi++)
@@ -416,8 +413,8 @@ FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
{
if ('\0' == *argend || ',' == *argend)
{
- if (-1 == fsp_fuse_opt_parse_arg(data, opts, proc,
- arg, argend, 0, 0, 1, &outargs, FSP_FUSE_MEMFN_A))
+ if (-1 == fsp_fuse_opt_parse_arg(env,
+ data, opts, proc, arg, argend, 0, 0, 1, &outargs))
goto fail;
arg = '\0' == *argend ? argend : argend + 1;
@@ -427,7 +424,7 @@ FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
case '-':
if ('\0' == arg[2])
{
- if (-1 == fsp_fuse_opt_add_arg(&outargs, arg, FSP_FUSE_MEMFN_A))
+ if (-1 == fsp_fuse_opt_add_arg(env, &outargs, arg))
return -1;
dashdash = 1;
break;
@@ -435,9 +432,8 @@ FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
/* fall through */
default:
consumed_nextarg = 0;
- if (-1 == fsp_fuse_opt_parse_arg(data, opts, proc,
- arg, 0, args->argv[argi + 1], &consumed_nextarg,
- 0, &outargs, FSP_FUSE_MEMFN_A))
+ if (-1 == fsp_fuse_opt_parse_arg(env,
+ data, opts, proc, arg, 0, args->argv[argi + 1], &consumed_nextarg, 0, &outargs))
goto fail;
if (consumed_nextarg)
argi++;
@@ -445,8 +441,8 @@ FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
}
}
else
- if (-1 == fsp_fuse_opt_call_proc(data, proc, arg, 0, arg, FUSE_OPT_KEY_NONOPT, 0, &outargs,
- FSP_FUSE_MEMFN_A))
+ if (-1 == fsp_fuse_opt_call_proc(env,
+ data, proc, arg, 0, arg, FUSE_OPT_KEY_NONOPT, 0, &outargs))
goto fail;
}
@@ -456,29 +452,29 @@ FSP_FUSE_API int fsp_fuse_opt_parse(struct fuse_args *args, void *data,
'-' == outargs.argv[outargs.argc - 1][1] &&
'\0' == outargs.argv[outargs.argc - 1][2])
{
- memfree(outargs.argv[--outargs.argc]);
+ env->memfree(outargs.argv[--outargs.argc]);
outargs.argv[outargs.argc] = 0;
}
- fsp_fuse_opt_free_args(args, FSP_FUSE_MEMFN_A);
+ fsp_fuse_opt_free_args(env, args);
memcpy(args, &outargs, sizeof outargs);
return 0;
fail:
- fsp_fuse_opt_free_args(&outargs, FSP_FUSE_MEMFN_A);
+ fsp_fuse_opt_free_args(env, &outargs);
return -1;
}
-FSP_FUSE_API int fsp_fuse_opt_add_arg(struct fuse_args *args, const char *arg,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_opt_add_arg(struct fsp_fuse_env *env,
+ struct fuse_args *args, const char *arg)
{
- return fsp_fuse_opt_insert_arg(args, args->argc, arg, FSP_FUSE_MEMFN_A);
+ return fsp_fuse_opt_insert_arg(env, args, args->argc, arg);
}
-FSP_FUSE_API int fsp_fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_opt_insert_arg(struct fsp_fuse_env *env,
+ struct fuse_args *args, int pos, const char *arg)
{
char **argv;
int argsize;
@@ -490,14 +486,14 @@ FSP_FUSE_API int fsp_fuse_opt_insert_arg(struct fuse_args *args, int pos, const
if (0 > pos || pos > args->argc)
return -1;
- argv = memalloc((args->argc + 2) * sizeof(char *));
+ argv = env->memalloc((args->argc + 2) * sizeof(char *));
if (0 == argv)
return -1;
argsize = lstrlenA(arg) + 1;
- argv[pos] = memalloc(argsize);
+ argv[pos] = env->memalloc(argsize);
if (0 == argv[pos])
{
- memfree(argv);
+ env->memfree(argv);
return -1;
}
@@ -505,7 +501,7 @@ FSP_FUSE_API int fsp_fuse_opt_insert_arg(struct fuse_args *args, int pos, const
memcpy(argv, args->argv, sizeof(char *) * pos);
memcpy(argv + pos + 1, args->argv + pos, sizeof(char *) * (args->argc - pos));
- memfree(args->argv);
+ env->memfree(args->argv);
args->argc++;
args->argv = argv;
@@ -515,8 +511,8 @@ FSP_FUSE_API int fsp_fuse_opt_insert_arg(struct fuse_args *args, int pos, const
return 0;
}
-FSP_FUSE_API void fsp_fuse_opt_free_args(struct fuse_args *args,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API void fsp_fuse_opt_free_args(struct fsp_fuse_env *env,
+ struct fuse_args *args)
{
if (0 == args)
return;
@@ -524,9 +520,9 @@ FSP_FUSE_API void fsp_fuse_opt_free_args(struct fuse_args *args,
if (args->allocated && 0 != args->argv)
{
for (int argi = 0; args->argc > argi; argi++)
- memfree(args->argv[argi]);
+ env->memfree(args->argv[argi]);
- memfree(args->argv);
+ env->memfree(args->argv);
}
args->argc = 0;
@@ -534,8 +530,8 @@ FSP_FUSE_API void fsp_fuse_opt_free_args(struct fuse_args *args,
args->allocated = 0;
}
-static int fsp_fuse_opt_add_opt_internal(char **opts, const char *opt, int escaped,
- FSP_FUSE_MEMFN_P)
+static int fsp_fuse_opt_add_opt_internal(struct fsp_fuse_env *env,
+ char **opts, const char *opt, int escaped)
{
size_t optsize, optlen;
char *newopts;
@@ -546,7 +542,7 @@ static int fsp_fuse_opt_add_opt_internal(char **opts, const char *opt, int escap
if (escaped && (',' == *p || '\\' == *p))
optlen++;
- newopts = memalloc(optsize + optlen + 1);
+ newopts = env->memalloc(optsize + optlen + 1);
if (0 == newopts)
return -1;
@@ -556,7 +552,7 @@ static int fsp_fuse_opt_add_opt_internal(char **opts, const char *opt, int escap
newopts[optsize - 1] = ',';
}
- memfree(*opts);
+ env->memfree(*opts);
*opts = newopts;
newopts += optsize;
@@ -571,22 +567,20 @@ static int fsp_fuse_opt_add_opt_internal(char **opts, const char *opt, int escap
return 0;
}
-FSP_FUSE_API int fsp_fuse_opt_add_opt(char **opts, const char *opt,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_opt_add_opt(struct fsp_fuse_env *env,
+ char **opts, const char *opt)
{
- return fsp_fuse_opt_add_opt_internal(opts, opt, 0,
- FSP_FUSE_MEMFN_A);
+ return fsp_fuse_opt_add_opt_internal(env, opts, opt, 0);
}
-FSP_FUSE_API int fsp_fuse_opt_add_opt_escaped(char **opts, const char *opt,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_opt_add_opt_escaped(struct fsp_fuse_env *env,
+ char **opts, const char *opt)
{
- return fsp_fuse_opt_add_opt_internal(opts, opt, 1,
- FSP_FUSE_MEMFN_A);
+ return fsp_fuse_opt_add_opt_internal(env, opts, opt, 1);
}
-FSP_FUSE_API int fsp_fuse_opt_match(const struct fuse_opt opts[], const char *arg,
- FSP_FUSE_MEMFN_P)
+FSP_FUSE_API int fsp_fuse_opt_match(struct fsp_fuse_env *env,
+ const struct fuse_opt opts[], const char *arg)
{
if (0 == opts)
return 0;