mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
dll: fsp_fuse_main_real: implementation
This commit is contained in:
parent
19d400d251
commit
4b9945d9bf
@ -105,13 +105,6 @@ 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,
|
||||
@ -133,20 +126,6 @@ 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);
|
||||
|
@ -119,35 +119,58 @@ 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)
|
||||
{
|
||||
struct fuse *f;
|
||||
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
|
||||
char *mountpoint = 0;
|
||||
int multithreaded = 0;
|
||||
int foreground = 0;
|
||||
struct fuse_chan *ch = 0;
|
||||
struct fuse *f = 0;
|
||||
int signal_handlers = 0;
|
||||
int result;
|
||||
|
||||
f = fsp_fuse_setup(env, argc, argv, ops, opsize, &mountpoint, &multithreaded, data);
|
||||
result = fsp_fuse_parse_cmdline(env, &args, &mountpoint, &multithreaded, &foreground);
|
||||
if (-1 == result)
|
||||
goto exit;
|
||||
|
||||
ch = fsp_fuse_mount(env, mountpoint, &args);
|
||||
if (0 == ch)
|
||||
{
|
||||
result = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
f = fsp_fuse_new(env, ch, &args, ops, opsize, data);
|
||||
if (0 == f)
|
||||
return 1;
|
||||
{
|
||||
result = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
result = env->daemonize(foreground);
|
||||
if (-1 == result)
|
||||
goto exit;
|
||||
|
||||
result = env->set_signal_handlers(f/* !!!: REVISIT */);
|
||||
if (-1 == result)
|
||||
goto exit;
|
||||
signal_handlers = 1;
|
||||
|
||||
result = multithreaded ? fsp_fuse_loop_mt(env, f) : fsp_fuse_loop(env, f);
|
||||
|
||||
fsp_fuse_teardown(env, f, mountpoint);
|
||||
exit:
|
||||
if (signal_handlers)
|
||||
env->remove_signal_handlers(f/* !!!: REVISIT */);
|
||||
|
||||
if (0 != ch)
|
||||
fsp_fuse_unmount(env, mountpoint, ch);
|
||||
|
||||
if (0 != f)
|
||||
fsp_fuse_destroy(env, f);
|
||||
|
||||
env->memfree(mountpoint);
|
||||
|
||||
fsp_fuse_opt_free_args(env, &args);
|
||||
|
||||
/* main() style return: 0 success, 1 error */
|
||||
return !!result;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// !!!: NEEDIMPL
|
||||
return 0;
|
||||
}
|
||||
|
||||
FSP_FUSE_API void fsp_fuse_teardown(struct fsp_fuse_env *env,
|
||||
struct fuse *f, char *mountpoint)
|
||||
{
|
||||
// !!!: NEEDIMPL
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user