Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (C) 2017 Intel Corporation. 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #include "spdk/stdinc.h" 7 : : 8 : : #define FUSE_USE_VERSION 30 9 : : #include "fuse3/fuse.h" 10 : : #include "fuse3/fuse_lowlevel.h" 11 : : 12 : : #include "spdk/blobfs.h" 13 : : #include "spdk/bdev.h" 14 : : #include "spdk/event.h" 15 : : #include "spdk/thread.h" 16 : : #include "spdk/blob_bdev.h" 17 : : #include "spdk/blobfs_bdev.h" 18 : : #include "spdk/log.h" 19 : : #include "spdk/string.h" 20 : : 21 : : char *g_bdev_name; 22 : : char *g_mountpoint; 23 : : 24 : : int g_fuse_argc = 0; 25 : : char **g_fuse_argv = NULL; 26 : : 27 : : static void 28 : 1 : fuse_run_cb(void *cb_arg, int fserrno) 29 : : { 30 [ - + ]: 1 : if (fserrno) { 31 [ # # ]: 0 : printf("Failed to mount filesystem on bdev %s to path %s: %s\n", 32 : : g_bdev_name, g_mountpoint, spdk_strerror(fserrno)); 33 : : 34 : 0 : spdk_app_stop(0); 35 : 0 : return; 36 : : } 37 : : 38 [ - + ]: 1 : printf("done.\n"); 39 : : } 40 : : 41 : : static void 42 : 1 : spdk_fuse_run(void *arg1) 43 : : { 44 [ - + ]: 1 : printf("Mounting filesystem on bdev %s to path %s...\n", 45 : : g_bdev_name, g_mountpoint); 46 : 1 : fflush(stdout); 47 : : 48 : 1 : spdk_blobfs_bdev_mount(g_bdev_name, g_mountpoint, fuse_run_cb, NULL); 49 : 1 : } 50 : : 51 : : static void 52 : 1 : spdk_fuse_shutdown(void) 53 : : { 54 : 1 : spdk_app_stop(0); 55 : 1 : } 56 : : 57 : : int 58 : 1 : main(int argc, char **argv) 59 : : { 60 : 1 : struct spdk_app_opts opts = {}; 61 : 1 : int rc = 0; 62 : : 63 [ - + ]: 1 : if (argc < 4) { 64 [ # # # # ]: 0 : fprintf(stderr, "usage: %s <conffile> <bdev name> <mountpoint>\n", argv[0]); 65 : 0 : exit(1); 66 : : } 67 : : 68 : 1 : spdk_app_opts_init(&opts, sizeof(opts)); 69 : 1 : opts.name = "spdk_fuse"; 70 : 1 : opts.json_config_file = argv[1]; 71 : 1 : opts.reactor_mask = "0x3"; 72 : 1 : opts.shutdown_cb = spdk_fuse_shutdown; 73 : : 74 : 1 : g_bdev_name = argv[2]; 75 : 1 : g_mountpoint = argv[3]; 76 : : 77 : : /* TODO: mount blobfs with extra FUSE options. */ 78 : 1 : g_fuse_argc = argc - 2; 79 : 1 : g_fuse_argv = &argv[2]; 80 : : 81 : 1 : spdk_fs_set_cache_size(512); 82 : : 83 : 1 : rc = spdk_app_start(&opts, spdk_fuse_run, NULL); 84 : 1 : spdk_app_fini(); 85 : : 86 : 1 : return rc; 87 : : }