Example #1
0
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;

#ifdef __APPLE__
	if (!*mountpoint) {
		fprintf(stderr, "fuse: no mount point\n");
		return NULL;
	}
#endif

	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;
}
Example #2
0
/**
 * 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;
}
Example #3
0
int
fuse_main_real(int argc, char* argv[], const struct fuse_operations* op,
	size_t opSize, void* userData)
{
printf("fuse_main_real(%d, %p, %p, %ld, %p)\n", argc, argv, op, opSize,
userData);
	// Note: We use the fuse_*() functions here to initialize and run the
	// file system, although some of them are merely dummies.

	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

	int result = 1;

	// create the kernel channel
	struct fuse_chan* channel = fuse_mount("/dummy", &args);
	if (channel != NULL) {
		// create the FUSE handle
		struct fuse* fuseHandle = fuse_new(channel, &args, op, opSize,
			userData);
		if (fuseHandle != NULL) {
			// run the main loop
			result = fuse_loop_mt(fuseHandle);

			fuse_destroy(fuseHandle);
		}

		fuse_unmount("/dummy", channel);
	}

	fuse_opt_free_args(&args);

	return result;
}
Example #4
0
File: πfs.c Project: 47d5b/pifs
int main (int argc, char *argv[])
{
  int ret;
  struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

  memset(&options, 0, sizeof(struct options));
  if (fuse_opt_parse(&args, &options, pifs_opts, NULL) == -1) {
    return -1;
  }

  if (!options.mdd) {
    fprintf(stderr,
            "%s: Metadata directory must be specified with -o mdd=<directory>\n",
            argv[0]);
    return -1;
  }

  if (access(options.mdd, R_OK | W_OK | X_OK) == -1) {
    fprintf(stderr, "%s: Cannot access metadata directory '%s': %s\n",
            argv[0], options.mdd, strerror(errno));
    return -1;
  }

  ret = fuse_main(args.argc, args.argv, &pifs_ops, NULL);
  fuse_opt_free_args(&args);
  return ret;
}
Example #5
0
/*
 * main
 */
int main(int argc, char *argv[])
{
    struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

    fuse_opt_parse(&args, &opt, NULL, memcachefs_opt_proc);

    if(!opt.host){
        usage();
        return EXIT_SUCCESS;
    }

    pool = handle_pool_new(&opt);
    if(!pool){
        perror("malloc()");
        return EXIT_FAILURE;
    }

    if(opt.verbose){
        fprintf(stderr, "mounting to %s:%s\n", opt.host, opt.port);
    }

    fuse_main(args.argc, args.argv, &memcachefs_oper);
    fuse_opt_free_args(&args);
    handle_pool_free(pool);
    return EXIT_SUCCESS;
}
Example #6
0
/**
 * gfuse_loop_set_config:
 * @loop: a #GFuseLoop
 * @argc: number of options in @argv
 * @argv: NULL-terminated array of options to pass to libfuse
 *
 * To init the instance of #GFuseLoop with some option, just as happens in
 * fuse_main(). It is suggested to parse the process' argv outside this
 * function to retrieve custom parameters, and pass here only effectively
 * FUSE's valid options
 */
void gfuse_loop_set_config (GFuseLoop *loop, int argc, gchar **argv)
{
    register int i;
    gchar **dup_argv;
    gboolean foreground_option;

    if (loop->priv->startup_argc != 0) {
        struct fuse_args tmp = FUSE_ARGS_INIT (loop->priv->startup_argc, loop->priv->startup_argv);
        fuse_opt_free_args (&tmp);
    }

    foreground_option = FALSE;
    dup_argv = g_new0 (char*, argc + 2);

    for (i = 0; i < argc; i++) {
        dup_argv [i] = argv [i];
        if (strcmp (argv [i], "-f"))
            foreground_option = TRUE;
    }

    /*
        We always force the "foreground" option, to avoid libfuse unattach
        and daemonize the whole process. It is at the toplevel code to decide
        if switch background
    */
    if (foreground_option == FALSE)
        dup_argv [i] = "-f";

    loop->priv->startup_argc = argc + (foreground_option == FALSE ? 1 : 0);
    loop->priv->startup_argv = dup_argv;
}
Example #7
0
static int unmount_root(void)
{
	int r;

	if (!root->mounted)
		return -EINVAL;

	mounts_remove(root);

	if (root->session)
		fuse_session_destroy(root->session); // also destroys root->channel
	if (root->channel_fd >= 0)
		(void) close(root->channel_fd);

	// only use fuse_unmount if there are no nested mounts
	if (nmounts == 0)
		fuse_unmount(root->mountpoint);

	fuse_opt_free_args(&root->args);

	free(root->mountpoint);
	free(root->fstitch_path);
	hash_map_destroy(root->parents);

	memset(root, 0, sizeof(*root));
	free(root);
	root = NULL;

	if ((r = helper_shutdown()) < 0)
		fprintf(stderr, "%s(): helper_shutdown() failed (%d), continuing anyway\n", __FUNCTION__, r);

	destroy_locals();

	return 0;
}
Example #8
0
int
main(int argc, char *argv[])
{
  int result;
  struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

  memset(&stormfs, 0, sizeof(struct stormfs));
  stormfs.progname = argv[0];
  stormfs.service = AMAZON;
  set_defaults();

  if(fuse_opt_parse(&args, &stormfs, stormfs_opts, stormfs_opt_proc) == -1) {
    fprintf(stderr, "%s: error parsing command-line options\n", stormfs.progname);
    exit(EXIT_FAILURE);
  }

  parse_config(stormfs.config);
  validate_config();
  if(stormfs.rrs)
    stormfs.storage_class = "REDUCED_REDUNDANCY";

  stormfs.virtual_url = stormfs_virtual_url(stormfs.url, stormfs.bucket);

  g_thread_init(NULL);
  result = stormfs_fuse_main(&args);

  fuse_opt_free_args(&args);

  return result;
}
Example #9
0
int fuse_opt_parse(struct fuse_args *args, void *data,
		   const struct fuse_opt opts[], fuse_opt_proc_t proc)
{
	int res;
	struct fuse_opt_context ctx = {
		.data = data,
		.opt = opts,
		.proc = proc,
	};

	if (!args || !args->argv || !args->argc)
		return 0;

	ctx.argc = args->argc;
	ctx.argv = args->argv;

	res = opt_parse(&ctx);
	if (res != -1) {
		struct fuse_args tmp = *args;
		*args = ctx.outargs;
		ctx.outargs = tmp;
	}
	free(ctx.opts);
	fuse_opt_free_args(&ctx.outargs);
	return res;
}
Example #10
0
int main(int argc, char *argv[])
{
    struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
    char *mountpoint;
    int err = -1;
    int fd;

    if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) != -1 &&
        (fd = fuse_mount(mountpoint, &args)) != -1) {
        struct fuse_session *se;

        se = fuse_lowlevel_new(&args, &hello_ll_oper, sizeof(hello_ll_oper),
                               NULL);
        if (se != NULL) {
            if (fuse_set_signal_handlers(se) != -1) {
                struct fuse_chan *ch = fuse_kern_chan_new(fd);
                if (ch != NULL) {
                    fuse_session_add_chan(se, ch);
                    err = fuse_session_loop(se);
                }
                fuse_remove_signal_handlers(se);
            }
            fuse_session_destroy(se);
        }
        close(fd);
    }
    fuse_unmount(mountpoint);
    fuse_opt_free_args(&args);

    return err ? 1 : 0;
}
Example #11
0
int fuse_serve_mount_start_shutdown(void)
{
	char b = 1;
	int i = 0;
	bool failed_found;
	Dprintf("%s()\n", __FUNCTION__);

	if (shutdown_has_started())
		return -1;

	helper.shutdown_started = 1;

	// NOTE: we can probably update this and helper_thread's code
	// so that calling this function shortly after an add or remove is
	// safe.
	while (helper.alive)
	{
		if (++i > 4*MAX_START_SHUTDOWN_WAIT)
		{
			fprintf(stderr, "%s(): Mounts or unmounts still in progress. Good luck with the shutdown!\n", __FUNCTION__);
			break;
		}
		jsleep(HZ / 4);
	}

	// Purge failed mounts
	do {
		mount_t ** mp;
		failed_found = 0;
		for (mp = mounts; mp && *mp; mp++)
			if (!(*mp)->mounted) {
				mount_t * m = *mp;
				failed_found = 1;
				mounts_remove(m);
				free(m->fstitch_path);
				fuse_opt_free_args(&m->args);
				free(m->mountpoint);
				hash_map_destroy(m->parents);
				memset(m, 0, sizeof(*m));
				free(m);
				break;
			}
	} while (failed_found);

	// If only root is mounted unmount it and return shutdown
	if (nmounts == 1)
		return unmount_root();

	// Start the calling of fuse_serve_mount_step_shutdown()
	if (write(unmount_pipe[1], &b, 1) != 1)
	{
		perror("fuse_serve_mount_start_shutdown(): write");
		helper.shutdown_started = 0;
		return -1;
	}

	return 0;
}
Example #12
0
int main(int argc, char *argv[]) 
{
    int ret;

	//create the log
	creatlogfile();
	servlog(INFO, "%s", "fsys start");

    struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

    if (fuse_opt_parse(&args, &params, fsys_opts, fsys_opt_proc)) 
	{
        fprintf(stderr, "Error parsing options.\n\n");
        usage(argv[0]);
        return 1;
    }

    if (!params.basepath) 
	{
        fprintf(stderr, "No valid flacdir specified.\n\n");
        usage(argv[0]);
        return 1;
    }

    if (params.basepath[0] != '/') 
	{
        fprintf(stderr, "flacdir must be an absolute path.\n\n");
        usage(argv[0]);
        return 1;
    }

    struct stat st;
    if (stat(params.basepath, &st) != 0 || !S_ISDIR(st.st_mode)) 
	{
        fprintf(stderr, "flacdir is not a valid directory: %s\n",
                params.basepath);
        fprintf(stderr, "Hint: Did you specify bitrate using the old "
                "syntax instead of the new -b?\n\n");
        usage(argv[0]);
        return 1;
    }

    /* Log to the screen if debug is enabled. */
    openlog("fsys", params.debug ? LOG_PERROR : 0, LOG_USER);

    servlog(INFO, "FSYS options:basepath->%s", params.basepath);

    // start FUSE
	umask(0);
    ret = fuse_main(args.argc, args.argv, &fsys_ops, NULL);

    fuse_opt_free_args(&args);

	servlog(INFO, "%s", "fsys have quited out");
	closelog();

    return ret;
}
Example #13
0
File: fuse.c Project: zmike/compiz
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);
}
Example #14
0
static 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;
	struct fuse *fuse;
	int foreground;
	int res;

	res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground);
	if (res == -1)
		return NULL;

	ch = fuse_mount(*mountpoint, &args);
	if (!ch) {
		fuse_opt_free_args(&args);
		goto err_free;
	}

	fuse = fuse_new(ch, &args, op, op_size, user_data);
	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;

	return fuse;

err_unmount:
	fuse_unmount(*mountpoint, ch);
	if (fuse)
		fuse_destroy(fuse);
err_free:
	free(*mountpoint);
	return NULL;
}
Example #15
0
int main(int argc, char *argv[]){
  // Initialize an empty argument list                                                  
  struct fuse_args mountpt = FUSE_ARGS_INIT(0, NULL);
  // add program and mountpoint                                   
  fuse_opt_add_arg(&mountpt, argv[0]);
  fuse_opt_add_arg(&mountpt, argv[1]);
  //fuse_opt_add_arg(&mountpt, argv[2]);// for debug                            
  //fuse_opt_add_arg(&mountpt, argv[3]);// for debug                   

  log_file_path= argv[2];
  fs_size=atoi(argv[3])*1000000;
  num_blocks=fs_size/block_size;
  if(num_blocks < 1000){
    free_space =block_size;
  }else
  free_space=block_size*4;

  dictionary= malloc(num_blocks*sizeof(int));
  log_fp = fopen (log_file_path,"a+");
  if (log_fp == NULL) {
    printf ("Data file could not be opened\n");
    return 1;
  }
  initialize_dictionary();
  mount=time(NULL);

  struct fuse_args args = FUSE_ARGS_INIT(mountpt.argc, mountpt.argv);
  struct fuse_chan *ch;
  char *mountpoint;
  int err = -1;
  if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) != -1 &&
      (ch = fuse_mount(mountpoint, &args)) != NULL) {
    struct fuse_session *se;
    se = fuse_lowlevel_new(&args, &lfs_ll_oper,
			   sizeof(lfs_ll_oper), NULL);
    if (se != NULL) {
      if (fuse_set_signal_handlers(se) != -1) {
	fuse_session_add_chan(se, ch);
	/* Block until ctrl+c or fusermount -u */
	err = fuse_session_loop(se);
	fuse_remove_signal_handlers(se);
	fuse_session_remove_chan(ch);
      }
      fuse_session_destroy(se);
      unmount=time(NULL);
      write_stats();
    }
    fuse_unmount(mountpoint, ch);
  }
  fuse_opt_free_args(&args);
  free(dictionary);
  fclose(log_fp);
  return err ? 1 : 0;

}
Example #16
0
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);
        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;
    memset(&fuse_oper, 0, sizeof(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;
}
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);
}
struct fuse_session *fuse_lowlevel_new_compat(const char *opts,
				const struct fuse_lowlevel_ops_compat *op,
				size_t op_size, void *userdata)
{
	struct fuse_session *se;
	struct fuse_args args = FUSE_ARGS_INIT(0, NULL);

	if (opts &&
	    (fuse_opt_add_arg(&args, "") == -1 ||
	     fuse_opt_add_arg(&args, "-o") == -1 ||
	     fuse_opt_add_arg(&args, opts) == -1)) {
		fuse_opt_free_args(&args);
		return NULL;
	}
	se = fuse_lowlevel_new(&args, (const struct fuse_lowlevel_ops *) op,
			       op_size, userdata);
	fuse_opt_free_args(&args);

	return se;
}
Example #19
0
/*
 * 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,
    const struct fuse_opt *opt, fuse_opt_proc_t f)
{
	struct fuse_args outargs;
	const char *arg;
	int ret = 0;
	int i;

	if (!f || !args || !args->argc || !args->argv)
		return (0);

	bzero(&outargs, sizeof(outargs));
	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
				arg = args->argv[++i];

			ret = parse_opt(opt, arg, data, f, &outargs);

			if (ret == -1)
				goto err;
		} 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);
}
Example #20
0
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;
}
Example #21
0
File: fuse.c Project: gderosa/darfs
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;
}
Example #22
0
int main(int argc, char *argv[]) {
	struct fuse_args args;
	sqfs_opts opts;
	sqfs_hl *hl;
	int ret;
	
	struct fuse_opt fuse_opts[] = {
		{"offset=%u", offsetof(sqfs_opts, offset), 0},
		FUSE_OPT_END
	};

	struct fuse_operations sqfs_hl_ops;
	memset(&sqfs_hl_ops, 0, sizeof(sqfs_hl_ops));
	sqfs_hl_ops.init			= sqfs_hl_op_init;
	sqfs_hl_ops.destroy		= sqfs_hl_op_destroy;
	sqfs_hl_ops.getattr		= sqfs_hl_op_getattr;
	sqfs_hl_ops.opendir		= sqfs_hl_op_opendir;
	sqfs_hl_ops.releasedir	= sqfs_hl_op_releasedir;
	sqfs_hl_ops.readdir		= sqfs_hl_op_readdir;
	sqfs_hl_ops.open		= sqfs_hl_op_open;
	sqfs_hl_ops.create		= sqfs_hl_op_create;
	sqfs_hl_ops.release		= sqfs_hl_op_release;
	sqfs_hl_ops.read		= sqfs_hl_op_read;
	sqfs_hl_ops.readlink	= sqfs_hl_op_readlink;
	sqfs_hl_ops.listxattr	= sqfs_hl_op_listxattr;
	sqfs_hl_ops.getxattr	= sqfs_hl_op_getxattr;
  
	args.argc = argc;
	args.argv = argv;
	args.allocated = 0;
	
	opts.progname = argv[0];
	opts.image = NULL;
	opts.mountpoint = 0;
	opts.offset = 0;
	if (fuse_opt_parse(&args, &opts, fuse_opts, sqfs_opt_proc) == -1)
		sqfs_usage(argv[0], true);
	if (!opts.image)
		sqfs_usage(argv[0], true);
	
	hl = sqfs_hl_open(opts.image, opts.offset);
	if (!hl)
		return -1;
	
	fuse_opt_add_arg(&args, "-s"); /* single threaded */
	ret = fuse_main(args.argc, args.argv, &sqfs_hl_ops, hl);
	fuse_opt_free_args(&args);
	return ret;
}
Example #23
0
File: fs.cpp Project: 8l/vdev
// get the mountpoint option, by parsing the FUSE command line 
static int vdev_get_mountpoint( int fuse_argc, char** fuse_argv, char** ret_mountpoint ) {
   
   struct fuse_args fargs = FUSE_ARGS_INIT(fuse_argc, fuse_argv);
   char* mountpoint = NULL;
   int unused_1;
   int unused_2;
   int rc = 0;
   
   // parse command-line...
   rc = fuse_parse_cmdline( &fargs, &mountpoint, &unused_1, &unused_2 );
   if( rc < 0 ) {

      vdev_error("fuse_parse_cmdline rc = %d\n", rc );
      fuse_opt_free_args(&fargs);

      return rc;
   }
   
   else {
      
      if( mountpoint != NULL ) {
         
         *ret_mountpoint = strdup( mountpoint );
         free( mountpoint );
         
         rc = 0;
      }
      else {
         rc = -ENOMEM;
      }
      
      fuse_opt_free_args(&fargs);
   }
   
   return 0;
}     
Example #24
0
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;
}
Example #25
0
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;
}
void SMTPFileSystem::printHelp() const
{
    struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
    struct fuse_operations tmp_operations;
    memset(&tmp_operations, 0, sizeof(tmp_operations));
    std::cout << "usage: " << m_args.argv[0] << " mountpoint [options]\n\n"
        << "general options:\n"
        << "    -o opt,[opt...]        mount options\n"
        << "    -h   --help            print help\n"
        << "    -V   --version         print version\n\n"
        << "simple-mtpfs options:\n"
        << "    -l   --list-devices    print available devices\n"
        << "         --device          select a device number to mount\n"
        << "    -o enable-move         enable the move operations\n"
        << "    -o tmp-dir=PATH        define a temporary directory for data storage\n\n";
    fuse_opt_add_arg(&args, m_args.argv[0]);
    fuse_opt_add_arg(&args, "-ho");
    fuse_main(args.argc, args.argv, &tmp_operations, nullptr);
    fuse_opt_free_args(&args);
    std::cout << "\nReport bugs to <" << PACKAGE_BUGREPORT << ">.\n";
}
Example #27
0
File: modfs.c Project: jgraef/aNXT
int main(int argc,char *argv[]) {
  int ret = 0;
  struct fuse_args args = FUSE_ARGS_INIT(argc,argv);
  memset(&options,0,sizeof(struct options));
  if (fuse_opt_parse(&args,&options,nxtfs_opts,NULL)==-1) return 1;

  nxt = nxt_open(options.name);
  if (nxt!=NULL) {
    get_modules();
#ifdef FUSE_VERSION_2_5
    ret = fuse_main(args.argc,args.argv,&nxtfs_oper);
#else
    ret = fuse_main(args.argc,args.argv,&nxtfs_oper,NULL);
#endif
    nxt_close(nxt);
  }
  else ret = 1;

  fuse_opt_free_args(&args);
  return ret;
}
Example #28
0
int
fuse_opt_parse(struct fuse_args *args, void *data,
		const struct fuse_opt *opts, fuse_opt_proc_t proc)
{
	struct fuse_args outargs = FUSE_ARGS_INIT(0, NULL);
	int rv;

	if (!args || !args->argv || !args->argc)
		return 0;

	rv = parse_all(args, &outargs, data, opts, proc);
	if (rv != -1) {
		/* Succeeded. Swap the outargs and args. */
		struct fuse_args tmp = *args;
		*args = outargs;
		outargs = tmp;
	}

	fuse_opt_free_args(&outargs);
	return rv;
}
void SMTPFileSystem::printHelp() const
{
    struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
    struct fuse_operations tmp_operations;
    memset(&tmp_operations, 0, sizeof(tmp_operations));
    std::cerr << "usage: " << smtpfs_basename(m_args.argv[0])
              << " <source> mountpoint [options]\n\n"
        << "general options:\n"
        << "    -o opt,[opt...]        mount options\n"
        << "    -h   --help            print help\n"
        << "    -V   --version         print version\n\n"
        << "simple-mtpfs options:\n"
        << "    -v   --verbose         verbose output, implies -f\n"
        << "    -l   --list-devices    print available devices. Supports <source> option\n"
        << "         --device          select a device number to mount\n"
        << "    -o enable-move         enable the move operations\n\n";
    fuse_opt_add_arg(&args, m_args.argv[0]);
    fuse_opt_add_arg(&args, "-ho");
    fuse_main(args.argc, args.argv, &tmp_operations, nullptr);
    fuse_opt_free_args(&args);
    std::cerr << "\nReport bugs to <" << PACKAGE_BUGREPORT << ">.\n";
}
Example #30
0
int main(int argc, char *argv[])
{
	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
	struct fuse_chan *ch;
	char *mountpoint;
	int ret = -1;
	struct lo_data lo = { .debug = 0 };

	if (fuse_opt_parse(&args, &lo, lo_opts, NULL) == -1)
		exit(1);
	lo.root.next = lo.root.prev = &lo.root;
	lo.root.fd = open("/", O_PATH);
	lo.root.nlookup = 2;
	if (lo.root.fd == -1)
		err(1, "open(\"/\", O_PATH)");

	if (fuse_parse_cmdline(&args, &mountpoint, NULL, NULL) != -1 &&
	    (ch = fuse_mount(mountpoint, &args)) != NULL) {
		struct fuse_session *se;
		se = fuse_lowlevel_new(&args, &lo_oper, sizeof(lo_oper), &lo);
		if (se != NULL) {
			if (fuse_set_signal_handlers(se) != -1) {
				fuse_session_add_chan(se, ch);
				ret = fuse_session_loop(se);
				fuse_remove_signal_handlers(se);
				fuse_session_remove_chan(ch);
			}
			fuse_session_destroy(se);
		}
		fuse_unmount(mountpoint, ch);
		free(mountpoint);
	}
	fuse_opt_free_args(&args);

	while (lo.root.next != &lo.root)
		lo_free(lo.root.next);

	return ret ? 1 : 0;
}