1. 程式人生 > >FUSE協議解析

FUSE協議解析

由於以前有專案是用到FUSE,將S3等物件儲存對映為檔案儲存的,但我不是負責那一塊,所以一直只是知道FUSE是個什麼東西,而沒有用過。剛好趁著沒工作的這段時間,學習Golang,順便把FUSE也瞭解下,實現了一個簡易版的libfuse: https://github.com/mingforpc/fuse-go和一個可以將HDFS Mount到本地資料夾的程式: https://github.com/mingforpc/hadoop-fs

由於剛學並整理,如有遺漏或者錯誤!請拼命指出,謝謝!

什麼是FUSE

FUSE的全稱是Filesystem in Userspace,即使用者空間檔案系統,是系統核心提供的一個功能,使得可以在使用者態下實現一個自定義的檔案系統。比如CEPH和GlusterFS等都有使用到FUSE。

libfuse則是提供給使用者態下的開發包。

FUSE是怎麼互動的

FUSE是通過讀寫/dev/fuse讓使用者態的檔案系統程序和核心通訊的。

大概流程

程式需要先開啟/dev/fuse,然後通過mount()/dev/fuse的fd,程序的使用者id和組id傳入,進行檔案系統的掛載。

PS: libfuse通過自己寫的fusermount程式(編譯安裝libfuse後會在/bin/下),可以讓我們實現的檔案系統程式在非root許可權下掛載,這部分我還不是很瞭解,我自己實現的go版libfuse也只是依賴於這個fusermount。

FUSE的指令號、對應的函式、請求格式與響應

程式從/dev/fuse中讀取請求,不需要擔心像TCP有半包粘包等問題,一次讀取一條請求。buffer不夠大,會報異常。

請求和響應,都是以二進位制位元組表示的,下文中的結構體只是為了方便看。

請求頭

每個命令的前 40 bytes為請求頭,轉為Golang的結構體如下:

// Each query starts with a FuseInHeader
type FuseInHeader struct {
	Len     uint32
	Opcode  uint32
	Unique  uint64
	Nodeid  uint64
	Uid     uint32
	Gid     uint32
	Pid     uint32
	Padding uint32
}
  • Len: 是整個請求的位元組數長度,包括請求頭後的具體內容
  • Opcode: 請求的型別
  • Unique: 該請求唯一標識,響應中要對應著該Unique
  • Nodeid: 該請求針對的檔案nodeid,目標檔案或者資料夾的nodeid
  • Uid: 對該檔案/資料夾操作的程序的使用者ID
  • Gid: 對該檔案/資料夾操作的程序的使用者組ID
  • Pid: 對該檔案/資料夾操作的程序的程序ID

響應頭

程式寫入/dev/fuse的每個響應的前 16 bytes為響應頭,轉為Golang的結構體如下:

type FuseOutHeader struct {
	Len    uint32
	Error  int32
	Unique uint64
}
  • Len: 是整個響應的位元組數長度,包括響應頭後的具體內容
  • Error: 一個負數的錯誤碼,成功返回0,其他對應著系統(error.h)的錯誤程式碼,但是為負數,每個操作的錯誤返回可以檢視linux man中相應的函式
  • Unique: 對應者請求的唯一標識

請求型別和具體結構

數字對應著請求中的Opcode

FUSE_LOOKUP = 1

lookup()函式,Look up a directory entry by name and get its attributes.

如解析所說,獲取代請求頭Nodeid資料夾下該名字的檔案的屬性,包含著 inode id等。

請求頭後的實體
type FuseLookupIn struct {
	Name string // 字串結尾的`\0`會計算到長度中,解析時需注意
}
  • Name: 檔名
響應頭的實體
type FuseEntryOut struct {
	NodeId         uint64 /* Inode ID */
	Generation     uint64 /* Inode generation: nodeid:gen must be unique for the fs's lifetime */
	EntryValid     uint64 /* Cache timeout for the name */
	AttrValid      uint64 /* Cache timeout for the attributes */
	EntryValidNsec uint32
	AttrValidNsec  uint32

	Attr FuseAttr
}

type FuseAttr struct {
	Ino       uint64
	Size      uint64
	Blocks    uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Nlink     uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	Blksize   uint32
	Padding   uint32
}
  • NodeId: 檔案的Inode ID
  • Generation: 同一個檔案, nodeid和gen的組合,必須在整個檔案系統的生命週期中唯一
  • EntryValid: 對於檔案的Name的快取時間,單位是秒
  • EntryValidNsec: 同上,但是該屬性表示毫秒部分
  • AttrValid: 對於檔案的屬性的快取時間,單位是秒
  • AttrValidNsec: 同上,但是該屬性表示毫秒部分
  • Attr: 該檔案的屬性,可以對應屬性的意義可以參考檔案屬性stat
FUSE_FORGET = 2

forget()函式,Forget about an inode

不需要返回任何響應的操作。

請求頭後的實體
// forget (should not send any reply)
type FuseForgetIn struct {
	Nlookup uint64
}
FUSE_GETATTR = 3

getattr()函式,Get file attributes.

請求頭後的實體
type FuseGetattrIn struct {
	GetattrFlags uint32
	Dummy        uint32
	Fh           uint64
}
響應頭的實體
type FuseAttrOut struct {
	AttrValid     uint64 /* Cache timeout for the attributes */
	AttrValidNsec uint32
	Dummp         uint32

	Attr FuseAttr
}

type FuseAttr struct {
	Ino       uint64
	Size      uint64
	Blocks    uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Nlink     uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	Blksize   uint32
	Padding   uint32
}
  • AttrValid: 屬性的有效時間,單位秒
  • AttrValidNsec: 同上,但是該屬性表示毫秒部分
  • Attr: 該檔案的屬性,可以對應屬性的意義可以參考檔案屬性stat
FUSE_SETATTR = 4

setattr()函式,Set file attributes

請求頭後的實體
type FuseSetattrIn struct {
	Valid     uint32
	Padding   uint32
	Fh        uint64
	Size      uint64
	LockOwner uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Unused4   uint32
	Uid       uint32
	Gid       uint32
	Unused5   uint32
}
  • Valid: 用來標識需要給檔案設定哪些屬性的:
    • FUSE_SET_ATTR_MODE = (1 << 0)
    • FUSE_SET_ATTR_UID = (1 << 1)
    • FUSE_SET_ATTR_GID = (1 << 2)
    • FUSE_SET_ATTR_SIZE = (1 << 3)
    • FUSE_SET_ATTR_ATIME = (1 << 4)
    • FUSE_SET_ATTR_MTIME = (1 << 5)
    • FUSE_SET_ATTR_ATIME_NOW = (1 << 7)
    • FUSE_SET_ATTR_MTIME_NOW = (1 << 8)
    • FUSE_SET_ATTR_CTIME = (1 << 10)
  • Size: 檔案的大小
  • Atime 和 AtimeNsec: 檔案的 access time
  • Mtime 和 MtimeNsec: 檔案的 modification time
  • Ctime 和 CtimeNsec: 檔案的 status time
  • Mode: 檔案的模式(檔案型別和許可權)
  • Uid: 檔案所屬的使用者
  • Gid: 檔案所屬的使用者組
響應頭的實體
type FuseAttrOut struct {
	AttrValid     uint64 /* Cache timeout for the attributes */
	AttrValidNsec uint32
	Dummp         uint32

	Attr FuseAttr
}

type FuseAttr struct {
	Ino       uint64
	Size      uint64
	Blocks    uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Nlink     uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	Blksize   uint32
	Padding   uint32
}
FUSE_READLINK = 5

readlink()函式,Read symbolic link

請求頭後的實體

FUSE_READLINK 請求頭後沒有實體。

響應頭的實體
type FuseReadlinkOut struct {
	Path string
}
FUSE_SYMLINK = 6

symlink()函式,Create a symbolic link

請求頭後的實體
type FuseSymlinkIn struct {
	Name string

	LinkName string
}

Name 和 LinkName 之間會以 '\0'分隔。

  • Name: 軟連線檔案的檔名
  • LinkName: 軟連線所連線的檔名
響應頭的實體
type FuseEntryOut struct {
	NodeId         uint64 /* Inode ID */
	Generation     uint64 /* Inode generation: nodeid:gen must be unique for the fs's lifetime */
	EntryValid     uint64 /* Cache timeout for the name */
	AttrValid      uint64 /* Cache timeout for the attributes */
	EntryValidNsec uint32
	AttrValidNsec  uint32

	Attr FuseAttr
}

type FuseAttr struct {
	Ino       uint64
	Size      uint64
	Blocks    uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Nlink     uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	Blksize   uint32
	Padding   uint32
}

屬性見lookup中的。

FUSE_MKNOD = 8

mknod()函式,Create file node

請求頭後的實體
type FuseMknodIn struct {
	Mode    uint32
	Rdev    uint32
	Umask   uint32
	Padding uint32

	Name string
}
響應頭的實體
type FuseEntryOut struct {
	NodeId         uint64 /* Inode ID */
	Generation     uint64 /* Inode generation: nodeid:gen must be unique for the fs's lifetime */
	EntryValid     uint64 /* Cache timeout for the name */
	AttrValid      uint64 /* Cache timeout for the attributes */
	EntryValidNsec uint32
	AttrValidNsec  uint32

	Attr FuseAttr
}

type FuseAttr struct {
	Ino       uint64
	Size      uint64
	Blocks    uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Nlink     uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	Blksize   uint32
	Padding   uint32
}

屬性見lookup中的。

FUSE_MKDIR = 9

mkdir()函式,Create a directory

請求頭後的實體
type FuseMkdirIn struct {
	Mode  uint32
	Umask uint32

	Name string
}
  • Mode: 目錄的模式(包含檔案型別和許可權)
  • Name: 要建立的目錄的名稱
響應頭的實體
type FuseEntryOut struct {
	NodeId         uint64 /* Inode ID */
	Generation     uint64 /* Inode generation: nodeid:gen must be unique for the fs's lifetime */
	EntryValid     uint64 /* Cache timeout for the name */
	AttrValid      uint64 /* Cache timeout for the attributes */
	EntryValidNsec uint32
	AttrValidNsec  uint32

	Attr FuseAttr
}

type FuseAttr struct {
	Ino       uint64
	Size      uint64
	Blocks    uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Nlink     uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	Blksize   uint32
	Padding   uint32
}

屬性見lookup中的。

FUSE_UNLINK = 10

unlink()函式, Remove a directory

請求頭後的實體
type FuseUnlinkIn struct {
	Name string
}
  • Name: 要刪除的目錄名字
響應頭的實體

無需響應實體,只需返回響應頭

FUSE_RMDIR = 11

rmdir()函式,Remove a directory

請求頭後的實體

參考unlink()

響應頭的實體

參考unlink()

FUSE_RENAME = 12

rename()函式,Rename a file

請求頭後的實體
type FuseRenameIn struct {
	NewDir uint64

	OldName string

	NewName string
}
  • NewDir: 新目錄的 inode id(舊目錄的inode id在請求頭中)
  • OldName: 舊檔名
  • NewName: 新檔名
響應頭的實體

無需響應實體,只需返回響應頭

FUSE_LINK = 13

link()函式, Create a hard link

請求頭後的實體
type FuseLinkIn struct {
	OldNodeid uint64
	NewName string
}
響應頭的實體
type FuseReadlinkOut struct {
	Path string
}
FUSE_OPEN = 14

open()函式,Open a file

請求頭後的實體
type FuseOpenIn struct {
	Flags  uint32
	Unused uint32
}
響應頭的實體
type FuseOpenOut struct {
	Fh        uint64
	OpenFlags uint32
	Padding   uint32
}
FUSE_READ = 15

read()函式,Read data

請求頭後的實體
type FuseReadIn struct {
	Fh        uint64
	Offset    uint64
	Size      uint32
	ReadFlags uint32
	LockOwner uint64
	Flags     uint32
	Padding   uint32
}
  • Offset: 讀取開始位置,相對於檔案開頭的偏移量
  • Size: 核心快取區的大小(讀取的資料大小不能超過這個限制)
響應頭的實體
type FuseReadOut struct {
	Content []byte
}

在響應頭後緊跟著讀取的二進位制資料

FUSE_WRITE = 16

write()函式,Write data

請求頭後的實體
type FuseWriteIn struct {
	Fh         uint64
	Offset     uint64
	Size       uint32
	WriteFlags uint32
	LockOwner  uint64
	Flags      uint32
	Padding    uint32

	Buf []byte
}
  • Offset: 開始寫入資料位置的偏移量
  • Size: 寫入資料的位元組數
  • Buf: 寫入的資料
響應頭的實體
type FuseWriteOut struct {
	Size    uint32
	Padding uint32
}
  • Size: 成功寫入資料的位元組數
FUSE_STATFS = 17

statfs()函式,Get file system statistics

請求頭後的實體

statfs只有請求頭

響應頭的實體
type FuseStatfs struct {
	Blocks  uint64
	Bfree   uint64
	Bavail  uint64
	Files   uint64
	Ffree   uint64
	Bsize   uint32
	NameLen uint32
	Frsize  uint32
	Padding uint32
	Spare   [6]uint32
}
FUSE_RELEASE = 18

release()函式,Release an open file

請求頭後的實體
type FuseReleaseIn struct {
	Fh           uint64
	Flags        uint32
	ReleaseFlags uint32
	LockOwner    uint64
}
響應頭的實體

release只需響應頭返回成功與否

FUSE_FSYNC = 20

fsync()函式,Synchronize file contents

請求頭後的實體
type FuseFsyncIn struct {
	Fh         uint64
	FsyncFlags uint32
	Padding    uint32
}
響應頭的實體

fsync只需響應頭返回成功與否

FUSE_SETXATTR = 21

setxattr()函式,Set an extended attribute

請求頭後的實體
type FuseSetxattrIn struct {
	Size  uint32
	Flags uint32

	Name  string
	Value string
}
  • Size: 是Value的位元組數
  • Name: 檔案擴充套件屬性的屬性名
  • Value: 檔案擴充套件屬性的值
響應頭的實體

setxattr只需響應頭返回成功與否

FUSE_GETXATTR = 22

getxattr()函式,Get an extended attribute

請求頭後的實體
type FuseGetxattrIn struct {
	Size    uint32
	Padding uint32

	Name string
}
  • Size: Name的長度
  • Name: 要獲取的檔案擴充套件屬性的名字
響應頭的實體
type FuseGetxattrOut struct {
	Size    uint32
	Padding uint32

	Value string
}
  • Size: 表示返回的Value大小
  • Value: 檔案擴充套件屬性Name對應的值
FUSE_LISTXATTR = 23

listxattr()函式, List extended attribute names

請求頭後的實體
type FuseListxattrIn struct {
	Size    uint32
	Padding uint32
}
  • Size: 表示核心接收的快取大小
響應頭的實體
type FuseListxattrOut struct {
	Size    uint32
	Padding uint32

	Value string
}
  • Size: 表示返回的Value大小
  • Value: 包含檔案額外屬性名的字串,格式類似"user.name\0system.name"

FuseListxattrIn中的Size為0, 不需要往FuseListxattrOut寫入Value。

特殊

  • 當Value為空時,響應實體為FuseListxattrOut
  • 當Value有值時,響應實體不需要FuseListxattrOut,而是在響應頭FuseOutHeader後緊跟著Value的值
FUSE_REMOVEXATTR = 24

removexattr()函式,Remove an extended attribute

請求頭後的實體
type FuseRemovexattrIn struct {
	Name string
}
  • Name: 要刪除的檔案額外屬性名
響應頭的實體

removexattr只需響應頭返回成功與否

FUSE_FLUSH = 25

flush()函式,Flush method

請求頭後的實體
type FuseFlushIn struct {
	Fh        uint64
	Unused    uint32
	Padding   uint32
	LockOwner uint64
}
響應頭的實體

flush只需響應頭返回成功與否

FUSE_INIT = 26

init()函式, Initialize filesystem

Fuse檔案系統的初始化函式,當Mount以後,從/dev/fuse讀到的第一個請求就是init,只有初始化後,才會接收到其他請求。

請求頭後的實體
type FuseInitIn struct {
	Major        uint32
	Minor        uint32
	MaxReadahead uint32
	Flags        uint32
}
  • Major: Fuse的主版本號
  • Minor: Fuse的副版本號
  • Flags: 核心Fuse能提供的功能
    • FUSE_ASYNC_READ = (1 << 0)
    • FUSE_POSIX_LOCKS = (1 << 1)
    • FUSE_FILE_OPS = (1 << 2)
    • FUSE_ATOMIC_O_TRUNC = (1 << 3)
    • FUSE_EXPORT_SUPPORT = (1 << 4)
    • FUSE_BIG_WRITES = (1 << 5)
    • FUSE_DONT_MASK = (1 << 6)
    • FUSE_SPLICE_WRITE = (1 << 7)
    • FUSE_SPLICE_MOVE = (1 << 8)
    • FUSE_SPLICE_READ = (1 << 9)
    • FUSE_FLOCK_LOCKS = (1 << 10)
    • FUSE_HAS_IOCTL_DIR = (1 << 11)
    • FUSE_AUTO_INVAL_DATA = (1 << 12)
    • FUSE_DO_READDIRPLUS = (1 << 13)
    • FUSE_READDIRPLUS_AUTO = (1 << 14)
    • FUSE_ASYNC_DIO = (1 << 15)
    • FUSE_WRITEBACK_CACHE = (1 << 16)
    • FUSE_NO_OPEN_SUPPORT = (1 << 17)
    • FUSE_PARALLEL_DIROPS = (1 << 18)
    • FUSE_HANDLE_KILLPRIV = (1 << 19)
    • FUSE_POSIX_ACL = (1 << 20)
響應頭的實體
type FuseInitOut struct {
	Major               uint32
	Minor               uint32
	MaxReadahead        uint32
	Flags               uint32
	MaxBackground       uint16
	CongestionThreshold uint16
	MaxWrite            uint32
	TimeGran            uint32
	Unused              [9]uint32
}
  • Major: 主版本號
  • Minor: 副版本號
  • Flags: 程式希望Fuse提供的功能
FUSE_OPENDIR = 27

opendir()函式,Open a directory

請求頭後的實體
type FuseOpenIn struct {
	Flags  uint32
	Unused uint32
}
響應頭的實體
type FuseOpenOut struct {
	Fh        uint64
	OpenFlags uint32
	Padding   uint32
}
FUSE_READDIR = 28

readdir()函式,Read directory

請求頭後的實體
type FuseReadIn struct {
	Fh        uint64
	Offset    uint64
	Size      uint32
	ReadFlags uint32
	LockOwner uint64
	Flags     uint32
	Padding   uint32
}
  • Offset: 開始的偏移量
  • Size: 核心所能接收的位元組數大小
響應頭的實體
type FuseReadOut struct {
	Content []byte
}

type FuseDirent struct {
	Ino     uint64
	Off     uint64
	NameLen uint32
	DirType uint32
	Name    string
}

讀取目錄比較特殊,讀取目錄是返回有目錄中哪些檔案的,FuseReadOut中是多個FuseDirent的二進位制格式。

並且FuseReadOut的大小不能超過,FuseReadIn中Size的大小。

同時,每個FuseDirent的二進位制位元組數,必須要湊齊為8的倍數,比如某個FuseDirent的位元組數是30,必須在其後加上"\0\0"以湊齊32。

FUSE_RELEASEDIR = 29

releasedir()函式,Release an open directory

請求頭後的實體
type FuseReleaseIn struct {
	Fh           uint64
	Flags        uint32
	ReleaseFlags uint32
	LockOwner    uint64
}
響應頭的實體

releasedir只需響應頭返回成功與否

FUSE_FSYNCDIR = 30

fsyncdir()函式,Synchronize directory contents

請求頭後的實體
type FuseFsyncIn struct {
	Fh         uint64
	FsyncFlags uint32
	Padding    uint32
}
響應頭的實體

fsyncdir只需響應頭返回成功與否

FUSE_GETLK = 31

getlk()函式,Test for a POSIX file lock

請求頭後的實體
type FuseLkIn struct {
	Fh      uint64
	Owner   uint64
	Lk      FuseFileLock
	LkFlags uint32
	Padding uint32
}

type FuseFileLock struct {
	Start uint64
	End   uint64
	Type  uint32
	Pid   uint32 /* tgid */
}
響應頭的實體
type FuseFileLock struct {
	Start uint64
	End   uint64
	Type  uint32
	Pid   uint32 /* tgid */
}
FUSE_SETLK = 32

setlk()函式,Acquire, modify or release a POSIX file lock

請求頭後的實體
type FuseLkIn struct {
	Fh      uint64
	Owner   uint64
	Lk      FuseFileLock
	LkFlags uint32
	Padding uint32
}

type FuseFileLock struct {
	Start uint64
	End   uint64
	Type  uint32
	Pid   uint32 /* tgid */
}
響應頭的實體
type FuseFileLock struct {
	Start uint64
	End   uint64
	Type  uint32
	Pid   uint32 /* tgid */
}
FUSE_SETLKW = 33

setlk()相同

FUSE_ACCESS = 34

access()函式,Check file access permissions

請求頭後的實體
type FuseAccessIn struct {
	Mask    uint32
	Padding uint32
}
響應頭的實體

access只需響應頭返回成功與否

FUSE_CREATE = 35

create()函式,Create and open a file

請求頭後的實體
type FuseCreateIn struct {
	Flags   uint32
	Mode    uint32
	Umask   uint32
	Padding uint32

	Name string
}
  • Mode: 檔案型別以及許可權模式
  • Name: 檔名
響應頭的實體
type FuseCreateOut struct {
	Entry FuseEntryOut
	Open  FuseOpenOut
}

type FuseEntryOut struct {
	NodeId         uint64 /* Inode ID */
	Generation     uint64 /* Inode generation: nodeid:gen must be unique for the fs's lifetime */
	EntryValid     uint64 /* Cache timeout for the name */
	AttrValid      uint64 /* Cache timeout for the attributes */
	EntryValidNsec uint32
	AttrValidNsec  uint32

	Attr FuseAttr
}

type FuseAttr struct {
	Ino       uint64
	Size      uint64
	Blocks    uint64
	Atime     uint64
	Mtime     uint64
	Ctime     uint64
	AtimeNsec uint32
	MtimeNsec uint32
	CtimeNsec uint32
	Mode      uint32
	Nlink     uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	Blksize   uint32
	Padding   uint32
}

type FuseOpenOut struct {
	Fh        uint64
	OpenFlags uint32
	Padding   uint32
}

create的響應實體FuseCreateOut需要有FuseEntryOutFuseOpenOut的結構

FUSE_INTERRUPT = 36

程式中斷接收到的請求

請求頭後的實體
struct FuseInterruptIn {
	uint64_t	unique;
};
FUSE_BMAP = 37

bmap()函式,Map block index within file to block index within device

請求頭後的實體
type FuseBmapIn struct {
	Block     uint64
	BlockSize uint32
	Padding   uint32
}
響應頭的實體
type FuseBmapOut struct {
	Block uint64
}
FUSE_DESTROY = 38

destory()函式,Clean up filesystem.

沒有請求實體,不需要返回響應。

FUSE_IOCTL = 39

ioctl()函式

請求頭後的實體
type FuseIoctlIn struct {
	Fh      uint64
	Flags   uint32
	Cmd     uint32
	Arg     uint64
	InSize  uint32
	OutSize uint32

	InBuf []byte
}
響應頭的實體
type FuseIoctlOut struct {
	Result  int32
	Flags   uint32
	InIovs  uint32
	OutIovs uint32
}
FUSE_POLL = 40

poll()函式,Poll for IO readiness

請求頭後的實體
type FusePollIn struct {
	Fh     uint64
	Kh     uint64
	Flags  uint32
	Events uint32
}
響應頭的實體
type FusePollOut struct {
	Revents uint32
	Padding uint32
}
FUSE_BATCH_FORGET = 42

forget_multi()函式,Forget about multiple inodes

不需要響應

請求頭後的實體
type FuseBatchForgetIn struct {
	Count uint32
	Dummy uint32

	NodeList []FuseForgetOne
}

type FuseForgetOne struct {
	Nodeid  uint64
	Nlookup uint64
}
FUSE_FALLOCATE = 43

fallocate()函式,Allocate requested space.

請求頭後的實體
type FuseFallocateIn struct {
	Fh      uint64
	Offset  uint64
	Length  uint64
	Mode    uint32
	Padding uint32
}
響應頭的實體

fallocate只需響應頭返回成功與否

FUSE_READDIRPLUS = 44

readdirplus()函式,Read directory with attributes

請求頭後的實體
type FuseReadIn struct {
	Fh        uint64
	Offset    uint64
	Size      uint32
	ReadFlags uint32
	LockOwner uint64
	Flags     uint32
	Padding   uint32
}
響應頭的實體
type FuseReadOut struct {
	Content []byte
}
FUSE_RENAME2 = 45

參考rename但請求略有不同

請求頭後的實體
type FuseRename2In struct {
	NewDir  uint64
	Flags   uint32
	Padding uint32

	OldName string
	NewName string
}
響應頭的實體

rename只需響應頭返回成功與否