mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
opt: cygfuse
This commit is contained in:
parent
698b711df4
commit
d6fb076cad
111
inc/fuse/fuse.h
111
inc/fuse/fuse.h
@ -102,95 +102,116 @@ 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(struct fsp_fuse_env *env,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API struct fuse *FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API void FSP_FUSE_API_NAME(fsp_fuse_destroy)(struct fsp_fuse_env *env,
|
||||
struct fuse *f);
|
||||
FSP_FUSE_API int fsp_fuse_loop(struct fsp_fuse_env *env,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(fsp_fuse_loop)(struct fsp_fuse_env *env,
|
||||
struct fuse *f);
|
||||
FSP_FUSE_API int fsp_fuse_loop_mt(struct fsp_fuse_env *env,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(fsp_fuse_loop_mt)(struct fsp_fuse_env *env,
|
||||
struct fuse *f);
|
||||
FSP_FUSE_API void fsp_fuse_exit(struct fsp_fuse_env *env,
|
||||
FSP_FUSE_API void FSP_FUSE_API_NAME(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);
|
||||
FSP_FUSE_API struct fuse_context *FSP_FUSE_API_NAME(fsp_fuse_get_context)(struct fsp_fuse_env *env);
|
||||
|
||||
FSP_FUSE_SYM int fuse_main_real(int argc, char *argv[],
|
||||
const struct fuse_operations *ops, size_t opsize, void *data)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_main_real(int argc, char *argv[],
|
||||
const struct fuse_operations *ops, size_t opsize, void *data),
|
||||
{
|
||||
return fsp_fuse_main_real(fsp_fuse_env(), argc, argv, ops, opsize, data);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_main_real)
|
||||
(fsp_fuse_env(), argc, argv, ops, opsize, data);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_is_lib_option(const char *opt)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_is_lib_option(const char *opt),
|
||||
{
|
||||
return fsp_fuse_is_lib_option(fsp_fuse_env(), opt);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_is_lib_option)
|
||||
(fsp_fuse_env(), opt);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
|
||||
const struct fuse_operations *ops, size_t opsize, void *data)
|
||||
FSP_FUSE_SYM(
|
||||
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(fsp_fuse_env(), ch, args, ops, opsize, data);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_new)
|
||||
(fsp_fuse_env(), ch, args, ops, opsize, data);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM void fuse_destroy(struct fuse *f)
|
||||
FSP_FUSE_SYM(
|
||||
void fuse_destroy(struct fuse *f),
|
||||
{
|
||||
fsp_fuse_destroy(fsp_fuse_env(), f);
|
||||
}
|
||||
FSP_FUSE_API_CALL(fsp_fuse_destroy)
|
||||
(fsp_fuse_env(), f);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_loop(struct fuse *f)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_loop(struct fuse *f),
|
||||
{
|
||||
return fsp_fuse_loop(fsp_fuse_env(), f);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_loop)
|
||||
(fsp_fuse_env(), f);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_loop_mt(struct fuse *f)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_loop_mt(struct fuse *f),
|
||||
{
|
||||
return fsp_fuse_loop_mt(fsp_fuse_env(), f);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_loop_mt)
|
||||
(fsp_fuse_env(), f);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM void fuse_exit(struct fuse *f)
|
||||
FSP_FUSE_SYM(
|
||||
void fuse_exit(struct fuse *f),
|
||||
{
|
||||
fsp_fuse_exit(fsp_fuse_env(), f);
|
||||
}
|
||||
FSP_FUSE_API_CALL(fsp_fuse_exit)
|
||||
(fsp_fuse_env(), f);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM struct fuse_context *fuse_get_context(void)
|
||||
FSP_FUSE_SYM(
|
||||
struct fuse_context *fuse_get_context(void),
|
||||
{
|
||||
return fsp_fuse_get_context(fsp_fuse_env());
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_get_context)
|
||||
(fsp_fuse_env());
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_getgroups(int size, fuse_gid_t list[])
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_getgroups(int size, fuse_gid_t list[]),
|
||||
{
|
||||
(void)size;
|
||||
(void)list;
|
||||
return -ENOSYS;
|
||||
}
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_interrupted(void)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_interrupted(void),
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_invalidate(struct fuse *f, const char *path)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_invalidate(struct fuse *f, const char *path),
|
||||
{
|
||||
(void)f;
|
||||
(void)path;
|
||||
return -EINVAL;
|
||||
}
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_notify_poll(struct fuse_pollhandle *ph)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_notify_poll(struct fuse_pollhandle *ph),
|
||||
{
|
||||
(void)ph;
|
||||
return 0;
|
||||
}
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM struct fuse_session *fuse_get_session(struct fuse *f)
|
||||
FSP_FUSE_SYM(
|
||||
struct fuse_session *fuse_get_session(struct fuse *f),
|
||||
{
|
||||
return (void *)f;
|
||||
}
|
||||
return (struct fuse_session *)f;
|
||||
})
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -77,58 +77,70 @@ struct fuse_session;
|
||||
struct fuse_chan;
|
||||
struct fuse_pollhandle;
|
||||
|
||||
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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(fsp_fuse_version)(struct fsp_fuse_env *env);
|
||||
FSP_FUSE_API struct fuse_chan *FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API void FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(fsp_fuse_parse_cmdline)(struct fsp_fuse_env *env,
|
||||
struct fuse_args *args,
|
||||
char **mountpoint, int *multithreaded, int *foreground);
|
||||
FSP_FUSE_API int32_t fsp_fuse_ntstatus_from_errno(struct fsp_fuse_env *env,
|
||||
FSP_FUSE_API int32_t FSP_FUSE_API_NAME(fsp_fuse_ntstatus_from_errno)(struct fsp_fuse_env *env,
|
||||
int err);
|
||||
|
||||
FSP_FUSE_SYM int fuse_version(void)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_version(void),
|
||||
{
|
||||
return fsp_fuse_version(fsp_fuse_env());
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_version)
|
||||
(fsp_fuse_env());
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
|
||||
FSP_FUSE_SYM(
|
||||
struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args),
|
||||
{
|
||||
return fsp_fuse_mount(fsp_fuse_env(), mountpoint, args);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_mount)
|
||||
(fsp_fuse_env(), mountpoint, args);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
|
||||
FSP_FUSE_SYM(
|
||||
void fuse_unmount(const char *mountpoint, struct fuse_chan *ch),
|
||||
{
|
||||
fsp_fuse_unmount(fsp_fuse_env(), mountpoint, ch);
|
||||
}
|
||||
FSP_FUSE_API_CALL(fsp_fuse_unmount)
|
||||
(fsp_fuse_env(), mountpoint, ch);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_parse_cmdline(struct fuse_args *args,
|
||||
char **mountpoint, int *multithreaded, int *foreground)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_parse_cmdline(struct fuse_args *args,
|
||||
char **mountpoint, int *multithreaded, int *foreground),
|
||||
{
|
||||
return fsp_fuse_parse_cmdline(fsp_fuse_env(), args, mountpoint, multithreaded, foreground);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_parse_cmdline)
|
||||
(fsp_fuse_env(), args, mountpoint, multithreaded, foreground);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
|
||||
FSP_FUSE_SYM(
|
||||
void fuse_pollhandle_destroy(struct fuse_pollhandle *ph),
|
||||
{
|
||||
(void)ph;
|
||||
}
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_daemonize(int foreground)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_daemonize(int foreground),
|
||||
{
|
||||
return fsp_fuse_daemonize(foreground);
|
||||
}
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_set_signal_handlers(struct fuse_session *se)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_set_signal_handlers(struct fuse_session *se),
|
||||
{
|
||||
return fsp_fuse_set_signal_handlers(se);
|
||||
}
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM void fuse_remove_signal_handlers(struct fuse_session *se)
|
||||
FSP_FUSE_SYM(
|
||||
void fuse_remove_signal_handlers(struct fuse_session *se),
|
||||
{
|
||||
(void)se;
|
||||
fsp_fuse_set_signal_handlers(0);
|
||||
}
|
||||
})
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -56,57 +56,71 @@ 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 fsp_fuse_env *env,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API void FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(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,
|
||||
FSP_FUSE_API int FSP_FUSE_API_NAME(fsp_fuse_opt_match)(struct fsp_fuse_env *env,
|
||||
const struct fuse_opt opts[], const char *opt);
|
||||
|
||||
FSP_FUSE_SYM int fuse_opt_parse(struct fuse_args *args, void *data,
|
||||
const struct fuse_opt opts[], fuse_opt_proc_t proc)
|
||||
FSP_FUSE_SYM(
|
||||
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(fsp_fuse_env(), args, data, opts, proc);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_opt_parse)
|
||||
(fsp_fuse_env(), args, data, opts, proc);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_opt_add_arg(struct fuse_args *args, const char *arg)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_opt_add_arg(struct fuse_args *args, const char *arg),
|
||||
{
|
||||
return fsp_fuse_opt_add_arg(fsp_fuse_env(), args, arg);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_opt_add_arg)
|
||||
(fsp_fuse_env(), args, arg);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg),
|
||||
{
|
||||
return fsp_fuse_opt_insert_arg(fsp_fuse_env(), args, pos, arg);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_opt_insert_arg)
|
||||
(fsp_fuse_env(), args, pos, arg);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM void fuse_opt_free_args(struct fuse_args *args)
|
||||
FSP_FUSE_SYM(
|
||||
void fuse_opt_free_args(struct fuse_args *args),
|
||||
{
|
||||
fsp_fuse_opt_free_args(fsp_fuse_env(), args);
|
||||
}
|
||||
FSP_FUSE_API_CALL(fsp_fuse_opt_free_args)
|
||||
(fsp_fuse_env(), args);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_opt_add_opt(char **opts, const char *opt)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_opt_add_opt(char **opts, const char *opt),
|
||||
{
|
||||
return fsp_fuse_opt_add_opt(fsp_fuse_env(), opts, opt);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_opt_add_opt)
|
||||
(fsp_fuse_env(), opts, opt);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_opt_add_opt_escaped(char **opts, const char *opt)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_opt_add_opt_escaped(char **opts, const char *opt),
|
||||
{
|
||||
return fsp_fuse_opt_add_opt_escaped(fsp_fuse_env(), opts, opt);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_opt_add_opt_escaped)
|
||||
(fsp_fuse_env(), opts, opt);
|
||||
})
|
||||
|
||||
FSP_FUSE_SYM int fuse_opt_match(const struct fuse_opt opts[], const char *opt)
|
||||
FSP_FUSE_SYM(
|
||||
int fuse_opt_match(const struct fuse_opt opts[], const char *opt),
|
||||
{
|
||||
return fsp_fuse_opt_match(fsp_fuse_env(), opts, opt);
|
||||
}
|
||||
return FSP_FUSE_API_CALL(fsp_fuse_opt_match)
|
||||
(fsp_fuse_env(), opts, opt);
|
||||
})
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -29,14 +29,28 @@
|
||||
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_API_NAME)
|
||||
#define FSP_FUSE_API_NAME(n) (n)
|
||||
#endif
|
||||
|
||||
#if !defined(FSP_FUSE_API_CALL)
|
||||
#define FSP_FUSE_API_CALL(n) (n)
|
||||
#endif
|
||||
|
||||
#if !defined(FSP_FUSE_SYM)
|
||||
#define FSP_FUSE_SYM static inline
|
||||
#if !defined(CYGFUSE)
|
||||
#define FSP_FUSE_SYM(proto, ...) static inline proto { __VA_ARGS__ }
|
||||
#else
|
||||
#define FSP_FUSE_SYM(proto, ...) proto;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -232,7 +246,7 @@ struct fsp_fuse_env
|
||||
int (*set_signal_handlers)(void *);
|
||||
};
|
||||
|
||||
FSP_FUSE_API void fsp_fuse_signal_handler(int sig);
|
||||
FSP_FUSE_API void FSP_FUSE_API_NAME(fsp_fuse_signal_handler)(int sig);
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
|
||||
@ -270,8 +284,8 @@ static inline void *fsp_fuse_signal_thread(void *psigmask)
|
||||
{
|
||||
int sig;
|
||||
|
||||
if (0 == sigwait(psigmask, &sig))
|
||||
fsp_fuse_signal_handler(sig);
|
||||
if (0 == sigwait((sigset_t *)psigmask, &sig))
|
||||
FSP_FUSE_API_CALL(fsp_fuse_signal_handler)(sig);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
8
opt/cygfuse/Makefile
Normal file
8
opt/cygfuse/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
#Debug = -g
|
||||
|
||||
cygfuse.dll libfuse.a: cygfuse.cpp
|
||||
g++ $(Debug) -shared -o cygfuse.dll -Wl,--out-implib=libfuse.a -I../../inc/fuse cygfuse.cpp
|
||||
[ -n "$(Debug)" ] || strip cygfuse.dll
|
||||
|
||||
cygfuse-test.exe: cygfuse-test.c cygfuse.dll libfuse.a
|
||||
gcc $(Debug) -o cygfuse-test.exe -I../../inc/fuse -DCYGFUSE cygfuse-test.c -L$(PWD) -lfuse
|
6
opt/cygfuse/cygfuse-test.c
Normal file
6
opt/cygfuse/cygfuse-test.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <fuse.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
return !(FUSE_VERSION == fuse_version());
|
||||
}
|
120
opt/cygfuse/cygfuse.cpp
Normal file
120
opt/cygfuse/cygfuse.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @file cygfuse/cygfuse.cpp
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static HANDLE cygfuse_init_winfsp();
|
||||
static HANDLE cygfuse_init_fail(int err);
|
||||
static inline void cygfuse_init()
|
||||
{
|
||||
static HANDLE Handle = cygfuse_init_winfsp();
|
||||
}
|
||||
|
||||
#define FSP_FUSE_API static
|
||||
#define FSP_FUSE_API_NAME(api) (* pfn_ ## api)
|
||||
#define FSP_FUSE_API_CALL(api) (cygfuse_init(), pfn_ ## api)
|
||||
#define FSP_FUSE_SYM(proto, ...) __attribute__ ((visibility("default"))) proto { __VA_ARGS__ }
|
||||
#include <fuse_common.h>
|
||||
#include <fuse.h>
|
||||
#include <fuse_opt.h>
|
||||
|
||||
#if defined(__LP64__)
|
||||
#define CYGFUSE_WINFSP_NAME "winfsp-x64.dll"
|
||||
#else
|
||||
#define CYGFUSE_WINFSP_NAME "winfsp-x86.dll"
|
||||
#endif
|
||||
#define CYGFUSE_WINFSP_PATH "bin\\" CYGFUSE_WINFSP_NAME
|
||||
#define CYGFUSE_API_GET(h, n) \
|
||||
if (0 == (*(FARPROC *)&(pfn_ ## n) = GetProcAddress((HMODULE)h, #n)))\
|
||||
return cygfuse_init_fail(ERROR_PROC_NOT_FOUND);
|
||||
|
||||
static HANDLE cygfuse_init_fail(int err)
|
||||
{
|
||||
//RaiseException(ERROR_SEVERITY_ERROR | (109/*FACILITY_VISUALCPP*/ << 16) | err, 0, 0, 0);
|
||||
abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HANDLE cygfuse_init_winfsp()
|
||||
{
|
||||
HANDLE Handle;
|
||||
|
||||
Handle = LoadLibraryW(L"" CYGFUSE_WINFSP_NAME);
|
||||
if (0 == Handle)
|
||||
{
|
||||
HKEY RegKey;
|
||||
DWORD RegResult, RegType;
|
||||
WCHAR Path[MAX_PATH];
|
||||
DWORD Size;
|
||||
|
||||
Size = sizeof(Path);
|
||||
if (ERROR_SUCCESS == (RegResult = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"Software\\WinFsp", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &RegKey)))
|
||||
{
|
||||
RegResult = RegQueryValueExW(RegKey, L"InstallDir", 0, &RegType, (PBYTE)Path, &Size);
|
||||
RegCloseKey(RegKey);
|
||||
}
|
||||
if (ERROR_SUCCESS != RegResult)
|
||||
return cygfuse_init_fail(ERROR_MOD_NOT_FOUND);
|
||||
|
||||
Size /= sizeof(WCHAR);
|
||||
if (Size >= MAX_PATH)
|
||||
Size = MAX_PATH - 1;
|
||||
Path[Size] = L'\0';
|
||||
|
||||
Size = lstrlenW(Path);
|
||||
if (Size * sizeof(WCHAR) + sizeof L"" CYGFUSE_WINFSP_PATH > MAX_PATH * sizeof(WCHAR))
|
||||
return cygfuse_init_fail(ERROR_MOD_NOT_FOUND);
|
||||
|
||||
memcpy(Path + Size, L"" CYGFUSE_WINFSP_PATH, sizeof L"" CYGFUSE_WINFSP_PATH);
|
||||
|
||||
Handle = LoadLibraryW(Path);
|
||||
if (0 == Handle)
|
||||
return cygfuse_init_fail(ERROR_MOD_NOT_FOUND);
|
||||
}
|
||||
|
||||
/* winfsp_fuse.h */
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_signal_handler);
|
||||
|
||||
/* fuse_common.h */
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_version);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_mount);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_unmount);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_parse_cmdline);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_ntstatus_from_errno);
|
||||
|
||||
/* fuse.h */
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_main_real);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_is_lib_option);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_new);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_destroy);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_loop);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_loop_mt);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_exit);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_get_context);
|
||||
|
||||
/* fuse_opt.h */
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_opt_parse);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_opt_add_arg);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_opt_insert_arg);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_opt_free_args);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_opt_add_opt);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_opt_add_opt_escaped);
|
||||
CYGFUSE_API_GET(Handle, fsp_fuse_opt_match);
|
||||
|
||||
return Handle;
|
||||
}
|
9
opt/cygfuse/fuse.pc
Normal file
9
opt/cygfuse/fuse.pc
Normal file
@ -0,0 +1,9 @@
|
||||
prefix=/usr/local
|
||||
incdir=${prefix}/include/fuse
|
||||
|
||||
Name: fuse
|
||||
Description: WinFsp FUSE compatible API
|
||||
Version: 2.8
|
||||
URL: http://www.secfs.net/winfsp/
|
||||
Libs: -lfuse
|
||||
Cflags: -I"${incdir}" -DCYGFUSE
|
Loading…
x
Reference in New Issue
Block a user