OpenBSD manual page server

Manual Page Search Parameters

FB_SETUP(9) Kernel Developer's Manual FB_SETUP(9)

fb_setup, fb_queue, fb_deletekernel messaging mechanism for file system in userland (FUSE)

#include <sys/fusebuf.h>

struct fusebuf *
fb_setup(size_t size, ino_t inode, int type, struct proc *p);

int
fb_queue(dev_t dev, struct fusebuf *fbuf);

void
fb_delete(struct fusebuf *fbuf);

#define FUSEBUFMAXSIZE	(4096*1024)
#define	FUSEBUFSIZE	(sizeof(struct fusebuf))

struct fb_hdr {
	SIMPLEQ_ENTRY(fusebuf)	fh_next;
	size_t			fh_len;
	int			fh_err;
	int			fh_type;
	ino_t			fh_ino;
	uint64_t		fh_uuid;
};

struct fb_io {
	uint64_t	fi_fd;
	ino_t		fi_ino;
	off_t		fi_off;
	size_t		fi_len;
	mode_t		fi_mode;
	uint32_t	fi_flags;
};

struct fusebuf {
	struct fb_hdr	fb_hdr;
	union {
		struct statvfs	FD_stat;
		struct stat	FD_attr;
		struct fb_io	FD_io;

	} FD;
	uint8_t	*fb_dat;
};

#define fb_next		fb_hdr.fh_next
#define fb_len		fb_hdr.fh_len
#define fb_err		fb_hdr.fh_err
#define fb_type		fb_hdr.fh_type
#define fb_ino		fb_hdr.fh_ino
#define fb_uuid		fb_hdr.fh_uuid

#define fb_stat		FD.FD_stat
#define fb_attr		FD.FD_attr
#define fb_io_fd	FD.FD_io.fi_fd
#define fb_io_ino	FD.FD_io.fi_ino
#define fb_io_off	FD.FD_io.fi_off
#define fb_io_len	FD.FD_io.fi_len
#define fb_io_mode	FD.FD_io.fi_mode
#define fb_io_flags	FD.FD_io.fi_flags

These functions provide a way to manage the kernel messaging mechanism for fuse(4) file systems. It is based on mbuf(9).

Each FUSE operation fits in a fusebuf except for read, write, and readdirs, which are split into several fusebufs with a changing value in fb_io_off for each. The size of a fusebuf is FUSEBUFSIZE.

A fusebuf structure is defined as an fb_hdr followed by a structure containing a union and a buffer F_Dat. The header contains the following elements:

fh_next
A SIMPLEQ_ENTRY(3) needed to store the different fusebufs stored with ().
fh_len
Indicates the amount of data in F_dat.
fh_resid
Used for partial fuse(4) reads. If the read does not fill the fusebuf, the number of bytes of F_dat written in this field are stored.
fh_err
Indicates the errno(2) failure of a fusebuf.
fh_type
Indicates the type of fusebuf transaction (see below).
fh_ino
Indicates the inode on which the fuse(4) operation is done.
fh_uuid
UUID to track the answer. This number is generated with arc4random(9).

The fh_type variable can take the following values:

The fusebuf is a lookup operation.
The fusebuf is a gettattr operation.
The fusebuf is a setattr operation.
The fusebuf is a readlink operation.
The fusebuf is a symlink operation.
The fusebuf is a mknod operation.
The fusebuf is a mkdir operation.
The fusebuf is an unlink operation.
The fusebuf is an rmdir operation.
The fusebuf is a rename operation.
The fusebuf is a link operation.
The fusebuf is an open operation.
The fusebuf is a read operation.
The fusebuf is a write operation.
The fusebuf is a statfs operation.
The fusebuf is a file close operation.
The fusebuf is a file sync operation.
The fusebuf is a flush operation.
The fusebuf initializes the FUSE connection.
The fusebuf is an opendir operation.
The fusebuf is a readdir operation.
The fusebuf is a close dir operation.
The fusebuf is a dir sync operation.
The fusebuf is an access operation.
The fusebuf closes the FUSE connection.

All the data needed by the FUSE clients is contained in the F_dat structure. This structure contains a union FD of frequently used type and a buffer F_databuf to send data to libfuse. The union contains the following elements:

FD_stat
A struct statvfs(3) filled in by the FUSE client statfs for the FUSE VFS statfs code.
FD_attr
Used by the getattr and setattr calls.
FD_io
Contains all fields commonly used by FUSE client callbacks to provide information to FUSE vnops. It is used by access, readdir, release, releasedir, read, write, mkdir, and setattr.

Setattr uses a struct fb_io and a struct stat. Settattr uses FD_stat and encapsulates a struct fb_io in F_databuf with fbtod.

Fusebufs can be deleted with the () helper.

errno(2), fuse_main(3), queue(3), statvfs(3), fuse(4), arc4random(9), mbuf(9)

The fb_setup API first appeared in OpenBSD 5.4.

November 30, 2017 OpenBSD-7.6