#define FUSE_USE_VERSION 31 #include #include #include #include #include #include #include static int fischl_mkdir(const char *, mode_t) { return 0; } static int fischl_open(const char *path, struct fuse_file_info *fi) { return 0; } static const struct fuse_operations fischl_oper = { .init = fischl_init, .getattr = fischl_getattr, .readdir = fischl_readdir, .open = fischl_open, .mkdir = fischl_mkdir, .read = fischl_read, }; static void show_help(const char *progname) { printf("usage: %s [options] \n\n", progname); printf("File-system specific options:\n" " --name= Name of the \"hello\" file\n" " (default: \"hello\")\n" " --contents= Contents \"hello\" file\n" " (default \"Hello, World!\\n\")\n" "\n"); } int fischl::init(int argc, char *argv[]) { int ret; struct fuse_args args = FUSE_ARGS_INIT(argc, argv); /* Parse options */ if (fuse_opt_parse(&args, &options, option_spec, NULL) == -1) return 1; /* When --help is specified, first print our own file-system specific help text, then signal fuse_main to show additional help (by adding `--help` to the options again) without usage: line (by setting argv[0] to the empty string) */ if (options.show_help) { show_help(argv[0]); assert(fuse_opt_add_arg(&args, "--help") == 0); args.argv[0][0] = '\0'; } ret = fuse_main(args.argc, args.argv, &hello_oper, NULL); fuse_opt_free_args(&args); return ret; }