void SMTPFileSystem::printVersion() const { struct fuse_args args = FUSE_ARGS_INIT(0, NULL); struct fuse_operations tmp_operations; memset(&tmp_operations, 0, sizeof(tmp_operations)); fuse_opt_add_arg(&args, m_args.argv[0]); fuse_opt_add_arg(&args, "--version"); std::cout << "simple-mtpfs version " << VERSION << "\n"; fuse_main(args.argc, args.argv, &tmp_operations, nullptr); fuse_opt_free_args(&args); }
int runfuse(int argc, const char* const* argv) { struct fuse_args fua = FUSE_ARGS_INIT(argc, (char**) argv); struct cuse_info info; const char *iav[] = { "DEVNAME=jrandom",NULL }; vzero(info); info.dev_info_argc = 1; info.dev_info_argv = iav; info.flags = CUSE_UNRESTRICTED_IOCTL; return cuse_lowlevel_main(fua.argc, fua.argv, &info, GET_RNDEV_OPS(), NULL); }
int main(int argc, char *argv[]) { fuse_args args = FUSE_ARGS_INIT(argc, argv); arg_ctx arg_ctx; if (fuse_opt_parse(&args, &arg_ctx, fuse_opts, fuse_opt_proc) == -1) { return EXIT_FAILURE; } int fd = -1; if (!arg_ctx.show_help) { if (!arg_ctx.source_file) { fprintf(stderr, "Missing source file\n"); return EXIT_FAILURE; } if (!arg_ctx.target_file) { fprintf(stderr, "Missing target file (mount point) parameter\n"); return EXIT_FAILURE; } fd = open(arg_ctx.source_file, O_RDONLY | O_CLOEXEC); if (fd < 0) { fprintf(stderr, "%s: Failed to open: %s\n", arg_ctx.source_file, strerror(errno)); return EXIT_FAILURE; } snprintf(source_fd_path, sizeof(source_fd_path), "/proc/self/fd/%d", fd); if (get_sparse_file_size() < 0) { close(fd); return EXIT_FAILURE; } } fuse_operations fuse_oper = {}; fuse_oper.getattr = fuse_getattr; fuse_oper.open = fuse_open; fuse_oper.read = fuse_read; fuse_oper.release = fuse_release; int fuse_ret = fuse_main(args.argc, args.argv, &fuse_oper, nullptr); if (!arg_ctx.show_help) { close(fd); } fuse_opt_free_args(&args); free(arg_ctx.source_file); free(arg_ctx.target_file); return fuse_ret; }
int main (int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT (argc, argv); g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR); if (fuse_opt_parse (&args, NULL, NULL, opt_process) == -1) g_critical ("usage: %s <query> <mount point>", argv[0]); return fuse_main (args.argc, args.argv, &beagle_file_ops); }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); memset(current_buffer, 0, sizeof(current_buffer)); memset(display_buffer, 0, sizeof(display_buffer)); fuse_opt_parse(&args, NULL, display_options, option_processor); // run fuse return fuse_main(args.argc, args.argv, &display_operations, NULL); }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); init_syslog(); uopt_init(); if (fuse_opt_parse(&args, NULL, unionfs_opts, unionfs_opt_proc) == -1) RETURN(1); if (uopt.debug) debug_init(); if (!uopt.doexit) { if (uopt.nbranches == 0) { printf("You need to specify at least one branch!\n"); RETURN(1); } } // enable fuse permission checks, we need to set this, even we we are // not root, since we don't have our own access() function int uid = getuid(); int gid = getgid(); bool default_permissions = true; if (uid != 0 && gid != 0 && uopt.relaxed_permissions) { default_permissions = false; } else if (uopt.relaxed_permissions) { // protec the user of a very critical security issue fprintf(stderr, "Relaxed permissions disallowed for root!\n"); exit(1); } if (default_permissions) { if (fuse_opt_add_arg(&args, "-odefault_permissions")) { fprintf(stderr, "Severe failure, can't enable permssion checks, aborting!\n"); exit(1); } } unionfs_post_opts(); #ifdef FUSE_CAP_BIG_WRITES /* libfuse > 0.8 supports large IO, also for reads, to increase performance * We support any IO sizes, so lets enable that option */ if (fuse_opt_add_arg(&args, "-obig_writes")) { fprintf(stderr, "Failed to enable big writes!\n"); exit(1); } #endif umask(0); int res = fuse_main(args.argc, args.argv, &unionfs_oper, NULL); RETURN(uopt.doexit ? uopt.retval : res); }
void sqfs_usage(char *progname, bool fuse_usage) { fprintf(stderr, "%s (c) 2012 Dave Vasilevsky\n\n", PACKAGE_STRING); fprintf(stderr, "Usage: %s [options] ARCHIVE MOUNTPOINT\n", progname ? progname : PACKAGE_NAME); if (fuse_usage) { struct fuse_args args = FUSE_ARGS_INIT(0, NULL); fuse_opt_add_arg(&args, ""); /* progname */ fuse_opt_add_arg(&args, "-ho"); fprintf(stderr, "\n"); fuse_parse_cmdline(&args, NULL, NULL, NULL); } exit(-2); }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); if (fuse_opt_parse(&args, &rbd_options, rbdfs_opts, rbdfs_opt_proc) == -1) { exit(1); } pthread_mutex_init(&readdir_lock, NULL); return fuse_main(args.argc, args.argv, &rbdfs_oper, NULL); }
struct fuse *fuse_setup_common(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, int *multithreaded, int *fd, void *user_data, int compat) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); struct fuse_chan *ch; struct fuse *fuse; int foreground; int res; res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground); if (res == -1) return NULL; ch = fuse_mount_common(*mountpoint, &args); if (!ch) { fuse_opt_free_args(&args); goto err_free; } fuse = fuse_new_common(ch, &args, op, op_size, user_data, compat); fuse_opt_free_args(&args); if (fuse == NULL) goto err_unmount; res = fuse_daemonize(foreground); if (res == -1) goto err_unmount; res = fuse_set_signal_handlers(fuse_get_session(fuse)); if (res == -1) goto err_unmount; if (fd) *fd = fuse_chan_fd(ch); return fuse; err_unmount: fuse_unmount_common(*mountpoint, ch); if (fuse) fuse_destroy(fuse); err_free: free(*mountpoint); return NULL; }
/* * this code is not very sexy but we are forced to follow * the fuse api. * * when f() returns 1 we need to keep the arg * when f() returns 0 we need to discard the arg */ int fuse_opt_parse(struct fuse_args *args, void *data, struct fuse_opt *opt, fuse_opt_proc_t f) { struct fuse_args outargs = FUSE_ARGS_INIT(args->argc, args->argv); const char *arg; int ret = 0; int i; if (!f || !args || !args->argc || !args->argv) return (0); bzero(&outargs, sizeof(args)); fuse_opt_add_arg(&outargs, args->argv[0]); for (i = 1; i < args->argc; i++) { arg = args->argv[i]; /* not - and not -- */ if (arg[0] != '-') { ret = f(data, arg, FUSE_OPT_KEY_NONOPT, 0); if (ret == 1) fuse_opt_add_arg(&outargs, arg); if (ret == -1) goto err; } else if (arg[1] == 'o') { if (arg[2]) arg += 2; /* -ofoo,bar */ else i++; /* -o foo,bar*/ if (ret != 0) return (ret); } else { ret = parse_opt(opt, arg, data, f, &outargs); if (ret == -1) goto err; } } ret = 0; err: /* Update args */ fuse_opt_free_args(args); args->allocated = outargs.allocated; args->argc = outargs.argc; args->argv = outargs.argv; return (ret); }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); opts.config = "pipefs.conf"; if(fuse_opt_parse(&args, &opts, pipefs_opts, pipefs_opt_proc) == -1) { exit(1); } pipefs_read_config(); return fuse_main(args.argc, args.argv, &pipefs_oper, NULL); }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); uid = getuid(); gid = getgid(); now = time(NULL); opts.host = "localhost"; opts.port = CC_XSTREAM_DEFAULT_PORT; opts.user = "******"; opts.pass = ""; opts.root = ""; if(fuse_opt_parse(&args, &opts, ccx_opts, ccx_opt_proc) == -1) { exit(1); } /* normalize to non-abs */ if(opts.root[0] == '/') { opts.root++; } /* not multithreaded */ fuse_opt_add_arg(&args, "-s"); /* 0x20000 (131072) hardcoded max ccx packet size (ccxclient.c) * set max read to max ccx packet - 100 (headers) */ fuse_opt_add_arg(&args, "-omax_readahead=130972"); if(cc_xstream_client_connect(opts.host, opts.port, &ccxconn) != CC_XSTREAM_CLIENT_OK) { fprintf(stderr, "Can't connect to host %s:%d.\n", opts.host, opts.port); exit(1); } if (cc_xstream_client_version_handshake(ccxconn) != CC_XSTREAM_CLIENT_OK) { fprintf(stderr, "Version handshake failed.\n"); exit(1); } if(cc_xstream_client_password_authenticate(ccxconn, opts.user, opts.pass) != CC_XSTREAM_CLIENT_OK) { fprintf(stderr, "Auth failed.\n"); exit(1); } return fuse_main(args.argc, args.argv, &ccx_oper, NULL); }
int main(int argc, char **argv) { struct fuse_args args = FUSE_ARGS_INIT(0, NULL); const char *imgname = NULL, *mntpoint = NULL; char fsname_buf[17 + PATH_MAX]; int r, fd; fuse_opt_add_arg(&args, argv[0]); if (argc < 2) panic("missing image or mountpoint parameter, see help"); for (r = 1; r < argc; r++) { if (imgname == NULL && argv[r][0] != '-' && strcmp(argv[r - 1], "-o") != 0) { imgname = argv[r]; } else if(mntpoint == NULL && argv[r][0] != '-' && strcmp(argv[r - 1], "-o") != 0) { mntpoint = argv[r]; fuse_opt_add_arg(&args, argv[r]); } else { fuse_opt_add_arg(&args, argv[r]); } } // Use a fsname (which shows up in df) in the style of sshfs, another // FUSE-based file system, with format "fsname#fslocation". snprintf(fsname_buf, sizeof(fsname_buf), "-ofsname=CS202fs#%s", imgname); fuse_opt_add_arg(&args, "-s"); // Always run single-threaded. fuse_opt_add_arg(&args, "-odefault_permissions"); // Kernel handles access. fuse_opt_add_arg(&args, fsname_buf); // Set the filesystem name. if (imgname == NULL) { fuse_opt_parse(&args, NULL, fs_opts, fs_parse_opt); return -1; } else { struct inode *dirroot; map_disk_image(imgname, mntpoint); // Make sure the superblock fields are sane. assert(super->s_magic == FS_MAGIC); assert(super->s_root != 0); // Guarantee that the root directory has proper permissions. // This is vital so that we can unmount the disk. dirroot = diskaddr(super->s_root); dirroot->i_mode = S_IFDIR | 0777; fuse_opt_parse(&args, NULL, fs_opts, fs_parse_opt); return fuse_main(args.argc, args.argv, &fs_oper, NULL); } }
int main (int argc, char **argv) { int ret; struct fuse_args args = FUSE_ARGS_INIT (argc, argv); get_mount_point (argc, argv); memset (&options, 0, sizeof (struct options)); if (-1 == fuse_opt_parse (&args, &options, arsenal_opts, NULL)) return -1; ret = fuse_main (args.argc, args.argv, &arsenal_oper, NULL); fuse_opt_free_args (&args); return ret; }
int main(int argc, char *argv[]) { int ret; struct fuse_args args = FUSE_ARGS_INIT(argc, argv); fuse_opt_parse(&args, NULL, NULL, darfs_opt_proc); ret = fuse_main(args.argc, args.argv, &hello_oper, NULL); /** free arguments */ fuse_opt_free_args(&args); return ret; }
int main(int argc, char* argv[]) { umask(0); struct fuse_args args = FUSE_ARGS_INIT(argc, argv); fuse_opt_parse(&args, NULL, NULL, &diskfile_opt_proc); // Need at least a if (diskfile_entries_count < 2) usage(&args); // put the mountpoint back fuse_opt_add_arg(&args, diskfile_entries[--diskfile_entries_count].source); return fuse_main(args.argc, args.argv, &diskfile_operations, NULL); }
/* * First we divide the given arguments into FUSE and cmd arguments, pass the * FUSE arguments to FUSE, and call cmd_Dispatch in the FUSE init function. */ int main(int argc, char **argv) { int code; struct fuse_args args = FUSE_ARGS_INIT(argc-1, &argv[1]); fuse_opt_add_arg(&afsd_args, argv[0]); #ifdef AFS_SUN511_ENV /* for some reason, Solaris 11 FUSE takes the filesystem name from * argv[0], and ignores the -ofsname option */ fuse_opt_add_arg(&fuse_args, "AFS"); #else fuse_opt_add_arg(&fuse_args, argv[0]); #endif /* let us determine file inode numbers, not FUSE. also make "AFS" appear * in df/mount/mnttab/etc output. */ fuse_opt_add_arg(&fuse_args, "-ouse_ino,fsname=AFS"); if (getuid() == 0) { /* allow other users to access the mountpoint. only do this for * root, since non-root may or may not be able to do this */ fuse_opt_add_arg(&fuse_args, "-oallow_other"); } code = uafs_Setup("/afs"); if (code) { errno = code; perror("libuafs"); return 1; } split_args(&args); uafs_ParseArgs(afsd_args.argc, afsd_args.argv); /* pass "-- /mount/dir" to fuse to specify dir to mount; "--" is * just to make sure fuse doesn't interpret the mount dir as a flag */ #ifndef AFS_SUN511_ENV /* This seems to screw up option parsing on Solaris 11 FUSE, so just * don't do it. This makes it slightly more annoying to mount on a dir * called -foo or something, but oh well. */ fuse_opt_add_arg(&fuse_args, "--"); #endif fuse_opt_add_arg(&fuse_args, uafs_MountDir()); return fuse_main(fuse_args.argc, fuse_args.argv, &fuafsd_oper, NULL); }
/** * main */ int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); struct mysqlfs_opt opt = { .init_conns = 1, .max_idling_conns = 5, .mycnf_group = "mysqlfs", #ifdef DEBUG .logfile = "mysqlfs.log", #endif }; log_file = stderr; /** theopts kludge is used for both statusdir (if configured at build) and for osxnospotlight */ theopts = &opt; fuse_opt_parse(&args, &opt, mysqlfs_opts, mysqlfs_opt_proc); if (pool_init(&opt) < 0) { log_printf(LOG_ERROR, "Error: pool_init() failed\n"); fuse_opt_free_args(&args); return EXIT_FAILURE; } /* * I found that -- running from a script (ie no term?) -- the MySQLfs would not background, so the terminal is held; this makes automated testing difficult. * * I (allanc) put this into here to allow for AUTOTEST, but then autotest has to seek-and-destroy the app. This isn't quite perfect yet, I get some flakiness here, othertines the pid is 4 more than the parent, which is odd. */ if (0 < opt.bg) { if (0 < fork()) return EXIT_SUCCESS; //else // fprintf (stderr, "forked %d\n", getpid()); } /* only create a log file if we have a logfile set; note that --enable-debug sets a default above */ if (NULL != opt.logfile) log_file = log_init(opt.logfile, 1); fuse_main(args.argc, args.argv, &mysqlfs_oper); fuse_opt_free_args(&args); pool_cleanup(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); fuse_opt_parse(&args, &dirname, ciopfs_opts, ciopfs_opt_parse); if (single_threaded) { fuse_opt_add_arg(&args, "-s"); log_print("disabling multithreaded mode for root mounted " "filesystem that is accessible for other users " "via the `-o allow_other' option\n"); } umask(0); return fuse_main(args.argc, args.argv, &ciopfs_operations, NULL); }
int main(int argc, char *argv[]) { umask(0); struct fuse_args args = FUSE_ARGS_INIT(argc, argv); fuse_opt_parse(&args, &the_config, cow_opts, cow_opt_proc); if (the_config.src_dir == NULL || the_config.cow_dir == NULL) { fprintf(stderr, "You must specify -o src_dir=... and a -o cow_dir=...\n"); exit(1); } return fuse_main(args.argc, args.argv, &cow_oper, NULL); }
struct fuse_args * parse_options(int argc, char *argv[]) { struct fuse_args * args=calloc(1, sizeof(struct fuse_args)); struct cow_config *conf = cow_getConfig(); int pathmaxcnt = 0; do{ pathmaxcnt++; conf->cwd = calloc(PATH_MAX*pathmaxcnt, sizeof(char)); if(getcwd(conf->cwd, PATH_MAX*pathmaxcnt)==NULL){ free(conf->cwd); conf->cwd = NULL; } }while(conf->cwd==NULL && errno == ERANGE); if(conf->cwd==NULL){ fprintf(stderr, "ERROR: couldnt allocate current working directory buffer (%d)\n", errno); exit(-1); } { struct fuse_args tmp=FUSE_ARGS_INIT(argc, argv); memcpy(args, &tmp, sizeof(struct fuse_args)); } if (fuse_opt_parse(args, cow_getConfig(), cow_opts, cow_opt_proc)==-1) exit(-1); char *cliopt = NULL; int clilen = strlen(FUSE_MP_OPT_STR)+strlen(conf->srcdir)+1; int i = 0; for(i=0;i<conf->dstdircnt;i++){ if(i) clilen++; /* separator character */ clilen += strlen(conf->dstdirs[i]); } clilen++; /* null byte */ cliopt = calloc(clilen, sizeof(char)); sprintf(cliopt, "%s%s=", FUSE_MP_OPT_STR, conf->srcdir); for(i=0;i<conf->dstdircnt;i++){ if(i) strcat(cliopt, ";"); strcat(cliopt, conf->dstdirs[i]); } fuse_opt_insert_arg(args, 1, cliopt); fuse_opt_insert_arg(args, 1, conf->mountpt); return args; }
int main(int argc, char** argv) { try { struct fuse_operations ops; struct fuse_args args = FUSE_ARGS_INIT(0, NULL); if (argc < 3) { showHelp(argv[0]); return 1; } openDisk(argv[1]); memset(&ops, 0, sizeof(ops)); ops.getattr = hfs_getattr; ops.open = hfs_open; ops.read = hfs_read; ops.release = hfs_release; //ops.opendir = hfs_opendir; ops.readdir = hfs_readdir; ops.readlink = hfs_readlink; //ops.releasedir = hfs_releasedir; ops.getxattr = hfs_getxattr; ops.listxattr = hfs_listxattr; for (int i = 0; i < argc; i++) { if (i == 1) ; else fuse_opt_add_arg(&args, argv[i]); } fuse_opt_add_arg(&args, "-oro"); fuse_opt_add_arg(&args, "-s"); std::cout << "Everything looks OK, disk mounted\n"; return fuse_main(args.argc, args.argv, &ops, 0); } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; return 1; } }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(0, NULL); guint8 *key; #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif if (argc < 3 || argc > 4) { goto usage; } if (!g_file_test(argv[1], G_FILE_TEST_EXISTS)) { printf("%s doesn't exist.\n", argv[1]); return 1; } if (!g_file_test(argv[2], G_FILE_TEST_EXISTS)) { printf("%s doesn't exist.\n", argv[2]); return 1; } if (argc == 4) { if (!mdsfs_lockmgr_check_key(argv[3])) return 1; /* Initializing blowfish */ key = mdsfs_misc_hexstrings_to_binary(argv[3]); } /* args */ fuse_opt_add_arg(&args, argv[0]); fuse_opt_add_arg(&args, argv[2]); /* Initiallizing */ mdsfs = mdsfs_core_open(argv[1], key); /* main of FUSE */ return fuse_main(args.argc, args.argv, &mdsfs_op, NULL); usage: printf("Usage: mdsfs [image file] [mount point] {key}\n"); return 1; }
int main(int argc, char* argv[]) { if (argc < 4){ printf("%s url count mnt {else fuse params}\n", argv[0]); return 1; } curl_global_init(CURL_GLOBAL_ALL); strncpy(url, argv[1], sizeof(url) - 1); char *err_strpol; parts = strtol(argv[2] ,&err_strpol, 0); if (*err_strpol != '\0' && parts <= 0){ printf("bad parts %s\n", argv[2]); return 1; } char tmp[NAME_SIZE]; snprintf(tmp, NAME_SIZE, url, parts - 1); file_size = part_size = get_size(tmp); if (part_size == -1){ printf("bad size %s\n", tmp); return 1; } if (parts > 1){ snprintf(tmp, NAME_SIZE, url, 0); part_size = get_size(tmp); if (part_size == -1){ printf("bad size %s\n", tmp); return 1; } file_size += (parts - 1) * part_size; } printf("size = %llu, parts = %d, part = %llu, last = %llu\n", file_size, parts, part_size, file_size - (parts - 1) * part_size); struct fuse_args args = FUSE_ARGS_INIT(0, NULL); fuse_opt_add_arg(&args, argv[0]); fuse_opt_add_arg(&args, "-s"); // single, not need blocking int i; for (i = 3; i < argc; ++i) fuse_opt_add_arg(&args, argv[i]); int res = fuse_main(args.argc, args.argv, &my_operations, NULL); curl_global_cleanup(); return res; }
int main(int argc, char *argv[]) { int res = 0; struct fuse_args args = FUSE_ARGS_INIT(argc, argv); loopback.case_insensitive = 0; if (fuse_opt_parse(&args, &loopback, loopback_opts, NULL) == -1) { exit(1); } umask(0); res = fuse_main(args.argc, args.argv, &loopback_oper, NULL); fuse_opt_free_args(&args); return res; }
int main(int argc, char **argv) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); fuse_opt_parse(&args, NULL, NULL, fuse_ext2_opt_args); if(ext2_dev) { if(fuse_ext2_init(ext2_dev) == -1) { fs_printf("unable to initialize disk device.\n"); return -1; } } else { // TODO } return (fuse_main(args.argc, args.argv, &fuse_ext2_ops, NULL)); }
void process_arguments(int argc, char **argv) { struct zfs_opts zopts; main_args = (struct fuse_args)FUSE_ARGS_INIT(argc, argv); memset(&zopts, 0, sizeof(zopts)); if (fuse_opt_parse (&main_args, &zopts, main_options, handle_one_argument) != 0) { usage(); exit(EXIT_FAILURE); } if (zopts.config) { set_local_config_path(zopts.config); } set_log_level(&syplogger, zopts.loglevel); // start zfsd on background or foreground int foreground; int rv; char * mountpoint; rv = fuse_parse_cmdline(&main_args, &mountpoint, NULL, &foreground); if (rv == -1) { message(LOG_INFO, FACILITY_ZFSD, "Failed to parse fuse cmdline options.\n"); exit(EXIT_FAILURE); } set_mountpoint(mountpoint); free(mountpoint); #ifndef ENABLE_CLI_CONSOLE //cli use console, don't daemonize rv = fuse_daemonize(foreground); if (rv == -1) { message(LOG_INFO, FACILITY_ZFSD, "Failed to daemonize zfsd.\n"); exit(EXIT_FAILURE); } #endif }
static void fuseMount(CompDisplay *d) { char *mountPoint; struct fuse_args args = FUSE_ARGS_INIT(0, NULL); FUSE_DISPLAY(d); mountPoint = strdup(fd->opt[FUSE_DISPLAY_OPTION_MOUNT_POINT].value.s); if (!mountPoint) return; fuse_opt_add_arg(&args, ""); fuse_opt_add_arg(&args, "-o"); fuse_opt_add_arg(&args, "allow_root"); fd->channel = fuse_mount(mountPoint, &args); if (!fd->channel) { fuse_opt_free_args(&args); free(mountPoint); return; } fuse_opt_free_args(&args); fd->buffer = malloc(fuse_chan_bufsize(fd->channel)); if (!fd->buffer) { fuse_unmount(mountPoint, fd->channel); free(mountPoint); fd->channel = NULL; return; } fd->mountPoint = mountPoint; fuse_session_add_chan(fd->session, fd->channel); fd->watchFdHandle = compAddWatchFd(fuse_chan_fd(fd->channel), POLLIN | POLLPRI | POLLHUP | POLLERR, fuseProcessMessages, d); }
struct fuse *fuse_setup(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, int *multithreaded, void *user_data) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); struct fuse_chan *ch=NULL; struct fuse *fuse; int foreground; int res; res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground); rDebug("res=%i", res); if (res == -1) return NULL; ch = fuse_mount(*mountpoint, &args); fuse = fuse_new(ch, &args, op, op_size, user_data); fuse_opt_free_args(&args); if (fuse == NULL || ch==NULL) goto err_unmount; res = fuse_daemonize(foreground); rDebug("res=%i", res); if (res == -1) goto err_unmount; if (fuse->conf.setsignals) { res = fuse_set_signal_handlers(fuse_get_session(fuse)); rDebug("res=%i", res); if (res == -1) goto err_unmount; } return fuse; err_unmount: fuse_unmount(*mountpoint, ch); if (fuse) fuse_destroy(fuse); free(*mountpoint); return NULL; }
int main(int argc, char *argv[]) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); int rc; bzero(&zdsfsinfo, sizeof(zdsfsinfo)); zdsfsinfo.keepRDW = 0; zdsfsinfo.allow_inclomplete_multi_volume = 0; zdsfsinfo.tracks_per_frame = 128; zdsfsinfo.seek_buffer_size = 1048576; rc = lzds_zdsroot_alloc(&zdsfsinfo.zdsroot); if (rc) { fprintf(stderr, "Could not allocate internal structures\n"); exit(1); } if (fuse_opt_parse(&args, &zdsfsinfo, zdsfs_opts, zdsfs_process_args) == -1) { fprintf(stderr, "Failed to parse option\n"); exit(1); } if (!zdsfsinfo.devcount) { fprintf(stderr, "Please specify a block device\n"); fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); exit(1); } rc = zdsfs_verify_datasets(); if (rc) goto cleanup; rc = zdsfs_create_meta_data_buffer(&zdsfsinfo); if (rc) goto cleanup; rc = fuse_main(args.argc, args.argv, &rdf_oper, NULL); cleanup: lzds_zdsroot_free(zdsfsinfo.zdsroot); fuse_opt_free_args(&args); return rc; }