FUSE_NEW(3)

NAME
fuse_new - FUSE implementation routine to intialise the FUSE connection

SYNOPSIS
#include <fuse.h>
struct fuse *
fuse_new(struct fuse_chan *fc, struct fuse_args *args, const struct fuse_operations *ops, unused size_t size, void *userdata);

DESCRIPTION
Initialises the FUSE library on the channel returned by fuse_mount(3).

FUSE operations work in the same way as their UNIX file system counterparts. A major exception is that these routines return a negated errno value (-errno) on failure.

All operations are optional but a functional file system will want to implement at least statfs, readdir, open, read and getattr. FUSE will return ENOSYS if any operation other than flush, fsync or fsyncdir is not implemented.

The first parameter to each of these operations (except for init and terminate) is a NULL terminated string representing the full path to the file or directory, relative to the root of this file system, that is being operated on.

    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 *);
    };

The order of calls is:

    init
    ...
    opendir
    readdir
    releasedir
    open
    read
    write
    ...
    flush
    release
    ...
    destroy

access
    Not implemented. OpenBSD always behaves as if the default_permissions mount option was specified. See fuse_mount(3).

chmod
    Called when file access permissions are changed.

chown
    Called when either the file owner or group is changed.

create
    Not implemented on OpenBSD. File systems must implement mknod instead. In the reference implementation this is an atomic operation that both creates and opens the file. There is no equivalent in the OpenBSD VFS.

flush
    Called when the file is closed by the close(2) system call. This is the only way for a file system to return an error on close.

fsync
    Optional function that implements fsync(2) and fdatasync(2). The datasync parameter specifies whether the operation is as a result of a call to fdatasync(2) and is currently always 0 (false). ffi.fh_id will contain the file handle returned by the file system when the file was opened.

fsyncdir
    Not implemented.

getattr
    Corresponds to the stat(2) system call. Flags and extended attributes are ignored. This operation is mandatory.

getxattr
    Not implemented.

getdir
    Deprecated. File system should implement readdir instead.

mknod
    Called on open(2) and mknod(2) to create regular files, pipes and device special files.

open
    Called on open(2). Due to the difference between FUSE and the OpenBSD VFS, open will only be called once for each file for every different combination of flags provided to open(2). The O_CREAT and O_TRUNC flags are never passed from the kernel to open, the mknod and truncate operations are invoked before open instead.

opendir
    Called when a directory is opened for reading.

release
    Called when there are no more references to the file.

releasedir
    Called when there are no more references to the directory.

setattr
    Equivalent to chown(2) and chmod(2) system calls. Setting file flags is not supported.

setxattr
    Not implemented.

Options supported by args are:

debug, -d
    Print debug information to stdout.

gid=%u
    The GID that will be reported as the group for all files by getattr.

hard_remove
    Immediately delete a file even if it's currently open by a process. Otherwise FUSE will temporarily rename the file and only delete it when it is no longer referenced. This is to avoid the file system having to deal with this situation. This is always set on OpenBSD.

readdir_ino
    Similar to use_ino but the file system's inode number is only reported for readdir. This is always set on OpenBSD because it's required by getcwd(3).

uid=%u
    The UID that will be reported as the owner for all files by getattr.

umask=%o
    The file mode mask applied to the permission for all files by getattr.

use_ino
    By default, FUSE will return an internal inode number for getattr and readdir and this will be different every time the file system is mounted. If this is set the file system's own inode number will be reported instead. Useful only for file system that have inode numbers.

SEE ALSO
fuse_get_context(3), fuse_main(3), fuse_mount(3)

STANDARDS
The fuse_new() function conforms to FUSE 2.6.

HISTORY
The fuse_new() function first appeared in OpenBSD 5.4.

AUTHORS
Sylvestre Gallon <ccna.syl@gmail.com> Helg Bredow <helg@openbsd.org>