mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-25 01:42:24 -05:00
dll: fuse3: checkpoint
This commit is contained in:
parent
9b79bb24ca
commit
753440e837
@ -27,30 +27,7 @@ struct fuse_chan
|
||||
};
|
||||
|
||||
#define FSP_FUSE_CORE_OPT(n, f, v) { n, offsetof(struct fsp_fuse_core_opt_data, f), v }
|
||||
|
||||
struct fsp_fuse_core_opt_data
|
||||
{
|
||||
struct fsp_fuse_env *env;
|
||||
int help, debug;
|
||||
HANDLE DebugLogHandle;
|
||||
int set_umask, umask,
|
||||
set_create_umask, create_umask,
|
||||
set_uid, uid,
|
||||
set_gid, gid,
|
||||
set_attr_timeout, attr_timeout,
|
||||
rellinks;
|
||||
int set_FileInfoTimeout,
|
||||
set_DirInfoTimeout,
|
||||
set_VolumeInfoTimeout,
|
||||
set_KeepFileCache;
|
||||
unsigned ThreadCount;
|
||||
FSP_FSCTL_VOLUME_PARAMS VolumeParams;
|
||||
UINT16 VolumeLabelLength;
|
||||
WCHAR VolumeLabel[sizeof ((FSP_FSCTL_VOLUME_INFO *)0)->VolumeLabel / sizeof(WCHAR)];
|
||||
};
|
||||
FSP_FSCTL_STATIC_ASSERT(
|
||||
sizeof ((struct fuse *)0)->VolumeLabel == sizeof ((struct fsp_fuse_core_opt_data *)0)->VolumeLabel,
|
||||
"fuse::VolumeLabel and fsp_fuse_core_opt_data::VolumeLabel: sizeof must be same.");
|
||||
#define FSP_FUSE_CORE_OPT_NOHELP_IDX 4
|
||||
|
||||
static struct fuse_opt fsp_fuse_core_opts[] =
|
||||
{
|
||||
@ -546,6 +523,18 @@ static int fsp_fuse_core_opt_proc(void *opt_data0, const char *arg, int key,
|
||||
}
|
||||
}
|
||||
|
||||
int fsp_fuse_core_opt_parse(struct fsp_fuse_env *env,
|
||||
struct fuse_args *args, struct fsp_fuse_core_opt_data *opt_data,
|
||||
int help)
|
||||
{
|
||||
if (help)
|
||||
return fsp_fuse_opt_parse(env, args, opt_data,
|
||||
fsp_fuse_core_opts, fsp_fuse_core_opt_proc);
|
||||
else
|
||||
return fsp_fuse_opt_parse(env, args, opt_data,
|
||||
fsp_fuse_core_opts + FSP_FUSE_CORE_OPT_NOHELP_IDX, fsp_fuse_core_opt_proc);
|
||||
}
|
||||
|
||||
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)
|
||||
@ -566,7 +555,7 @@ FSP_FUSE_API struct fuse *fsp_fuse_new(struct fsp_fuse_env *env,
|
||||
opt_data.VolumeParams.FileInfoTimeout = 1000;
|
||||
opt_data.VolumeParams.FlushAndPurgeOnCleanup = TRUE;
|
||||
|
||||
if (-1 == fsp_fuse_opt_parse(env, args, &opt_data, fsp_fuse_core_opts, fsp_fuse_core_opt_proc))
|
||||
if (-1 == fsp_fuse_core_opt_parse(env, args, &opt_data, /*help=*/1))
|
||||
return 0;
|
||||
if (opt_data.help)
|
||||
return 0;
|
||||
|
@ -141,4 +141,32 @@ static inline void fsp_fuse_obj_free(void *obj)
|
||||
|
||||
struct fuse_context *fsp_fuse_get_context_internal(void);
|
||||
|
||||
struct fsp_fuse_core_opt_data
|
||||
{
|
||||
struct fsp_fuse_env *env;
|
||||
int help, debug;
|
||||
HANDLE DebugLogHandle;
|
||||
int set_umask, umask,
|
||||
set_create_umask, create_umask,
|
||||
set_uid, uid,
|
||||
set_gid, gid,
|
||||
set_attr_timeout, attr_timeout,
|
||||
rellinks;
|
||||
int set_FileInfoTimeout,
|
||||
set_DirInfoTimeout,
|
||||
set_VolumeInfoTimeout,
|
||||
set_KeepFileCache;
|
||||
unsigned ThreadCount;
|
||||
FSP_FSCTL_VOLUME_PARAMS VolumeParams;
|
||||
UINT16 VolumeLabelLength;
|
||||
WCHAR VolumeLabel[sizeof ((FSP_FSCTL_VOLUME_INFO *)0)->VolumeLabel / sizeof(WCHAR)];
|
||||
};
|
||||
FSP_FSCTL_STATIC_ASSERT(
|
||||
sizeof ((struct fuse *)0)->VolumeLabel == sizeof ((struct fsp_fuse_core_opt_data *)0)->VolumeLabel,
|
||||
"fuse::VolumeLabel and fsp_fuse_core_opt_data::VolumeLabel: sizeof must be same.");
|
||||
|
||||
int fsp_fuse_core_opt_parse(struct fsp_fuse_env *env,
|
||||
struct fuse_args *args, struct fsp_fuse_core_opt_data *opt_data,
|
||||
int help);
|
||||
|
||||
#endif
|
||||
|
@ -460,17 +460,44 @@ static int fuse2to3_fallocate(const char *path, int mode, fuse_off_t off, fuse_o
|
||||
return res;
|
||||
}
|
||||
|
||||
FSP_FUSE_API struct fuse3 *fsp_fuse3_new_30(struct fsp_fuse_env *env,
|
||||
struct fuse_args *args,
|
||||
const struct fuse3_operations *ops, size_t opsize, void *data)
|
||||
static int fsp_fuse3_copy_args(struct fsp_fuse_env *env,
|
||||
const struct fuse_args *args,
|
||||
struct fuse_args *outargs)
|
||||
{
|
||||
outargs->argc = 0;
|
||||
outargs->argv = 0;
|
||||
outargs->allocated = 0;
|
||||
|
||||
for (int argi = 0; args->argc > argi; argi++)
|
||||
if (-1 == fsp_fuse_opt_add_arg(env, outargs, args->argv[argi]))
|
||||
goto fail;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
fsp_fuse_opt_free_args(env, outargs);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
FSP_FUSE_API struct fuse3 *fsp_fuse3_new(struct fsp_fuse_env *env,
|
||||
static struct fuse3 *fsp_fuse3_new_common(struct fsp_fuse_env *env,
|
||||
struct fuse_args *args,
|
||||
const struct fuse3_operations *ops, size_t opsize, void *data)
|
||||
const struct fuse3_operations *ops, size_t opsize, void *data,
|
||||
int help)
|
||||
{
|
||||
/* preflight args */
|
||||
struct fsp_fuse_core_opt_data opt_data;
|
||||
struct fuse_args pfargs;
|
||||
memset(&opt_data, 0, sizeof opt_data);
|
||||
if (-1 == fsp_fuse3_copy_args(env, args, &pfargs))
|
||||
return 0;
|
||||
int optres = fsp_fuse_core_opt_parse(env, &pfargs, &opt_data, /*help=*/1);
|
||||
fsp_fuse_opt_free_args(env, &pfargs);
|
||||
if (-1 == optres)
|
||||
return 0;
|
||||
if (opt_data.help)
|
||||
return 0;
|
||||
|
||||
struct fuse3 *f3 = 0;
|
||||
|
||||
if (opsize > sizeof(struct fuse3_operations))
|
||||
@ -480,10 +507,8 @@ FSP_FUSE_API struct fuse3 *fsp_fuse3_new(struct fsp_fuse_env *env,
|
||||
if (0 == f3)
|
||||
goto fail;
|
||||
|
||||
for (int argi = 0; args->argc > argi; argi++)
|
||||
if (-1 == fsp_fuse_opt_add_arg(env, &f3->args, args->argv[argi]))
|
||||
goto fail;
|
||||
|
||||
if (-1 == fsp_fuse3_copy_args(env, args, &f3->args))
|
||||
goto fail;
|
||||
memcpy(&f3->ops, ops, opsize);
|
||||
f3->data = data;
|
||||
|
||||
@ -496,6 +521,20 @@ fail:
|
||||
return 0;
|
||||
}
|
||||
|
||||
FSP_FUSE_API struct fuse3 *fsp_fuse3_new_30(struct fsp_fuse_env *env,
|
||||
struct fuse_args *args,
|
||||
const struct fuse3_operations *ops, size_t opsize, void *data)
|
||||
{
|
||||
return fsp_fuse3_new_common(env, args, ops, opsize, data, /*help=*/1);
|
||||
}
|
||||
|
||||
FSP_FUSE_API struct fuse3 *fsp_fuse3_new(struct fsp_fuse_env *env,
|
||||
struct fuse_args *args,
|
||||
const struct fuse3_operations *ops, size_t opsize, void *data)
|
||||
{
|
||||
return fsp_fuse3_new_common(env, args, ops, opsize, data, /*help=*/0);
|
||||
}
|
||||
|
||||
FSP_FUSE_API void fsp_fuse3_destroy(struct fsp_fuse_env *env,
|
||||
struct fuse3 *f3)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user