mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-15 00:02:46 -05:00
dll: fsp_fuse_parse_cmdline, fsp_fuse_main_real: implementation checkpoint
This commit is contained in:
@ -105,6 +105,13 @@ struct fuse_context
|
||||
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 struct fuse *fsp_fuse_setup(struct fsp_fuse_env *env,
|
||||
int argc, char *argv[],
|
||||
const struct fuse_operations *ops, size_t opsize,
|
||||
char **mountpoint, int *multithreaded,
|
||||
void *data);
|
||||
FSP_FUSE_API void fsp_fuse_teardown(struct fsp_fuse_env *env,
|
||||
struct fuse *f, char *mountpoint);
|
||||
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,
|
||||
@ -126,6 +133,20 @@ static inline int fuse_main_real(int argc, char *argv[],
|
||||
return fsp_fuse_main_real(fsp_fuse_env(), argc, argv, ops, opsize, data);
|
||||
}
|
||||
|
||||
static inline struct fuse *fuse_setup(int argc, char *argv[],
|
||||
const struct fuse_operations *ops, size_t opsize,
|
||||
char **mountpoint, int *multithreaded,
|
||||
void *data)
|
||||
{
|
||||
return fsp_fuse_setup(fsp_fuse_env(),
|
||||
argc, argv, ops, opsize, mountpoint, multithreaded, data);
|
||||
}
|
||||
|
||||
static inline void fuse_teardown(struct fuse *f, char *mountpoint)
|
||||
{
|
||||
fsp_fuse_teardown(fsp_fuse_env(), f, mountpoint);
|
||||
}
|
||||
|
||||
static inline int fuse_is_lib_option(const char *opt)
|
||||
{
|
||||
return fsp_fuse_is_lib_option(fsp_fuse_env(), opt);
|
||||
|
@ -83,8 +83,8 @@ FSP_FUSE_API struct fuse_chan *fsp_fuse_mount(struct fsp_fuse_env *env,
|
||||
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);
|
||||
struct fuse_args *args,
|
||||
char **mountpoint, int *multithreaded, int *foreground);
|
||||
|
||||
static inline int fuse_version(void)
|
||||
{
|
||||
@ -101,8 +101,8 @@ static inline void fuse_unmount(const char *mountpoint, struct fuse_chan *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)
|
||||
static inline 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);
|
||||
}
|
||||
@ -114,19 +114,17 @@ static inline void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
|
||||
|
||||
static inline int fuse_daemonize(int foreground)
|
||||
{
|
||||
(void)foreground;
|
||||
return 0;
|
||||
return fsp_fuse_daemonize(foreground);
|
||||
}
|
||||
|
||||
static inline int fuse_set_signal_handlers(struct fuse_session *se)
|
||||
{
|
||||
(void)se;
|
||||
return 0;
|
||||
return fsp_fuse_set_signal_handlers(se);
|
||||
}
|
||||
|
||||
static inline void fuse_remove_signal_handlers(struct fuse_session *se)
|
||||
{
|
||||
(void)se;
|
||||
fsp_fuse_remove_signal_handlers(se);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -46,7 +46,7 @@ extern "C" {
|
||||
* understanding of the types and ours.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
|
||||
typedef uint32_t fuse_uid_t;
|
||||
typedef uint32_t fuse_gid_t;
|
||||
@ -103,9 +103,23 @@ struct fuse_statvfs
|
||||
};
|
||||
|
||||
#if defined(WINFSP_DLL_INTERNAL)
|
||||
#define FSP_FUSE_ENV_INIT { 'W', MemAlloc, MemFree }
|
||||
#define FSP_FUSE_ENV_INIT \
|
||||
{ \
|
||||
'W', \
|
||||
MemAlloc, MemFree, \
|
||||
fsp_fuse_daemonize, \
|
||||
fsp_fuse_set_signal_handlers, \
|
||||
fsp_fuse_remove_signal_handlers,\
|
||||
}
|
||||
#else
|
||||
#define FSP_FUSE_ENV_INIT { 'W', malloc, free }
|
||||
#define FSP_FUSE_ENV_INIT \
|
||||
{ \
|
||||
'W', \
|
||||
malloc, free, \
|
||||
fsp_fuse_daemonize, \
|
||||
fsp_fuse_set_signal_handlers, \
|
||||
fsp_fuse_remove_signal_handlers,\
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
@ -136,7 +150,14 @@ struct fuse_statvfs
|
||||
#define fuse_stat stat
|
||||
#define fuse_statvfs statvfs
|
||||
|
||||
#define FSP_FUSE_ENV_INIT { 'C', malloc, free }
|
||||
#define FSP_FUSE_ENV_INIT \
|
||||
{ \
|
||||
'C', \
|
||||
malloc, free, \
|
||||
fsp_fuse_daemonize, \
|
||||
fsp_fuse_set_signal_handlers, \
|
||||
fsp_fuse_remove_signal_handlers,\
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that long is 8 bytes long in Cygwin64 and 4 bytes long in Win64.
|
||||
@ -152,8 +173,41 @@ struct fsp_fuse_env
|
||||
unsigned environment;
|
||||
void *(*memalloc)(size_t);
|
||||
void (*memfree)(void *);
|
||||
int (*daemonize)(int);
|
||||
int (*set_signal_handlers)(void *);
|
||||
void (*remove_signal_handlers)(void *);
|
||||
};
|
||||
|
||||
static inline int fsp_fuse_daemonize(int foreground)
|
||||
{
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
(void)foreground;
|
||||
return 0;
|
||||
#elif defined(__CYGWIN__)
|
||||
int daemon(int nochdir, int noclose);
|
||||
int chdir(const char *path);
|
||||
if (!foreground)
|
||||
{
|
||||
if (-1 == daemon(0, 0))
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
chdir("/");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int fsp_fuse_set_signal_handlers(void *se)
|
||||
{
|
||||
(void)se;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void fsp_fuse_remove_signal_handlers(void *se)
|
||||
{
|
||||
(void)se;
|
||||
}
|
||||
|
||||
static inline struct fsp_fuse_env *fsp_fuse_env(void)
|
||||
{
|
||||
static struct fsp_fuse_env env = FSP_FUSE_ENV_INIT;
|
||||
|
Reference in New Issue
Block a user