2017-03-22 20:35:00 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|