FB_SETUP(9)
β¨ FB_SETUP(9) β¨
okay bestie, this one is straight out of the Kernel Developer's Manual, and it's giving kernel-messaging-for-FUSE realness π«Ά no cap.
π NAME π
fb_setup, fb_queue, fb_delete β kernel messaging mechanism for file system in userland (FUSE)
πΈ SYNOPSIS πΈ
#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
π DESCRIPTION π
These functions are the whole vibe for managing the kernel messaging mechanism for fuse(4) file systems. It is based on mbuf(9) β yes ma'am, classic behavior π
Every single FUSE operation fits inside one fusebuf, except for read, write, and readdirs β those get split into several fusebufs, with a changing value in fb_io_off for each one. The size of a fusebuf is FUSEBUFSIZE. Periodt β¨
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β aSIMPLEQ_ENTRY(3)needed to store the different fusebufs stored withfb_queue().fh_lenβ indicates the amount of data inF_dat.fh_residβ used for partialfuse(4)reads. If the read does not fill the fusebuf, the number of bytes ofF_datwritten are stored in this field.fh_errβ indicates theerrno(2)failure of a fusebuf.fh_typeβ indicates the type of fusebuf transaction (see below).fh_inoβ indicates the inode on which thefuse(4)operation is done.fh_uuidβ UUID to track the answer. This number is generated witharc4random(9).
The fh_type variable can take the following values:
FBT_LOOKUPβ the fusebuf is a lookup operation.FBT_GETATTRβ the fusebuf is a gettattr operation.FBT_SETATTRβ the fusebuf is a setattr operation.FBT_READLINKβ the fusebuf is a readlink operation.FBT_SYMLINKβ the fusebuf is a symlink operation.FBT_MKNODβ the fusebuf is a mknod operation.FBT_MKDIRβ the fusebuf is a mkdir operation.FBT_UNLINKβ the fusebuf is an unlink operation.FBT_RMDIRβ the fusebuf is an rmdir operation.FBT_RENAMEβ the fusebuf is a rename operation.FBT_LINKβ the fusebuf is a link operation.FBT_OPENβ the fusebuf is an open operation.FBT_READβ the fusebuf is a read operation.FBT_WRITEβ the fusebuf is a write operation.FBT_STATFSβ the fusebuf is a statfs operation.FBT_RELEASEβ the fusebuf is a file close operation.FBT_FSYNCβ the fusebuf is a file sync operation.FBT_FLUSHβ the fusebuf is a flush operation.FBT_INITβ the fusebuf initializes the FUSE connection.FBT_OPENDIRβ the fusebuf is an opendir operation.FBT_READDIRβ the fusebuf is a readdir operation.FBT_RELEASEDIRβ the fusebuf is a close dir operation.FBT_FSYNCDIRβ the fusebuf is a dir sync operation.FBT_ACCESSβ the fusebuf is an access operation.FBT_DESTROYβ 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β astruct statvfs(3)filled in by the FUSE client statfs for the FUSE VFS statfs code.FD_attrβ used by thegetattrandsetattrcalls.FD_ioβ contains all fields commonly used by FUSE client callbacks to provide information to FUSE vnops. It is used byaccess,readdir,release,releasedir,read,write,mkdir, andsetattr.
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 fb_delete() helper. slay π«Ά
π SEE ALSO π
errno(2), fuse_main(3), queue(3), statvfs(3), fuse(4), arc4random(9), mbuf(9)
π¦ HISTORY π¦
The fb_setup API first appeared in OpenBSD 5.4. iconic behavior honestly π₯
mwah π this page's footer energy is Debian, dated November 30, 2017 β FB_SETUP(9) out π
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms