Import librefuse and libpuffs
Import libpuffs and our port of libpuffs. The port was done as part of GSoC 2011 FUSE project, done by Evgeniy Ivanov. The librefuse import did not require any porting efforts. Libpuffs has been modified to understand our VFS-FS protocol and translate between that and PUFFS. As an example that it works, fuse-ntfs-3g from pkgsrc can be compiled and used to mount ntfs partitions: mount -t ntfs-3g <device> <mountpoint> FUSE only works with the asynchronous version of VFS. See <docs/UPDATING> on how to run AVFS. This patch further includes some changes to mount(1) and mount(2) so it's possible to use file systems provided by pkgsrc (note: manual modifications to /etc/system.conf are still needed. There has been made an exception for fuse-ntfs-3g, so it already as an entry).
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# $NetBSD: Makefile,v 1.8 2007/11/05 13:41:52 pooka Exp $
|
||||
|
||||
USE_FORT?= yes # data driven bugs?
|
||||
|
||||
LIB= refuse
|
||||
LIBDPLIBS+= puffs ${.CURDIR}/../libpuffs
|
||||
|
||||
.ifdef DEBUG
|
||||
FUSE_OPT_DEBUG_FLAGS= -g -DFUSE_OPT_DEBUG
|
||||
.endif
|
||||
|
||||
CFLAGS+= ${FUSE_OPT_DEBUG_FLAGS}
|
||||
SRCS= refuse.c refuse_opt.c
|
||||
MAN= refuse.3
|
||||
WARNS= 4
|
||||
INCS= fuse.h fuse_opt.h
|
||||
INCSDIR= /usr/include
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
@@ -0,0 +1,25 @@
|
||||
$NetBSD: TODO,v 1.3 2007/05/03 21:02:54 agc Exp $
|
||||
|
||||
To Do
|
||||
=====
|
||||
address all XXX
|
||||
implement all fuse_opt
|
||||
implement proper lookup (pending some libpuffs stuff)
|
||||
support fuse_mt (i.e. worker threads, but that'll probably be smarter
|
||||
to do inside of libpuffs)
|
||||
support fuse_ll (i.e. "raw" vfs/vnode export)
|
||||
implement all sorts of compat tweaks to appease various file systems
|
||||
do proper implementations of dirfillers
|
||||
statfs - some fuse file systems want struct statfs and we only have
|
||||
statvfs available natively
|
||||
|
||||
Done
|
||||
====
|
||||
statvfs
|
||||
sync
|
||||
WARNS=4
|
||||
address lint
|
||||
special directory handling in open()
|
||||
Finish off manual page
|
||||
fuse_setup
|
||||
fuse_teardown
|
||||
@@ -0,0 +1,193 @@
|
||||
/* $NetBSD: fuse.h,v 1.21 2008/08/01 15:54:09 dillo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright © 2007 Alistair Crooks. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
#ifndef FUSE_H_
|
||||
#define FUSE_H_ 20070123
|
||||
|
||||
/* set the default version to use for the fuse interface */
|
||||
/* this value determines the API to be used */
|
||||
#ifndef FUSE_USE_VERSION
|
||||
#define FUSE_USE_VERSION 26
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <puffs.h>
|
||||
#include <utime.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct fuse;
|
||||
struct fuse_args; /* XXXsupportme */
|
||||
|
||||
struct fuse_file_info {
|
||||
int32_t flags;
|
||||
uint32_t fh_old;
|
||||
int32_t writepage;
|
||||
uint32_t direct_io:1;
|
||||
uint32_t keep_cache:1;
|
||||
uint32_t flush:1;
|
||||
uint32_t padding:29;
|
||||
uint64_t fh;
|
||||
uint64_t lock_owner;
|
||||
};
|
||||
|
||||
struct fuse_conn_info {
|
||||
uint32_t proto_major;
|
||||
uint32_t proto_minor;
|
||||
uint32_t async_read;
|
||||
uint32_t max_write;
|
||||
uint32_t max_readahead;
|
||||
uint32_t reserved[27];
|
||||
};
|
||||
|
||||
/* equivalent'ish of puffs_cc */
|
||||
struct fuse_context {
|
||||
struct fuse *fuse;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
pid_t pid;
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Argument list
|
||||
*/
|
||||
struct fuse_args {
|
||||
int argc;
|
||||
char **argv;
|
||||
int allocated;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializer for 'struct fuse_args'
|
||||
*/
|
||||
#define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 }
|
||||
|
||||
typedef struct puffs_fuse_dirh *fuse_dirh_t;
|
||||
|
||||
typedef int (*fuse_fill_dir_t)(void *, const char *, const struct stat *, off_t);
|
||||
typedef int (*fuse_dirfil_t)(fuse_dirh_t, const char *, int, ino_t);
|
||||
|
||||
#define FUSE_VERSION 26
|
||||
#define FUSE_MAJOR_VERSION 2
|
||||
#define FUSE_MINOR_VERSION 6
|
||||
|
||||
/*
|
||||
* These operations shadow those in puffs_usermount, and are used
|
||||
* as a table of callbacks to make when file system requests come
|
||||
* in.
|
||||
*
|
||||
* NOTE: keep same order as fuse
|
||||
*/
|
||||
struct fuse_operations {
|
||||
int (*getattr)(const char *, struct stat *);
|
||||
int (*readlink)(const char *, char *, size_t);
|
||||
int (*getdir)(const char *, fuse_dirh_t, fuse_dirfil_t);
|
||||
int (*mknod)(const char *, mode_t, dev_t);
|
||||
int (*mkdir)(const char *, mode_t);
|
||||
int (*unlink)(const char *);
|
||||
int (*rmdir)(const char *);
|
||||
int (*symlink)(const char *, const char *);
|
||||
int (*rename)(const char *, const char *);
|
||||
int (*link)(const char *, const char *);
|
||||
int (*chmod)(const char *, mode_t);
|
||||
int (*chown)(const char *, uid_t, gid_t);
|
||||
int (*truncate)(const char *, off_t);
|
||||
int (*utime)(const char *, struct utimbuf *);
|
||||
int (*open)(const char *, struct fuse_file_info *);
|
||||
int (*read)(const char *, char *, size_t, off_t, struct fuse_file_info *);
|
||||
int (*write)(const char *, const char *, size_t, off_t, struct fuse_file_info *);
|
||||
int (*statfs)(const char *, struct statvfs *);
|
||||
int (*flush)(const char *, struct fuse_file_info *);
|
||||
int (*release)(const char *, struct fuse_file_info *);
|
||||
int (*fsync)(const char *, int, struct fuse_file_info *);
|
||||
int (*setxattr)(const char *, const char *, const char *, size_t, int);
|
||||
int (*getxattr)(const char *, const char *, char *, size_t);
|
||||
int (*listxattr)(const char *, char *, size_t);
|
||||
int (*removexattr)(const char *, const char *);
|
||||
int (*opendir)(const char *, struct fuse_file_info *);
|
||||
int (*readdir)(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *);
|
||||
int (*releasedir)(const char *, struct fuse_file_info *);
|
||||
int (*fsyncdir)(const char *, int, struct fuse_file_info *);
|
||||
void *(*init)(struct fuse_conn_info *);
|
||||
void (*destroy)(void *);
|
||||
int (*access)(const char *, int);
|
||||
int (*create)(const char *, mode_t, struct fuse_file_info *);
|
||||
int (*ftruncate)(const char *, off_t, struct fuse_file_info *);
|
||||
int (*fgetattr)(const char *, struct stat *, struct fuse_file_info *);
|
||||
int (*lock)(const char *, struct fuse_file_info *, int, struct flock *);
|
||||
int (*utimens)(const char *, const struct timespec *);
|
||||
int (*bmap)(const char *, size_t , uint64_t *);
|
||||
};
|
||||
|
||||
|
||||
struct fuse_chan *fuse_mount(const char *, struct fuse_args *);
|
||||
struct fuse *fuse_new(struct fuse_chan *, struct fuse_args *,
|
||||
const struct fuse_operations *, size_t, void *);
|
||||
|
||||
int fuse_main_real(int, char **, const struct fuse_operations *, size_t, void *);
|
||||
int fuse_loop(struct fuse *);
|
||||
struct fuse_context *fuse_get_context(void);
|
||||
void fuse_exit(struct fuse *);
|
||||
void fuse_destroy(struct fuse *);
|
||||
|
||||
void fuse_unmount(const char *, struct fuse_chan *);
|
||||
|
||||
struct fuse *fuse_setup(int, char **, const struct fuse_operations *,
|
||||
size_t, char **, int *, int *);
|
||||
void fuse_teardown(struct fuse *, char *);
|
||||
|
||||
#if FUSE_USE_VERSION == 22
|
||||
#define fuse_unmount fuse_unmount_compat22
|
||||
#endif
|
||||
|
||||
void fuse_unmount_compat22(const char *);
|
||||
|
||||
#if FUSE_USE_VERSION >= 26
|
||||
#define fuse_main(argc, argv, op, arg) \
|
||||
fuse_main_real(argc, argv, op, sizeof(*(op)), arg)
|
||||
#define fuse_setup fuse_setup26
|
||||
#else
|
||||
#define fuse_main(argc, argv, op) \
|
||||
fuse_main_real(argc, argv, op, sizeof(*(op)), NULL)
|
||||
#endif
|
||||
|
||||
struct fuse *fuse_setup26(int, char **, const struct fuse_operations *,
|
||||
size_t, char **, int *, void *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <fuse_opt.h>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/* $NetBSD: fuse_opt.h,v 1.5 2009/04/19 22:25:29 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Alistair Crooks. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _FUSE_OPT_H_
|
||||
#define _FUSE_OPT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
FUSE_OPT_KEY_OPT = -1,
|
||||
FUSE_OPT_KEY_NONOPT = -2,
|
||||
FUSE_OPT_KEY_KEEP = -3,
|
||||
FUSE_OPT_KEY_DISCARD = -4
|
||||
};
|
||||
|
||||
struct fuse_opt {
|
||||
const char *templ;
|
||||
int32_t offset;
|
||||
int32_t value;
|
||||
};
|
||||
|
||||
#define FUSE_OPT_KEY(templ, key) { templ, -1U, key }
|
||||
#define FUSE_OPT_END { .templ = NULL }
|
||||
|
||||
typedef int (*fuse_opt_proc_t)(void *, const char *, int, struct fuse_args *);
|
||||
|
||||
|
||||
int fuse_opt_add_arg(struct fuse_args *, const char *);
|
||||
struct fuse_args *fuse_opt_deep_copy_args(int, char **);
|
||||
void fuse_opt_free_args(struct fuse_args *);
|
||||
int fuse_opt_insert_arg(struct fuse_args *, int, const char *);
|
||||
int fuse_opt_add_opt(char **, const char *);
|
||||
int fuse_opt_parse(struct fuse_args *, void *,
|
||||
const struct fuse_opt *, fuse_opt_proc_t);
|
||||
int fuse_opt_match(const struct fuse_opt *, const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FUSE_OPT_H_ */
|
||||
@@ -0,0 +1,243 @@
|
||||
.\" $NetBSD: refuse.3,v 1.7 2007/11/08 17:08:46 pooka Exp $
|
||||
.\"
|
||||
.\" Copyright © 2007 Alistair Crooks. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. 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.
|
||||
.\" 3. The name of the author may not be used to endorse or promote
|
||||
.\" products derived from this software without specific prior written
|
||||
.\" permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
.\"
|
||||
.Dd April 30, 2007
|
||||
.Dt REFUSE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm refuse
|
||||
.Nd Re-implementation of a file system in userspace system
|
||||
.Sh LIBRARY
|
||||
.Lb librefuse
|
||||
.Sh SYNOPSIS
|
||||
.In fuse.h
|
||||
.Ft int
|
||||
.Fo fuse_main
|
||||
.Fa "int argc" "char **argv" "const struct fuse_operations *"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo fuse_opt_add_arg
|
||||
.Fa "struct fuse_args *args" "const char *arg"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo fuse_opt_parse
|
||||
.Fa "struct fuse_args *args" "void *userdata"
|
||||
.Fa "const struct fuse_opt *descriptions" "fuse_opt_proc_t processingfunc"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo fuse_teardown
|
||||
.Fa "struct fuse *fuse" "char *mountpoint"
|
||||
.Fc
|
||||
.Ft struct fuse *
|
||||
.Fo fuse_setup
|
||||
.Fa "int argc" "char **argv" "const struct fuse_operations *ops"
|
||||
.Fa "size_t opssize" "char **mountpoint" "int *multithreaded" "int *fd"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_getattr
|
||||
.Fa "const char *path" "struct stat *attrs"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_readlink
|
||||
.Fa "const char *path" "char *output" "size_t outlen"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_mknod
|
||||
.Fa "const char *path" "mode_t permissions" "dev_t devicenumber"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_mkdir
|
||||
.Fa "const char *path" "mode_t permissions"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_unlink
|
||||
.Fa "const char *path"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_rmdir
|
||||
.Fa "const char *path"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_symlink
|
||||
.Fa "const char *path" "const char *target"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_rename
|
||||
.Fa "const char *from" "const char *to"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_link
|
||||
.Fa "const char *from" "const char *to"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_chmod
|
||||
.Fa "const char *path" "mode_t permissions"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_own
|
||||
.Fa "const char *path" "uid_t owner" "gid_t group"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_truncate
|
||||
.Fa "const char *path" "off_t newsize"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_utime
|
||||
.Fa "const char *path" "struct utimbuf *newtimes"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_open
|
||||
.Fa "const char *path" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_read
|
||||
.Fa "const char *path" "char *buffer" "size_t bufferlen" "off_t startoffset"
|
||||
.Fa "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_write
|
||||
.Fa "const char *path" "char *buffer" "size_t bufferlen" "off_t startoffset"
|
||||
.Fa "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_fs_statfs
|
||||
.Fa "const char *path" "struct statvfs *vfsinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_flush
|
||||
.Fa "const char *path" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_fsync
|
||||
.Fa "const char *path" "int flags" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_setxattr
|
||||
.Fa "const char *path" "const char *attrname" "const char *attrvalue"
|
||||
.Fa "size_t attrsize" "int flags"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_getxattr
|
||||
.Fa "const char *path" "const char *attrname" "const char *attrvalue"
|
||||
.Fa "size_t attrvaluesize"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_listxattr
|
||||
.Fa "const char *path" "const char *attrname"
|
||||
.Fa "size_t attrvaluesize"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_removexattr
|
||||
.Fa "const char *path" "const char *attrname"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_opendir
|
||||
.Fa "const char *path" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_readdir
|
||||
.Fa "const char *path" "void *data" "fuse_fill_dir_t fillinfo"
|
||||
.Fa "off_t offset" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_releasedir
|
||||
.Fa "const char *path" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_fsyncdir
|
||||
.Fa "const char *path" "int flags" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft void *
|
||||
.Fo puffs_fuse_fs_init
|
||||
.Fa "struct fuse_conn_info *connectioninfo"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo puffs_fuse_node_destroy
|
||||
.Fa "void *connection"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_access
|
||||
.Fa "const char *path" "int accesstype"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_create
|
||||
.Fa "const char *path" "mode_t permissions" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_ftruncate
|
||||
.Fa "const char *path" "off_t offset" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_fgetattr
|
||||
.Fa "const char *path" "struct stat *attrs" "struct fuse_file_info *fileinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_lock
|
||||
.Fa "const char *path" "struct fuse_file_info *fileinfo"
|
||||
.Fa "int locktype" "struct flock *lockinfo"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_utimens
|
||||
.Fa "const char *path" "const struct timespec *newtimes"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo puffs_fuse_node_bmap
|
||||
.Fa "const char *path" "size_t mapsize" "uint64_t offset"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a reimplementation of the file system in user space subsystem.
|
||||
Operations are transported from the kernel virtual file system layer
|
||||
to the concrete implementation behind
|
||||
.Nm ,
|
||||
where they are processed and results are sent back to the kernel.
|
||||
.Pp
|
||||
It uses the framework provided by the
|
||||
.Xr puffs 3
|
||||
subsystem, and, through that, the kernel interface provided by
|
||||
.Xr puffs 4 .
|
||||
.Sh SEE ALSO
|
||||
.Xr puffs 3 ,
|
||||
.Xr puffs 4
|
||||
.Rs
|
||||
.%A Antti Kantee
|
||||
.%A Alistair Crooks
|
||||
.%D September 2007
|
||||
.%J EuroBSDCon 2007
|
||||
.%T ReFUSE: Userspace FUSE Reimplementation Using puffs
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
An unsupported experimental version of
|
||||
.Nm
|
||||
first appeared in
|
||||
.Nx 5.0 .
|
||||
.Sh AUTHORS
|
||||
.An Alistair Crooks Aq agc@NetBSD.org ,
|
||||
.An Antti Kantee Aq pooka@NetBSD.org
|
||||
.Sh BUGS
|
||||
Many, legion, but well-loved.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,368 @@
|
||||
/* $NetBSD: refuse_opt.c,v 1.14 2009/01/19 09:56:06 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* * -oblah,foo... works, but the options are not enabled.
|
||||
* * -ofoo=%s (accepts a string) or -ofoo=%u (int) is not
|
||||
* supported for now.
|
||||
* * void *data: how is it used? I think it's used to enable
|
||||
* options or pass values for the matching options.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <fuse.h>
|
||||
#include <fuse_opt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef FUSE_OPT_DEBUG
|
||||
#define DPRINTF(x) do { printf x; } while ( /* CONSTCOND */ 0)
|
||||
#else
|
||||
#define DPRINTF(x)
|
||||
#endif
|
||||
|
||||
enum {
|
||||
KEY_HELP,
|
||||
KEY_VERBOSE,
|
||||
KEY_VERSION
|
||||
};
|
||||
|
||||
struct fuse_opt_option {
|
||||
const struct fuse_opt *fop;
|
||||
char *option;
|
||||
int key;
|
||||
void *data;
|
||||
};
|
||||
|
||||
static int fuse_opt_popt(struct fuse_opt_option *, const struct fuse_opt *);
|
||||
|
||||
/*
|
||||
* Public API.
|
||||
*
|
||||
* The following functions always return 0:
|
||||
*
|
||||
* int fuse_opt_add_opt(char **, const char *);
|
||||
*
|
||||
* We implement the next ones:
|
||||
*
|
||||
* int fuse_opt_add_arg(struct fuse_args *, const char *);
|
||||
* void fuse_opt_free_args(struct fuse_args *);
|
||||
* int fuse_opt_insert_arg(struct fuse_args *, const char *);
|
||||
* int fuse_opt_match(const struct fuse_opt *, const char *);
|
||||
* int fuse_opt_parse(struct fuse_args *, void *,
|
||||
* const struct fuse_opt *, fuse_opt_proc_t);
|
||||
*
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
fuse_opt_add_arg(struct fuse_args *args, const char *arg)
|
||||
{
|
||||
struct fuse_args *ap;
|
||||
|
||||
if (args->allocated == 0) {
|
||||
ap = fuse_opt_deep_copy_args(args->argc, args->argv);
|
||||
args->argv = ap->argv;
|
||||
args->argc = ap->argc;
|
||||
args->allocated = ap->allocated;
|
||||
(void) free(ap);
|
||||
} else if (args->allocated == args->argc) {
|
||||
void *a;
|
||||
int na = args->allocated + 10;
|
||||
|
||||
if ((a = realloc(args->argv, na * sizeof(*args->argv))) == NULL)
|
||||
return -1;
|
||||
|
||||
args->argv = a;
|
||||
args->allocated = na;
|
||||
}
|
||||
DPRINTF(("%s: arguments passed: [arg:%s]\n", __func__, arg));
|
||||
if ((args->argv[args->argc++] = strdup(arg)) == NULL)
|
||||
err(1, "fuse_opt_add_arg");
|
||||
args->argv[args->argc] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct fuse_args *
|
||||
fuse_opt_deep_copy_args(int argc, char **argv)
|
||||
{
|
||||
struct fuse_args *ap;
|
||||
int i;
|
||||
|
||||
if ((ap = malloc(sizeof(*ap))) == NULL)
|
||||
err(1, "_fuse_deep_copy_args");
|
||||
/* deep copy args structure into channel args */
|
||||
ap->allocated = ((argc / 10) + 1) * 10;
|
||||
|
||||
if ((ap->argv = calloc((size_t)ap->allocated,
|
||||
sizeof(*ap->argv))) == NULL)
|
||||
err(1, "_fuse_deep_copy_args");
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if ((ap->argv[i] = strdup(argv[i])) == NULL)
|
||||
err(1, "_fuse_deep_copy_args");
|
||||
}
|
||||
ap->argv[ap->argc = i] = NULL;
|
||||
return ap;
|
||||
}
|
||||
|
||||
void
|
||||
fuse_opt_free_args(struct fuse_args *ap)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ap->argc; i++) {
|
||||
free(ap->argv[i]);
|
||||
}
|
||||
free(ap->argv);
|
||||
ap->argv = NULL;
|
||||
ap->allocated = ap->argc = 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg)
|
||||
{
|
||||
int i;
|
||||
int na;
|
||||
void *a;
|
||||
|
||||
DPRINTF(("%s: arguments passed: [pos=%d] [arg=%s]\n",
|
||||
__func__, pos, arg));
|
||||
if (args->argv == NULL) {
|
||||
na = 10;
|
||||
a = malloc(na * sizeof(*args->argv));
|
||||
} else {
|
||||
na = args->allocated + 10;
|
||||
a = realloc(args->argv, na * sizeof(*args->argv));
|
||||
}
|
||||
if (a == NULL) {
|
||||
warn("fuse_opt_insert_arg");
|
||||
return -1;
|
||||
}
|
||||
args->argv = a;
|
||||
args->allocated = na;
|
||||
|
||||
for (i = args->argc++; i > pos; --i) {
|
||||
args->argv[i] = args->argv[i - 1];
|
||||
}
|
||||
if ((args->argv[pos] = strdup(arg)) == NULL)
|
||||
err(1, "fuse_opt_insert_arg");
|
||||
args->argv[args->argc] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int fuse_opt_add_opt(char **opts, const char *opt)
|
||||
{
|
||||
DPRINTF(("%s: arguments passed: [opts=%s] [opt=%s]\n",
|
||||
__func__, *opts, opt));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 0 if opt was matched with any option from opts,
|
||||
* otherwise returns 1.
|
||||
*/
|
||||
int
|
||||
fuse_opt_match(const struct fuse_opt *opts, const char *opt)
|
||||
{
|
||||
while (opts++) {
|
||||
if (strcmp(opt, opts->templ) == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 0 if foo->option was matched with any option from opts,
|
||||
* and sets the following on match:
|
||||
*
|
||||
* * foo->key is set to the foo->fop->value if offset == -1.
|
||||
* * foo->fop points to the matched struct opts.
|
||||
*
|
||||
* otherwise returns 1.
|
||||
*/
|
||||
static int
|
||||
fuse_opt_popt(struct fuse_opt_option *foo, const struct fuse_opt *opts)
|
||||
{
|
||||
int i, found = 0;
|
||||
char *match;
|
||||
|
||||
if (!foo->option) {
|
||||
(void)fprintf(stderr, "fuse: missing argument after -o\n");
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
* iterate over argv and opts to see
|
||||
* if there's a match with any template.
|
||||
*/
|
||||
for (match = strtok(foo->option, ",");
|
||||
match; match = strtok(NULL, ",")) {
|
||||
|
||||
DPRINTF(("%s: specified option='%s'\n", __func__, match));
|
||||
found = 0;
|
||||
|
||||
for (i = 0; opts && opts->templ; opts++, i++) {
|
||||
|
||||
DPRINTF(("%s: opts->templ='%s' opts->offset=%d "
|
||||
"opts->value=%d\n", __func__, opts->templ,
|
||||
opts->offset, opts->value));
|
||||
|
||||
/* option is ok */
|
||||
if (strcmp(match, opts->templ) == 0) {
|
||||
DPRINTF(("%s: option matched='%s'\n",
|
||||
__func__, match));
|
||||
found++;
|
||||
/*
|
||||
* our fop pointer now points
|
||||
* to the matched struct opts.
|
||||
*/
|
||||
foo->fop = opts;
|
||||
/*
|
||||
* assign default key value, necessary for
|
||||
* KEY_HELP, KEY_VERSION and KEY_VERBOSE.
|
||||
*/
|
||||
if (foo->fop->offset == -1)
|
||||
foo->key = foo->fop->value;
|
||||
/* reset counter */
|
||||
opts -= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* invalid option */
|
||||
if (!found) {
|
||||
(void)fprintf(stderr, "fuse: '%s' is not a "
|
||||
"valid option\n", match);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED1 */
|
||||
int
|
||||
fuse_opt_parse(struct fuse_args *args, void *data,
|
||||
const struct fuse_opt *opts, fuse_opt_proc_t proc)
|
||||
{
|
||||
struct fuse_opt_option foo;
|
||||
char *buf;
|
||||
int i, rv = 0;
|
||||
|
||||
if (!args || !args->argv || !args->argc || !proc)
|
||||
return 0;
|
||||
|
||||
if (args->argc == 1)
|
||||
return proc(foo.data, *args->argv, FUSE_OPT_KEY_OPT, args);
|
||||
|
||||
/* the real loop to process the arguments */
|
||||
for (i = 1; i < args->argc; i++) {
|
||||
|
||||
/* assign current argv string */
|
||||
foo.option = buf = args->argv[i];
|
||||
|
||||
/* argvn != -foo... */
|
||||
if (buf[0] != '-') {
|
||||
|
||||
foo.key = FUSE_OPT_KEY_NONOPT;
|
||||
rv = proc(foo.data, foo.option, foo.key, args);
|
||||
if (rv != 0)
|
||||
break;
|
||||
|
||||
/* -o was specified... */
|
||||
} else if (buf[0] == '-' && buf[1] == 'o') {
|
||||
|
||||
/* -oblah,foo... */
|
||||
if (buf[2]) {
|
||||
/* skip -o */
|
||||
foo.option = args->argv[i] + 2;
|
||||
/* -o blah,foo... */
|
||||
} else {
|
||||
/*
|
||||
* skip current argv and pass to the
|
||||
* next one to parse the options.
|
||||
*/
|
||||
++i;
|
||||
foo.option = args->argv[i];
|
||||
}
|
||||
|
||||
rv = fuse_opt_popt(&foo, opts);
|
||||
if (rv != 0)
|
||||
break;
|
||||
|
||||
/* help/version/verbose argument */
|
||||
} else if (buf[0] == '-' && buf[1] != 'o') {
|
||||
/*
|
||||
* check if the argument matches
|
||||
* with any template in opts.
|
||||
*/
|
||||
rv = fuse_opt_popt(&foo, opts);
|
||||
if (rv != 0) {
|
||||
break;
|
||||
} else {
|
||||
DPRINTF(("%s: foo.fop->templ='%s' "
|
||||
"foo.fop->offset: %d "
|
||||
"foo.fop->value: %d\n",
|
||||
__func__, foo.fop->templ,
|
||||
foo.fop->offset, foo.fop->value));
|
||||
|
||||
/* argument needs to be discarded */
|
||||
if (foo.key == FUSE_OPT_KEY_DISCARD) {
|
||||
rv = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* process help/version argument */
|
||||
if (foo.key != KEY_VERBOSE &&
|
||||
foo.key != FUSE_OPT_KEY_KEEP) {
|
||||
rv = proc(foo.data, foo.option,
|
||||
foo.key, args);
|
||||
break;
|
||||
} else {
|
||||
/* process verbose argument */
|
||||
rv = proc(foo.data, foo.option,
|
||||
foo.key, args);
|
||||
if (rv != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* unknown option, how could that happen? */
|
||||
} else {
|
||||
DPRINTF(("%s: unknown option\n", __func__));
|
||||
rv = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# $NetBSD: shlib_version,v 1.3 2010/05/21 10:53:41 pooka Exp $
|
||||
#
|
||||
major=2
|
||||
minor=0
|
||||
Reference in New Issue
Block a user