2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2017-03-22 20:35:00 +00:00
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
|
|
|
|
#define FUSE_USE_VERSION 30
|
2017-03-22 20:35:00 +00:00
|
|
|
#include "fuse3/fuse.h"
|
|
|
|
#include "fuse3/fuse_lowlevel.h"
|
|
|
|
|
|
|
|
#include "spdk/blobfs.h"
|
|
|
|
#include "spdk/bdev.h"
|
|
|
|
#include "spdk/event.h"
|
2018-06-11 20:32:15 +00:00
|
|
|
#include "spdk/thread.h"
|
2017-03-22 20:35:00 +00:00
|
|
|
#include "spdk/blob_bdev.h"
|
2019-09-25 08:47:02 +00:00
|
|
|
#include "spdk/blobfs_bdev.h"
|
2017-03-22 20:35:00 +00:00
|
|
|
#include "spdk/log.h"
|
2019-09-25 08:47:02 +00:00
|
|
|
#include "spdk/string.h"
|
2017-03-22 20:35:00 +00:00
|
|
|
|
|
|
|
char *g_bdev_name;
|
|
|
|
char *g_mountpoint;
|
|
|
|
|
|
|
|
int g_fuse_argc = 0;
|
|
|
|
char **g_fuse_argv = NULL;
|
|
|
|
|
|
|
|
static void
|
2019-09-25 08:47:02 +00:00
|
|
|
fuse_run_cb(void *cb_arg, int fserrno)
|
2017-03-22 20:35:00 +00:00
|
|
|
{
|
2019-09-25 08:47:02 +00:00
|
|
|
if (fserrno) {
|
2020-08-20 07:06:29 +00:00
|
|
|
printf("Failed to mount filesystem on bdev %s to path %s: %s\n",
|
2019-09-25 08:47:02 +00:00
|
|
|
g_bdev_name, g_mountpoint, spdk_strerror(fserrno));
|
2017-03-22 20:35:00 +00:00
|
|
|
|
2019-09-25 08:47:02 +00:00
|
|
|
spdk_app_stop(0);
|
2017-03-22 20:35:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-25 08:47:02 +00:00
|
|
|
printf("done.\n");
|
2017-03-22 20:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-03-04 20:52:59 +00:00
|
|
|
spdk_fuse_run(void *arg1)
|
2017-03-22 20:35:00 +00:00
|
|
|
{
|
2020-08-20 07:06:29 +00:00
|
|
|
printf("Mounting filesystem on bdev %s to path %s...\n",
|
2019-09-25 08:47:02 +00:00
|
|
|
g_bdev_name, g_mountpoint);
|
|
|
|
fflush(stdout);
|
2017-03-22 20:35:00 +00:00
|
|
|
|
2019-09-25 08:47:02 +00:00
|
|
|
spdk_blobfs_bdev_mount(g_bdev_name, g_mountpoint, fuse_run_cb, NULL);
|
2017-03-22 20:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spdk_fuse_shutdown(void)
|
|
|
|
{
|
2019-09-25 08:47:02 +00:00
|
|
|
spdk_app_stop(0);
|
2017-03-22 20:35:00 +00:00
|
|
|
}
|
|
|
|
|
2022-06-22 21:35:04 +00:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
2017-03-22 20:35:00 +00:00
|
|
|
{
|
|
|
|
struct spdk_app_opts opts = {};
|
2018-02-22 23:50:51 +00:00
|
|
|
int rc = 0;
|
2017-03-22 20:35:00 +00:00
|
|
|
|
|
|
|
if (argc < 4) {
|
|
|
|
fprintf(stderr, "usage: %s <conffile> <bdev name> <mountpoint>\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-11-30 11:38:37 +00:00
|
|
|
spdk_app_opts_init(&opts, sizeof(opts));
|
2017-03-22 20:35:00 +00:00
|
|
|
opts.name = "spdk_fuse";
|
2020-06-15 08:34:56 +00:00
|
|
|
opts.json_config_file = argv[1];
|
2017-03-22 20:35:00 +00:00
|
|
|
opts.reactor_mask = "0x3";
|
|
|
|
opts.shutdown_cb = spdk_fuse_shutdown;
|
|
|
|
|
|
|
|
g_bdev_name = argv[2];
|
|
|
|
g_mountpoint = argv[3];
|
2019-09-25 08:47:02 +00:00
|
|
|
|
|
|
|
/* TODO: mount blobfs with extra FUSE options. */
|
2017-03-22 20:35:00 +00:00
|
|
|
g_fuse_argc = argc - 2;
|
|
|
|
g_fuse_argv = &argv[2];
|
|
|
|
|
2020-04-30 01:19:35 +00:00
|
|
|
spdk_fs_set_cache_size(512);
|
|
|
|
|
2019-02-28 21:42:07 +00:00
|
|
|
rc = spdk_app_start(&opts, spdk_fuse_run, NULL);
|
2017-03-22 20:35:00 +00:00
|
|
|
spdk_app_fini();
|
|
|
|
|
2018-02-22 23:50:51 +00:00
|
|
|
return rc;
|
2017-03-22 20:35:00 +00:00
|
|
|
}
|