Commit 043296a8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: sync opcodes and capabilities

This adds opcodes and capabilities from this week's upstream kernel.

As of commit 53db28933 ("fuse: extend init flags"), the init message
has been extended to 104 bytes, with more flags added in a flags2
field.

Prepare for this by allowing _OP_INIT to have short reads.

Tested on Fedora 38 (Linux 6.4.14) and Fedora 34 (Linux 5.11)

Change-Id: I366ecda9e23f1a329134677075ee839674ff4c57
parent 36842ef6
...@@ -62,6 +62,12 @@ const ( ...@@ -62,6 +62,12 @@ const (
_OP_LSEEK = uint32(46) // protocol version 24 _OP_LSEEK = uint32(46) // protocol version 24
_OP_COPY_FILE_RANGE = uint32(47) // protocol version 28. _OP_COPY_FILE_RANGE = uint32(47) // protocol version 28.
_OP_SETUPMAPPING = 48
_OP_REMOVEMAPPING = 49
_OP_SYNCFS = 50
_OP_TMPFILE = 51
_OP_STATX = 52
// The following entries don't have to be compatible across Go-FUSE versions. // The following entries don't have to be compatible across Go-FUSE versions.
_OP_NOTIFY_INVAL_ENTRY = uint32(100) _OP_NOTIFY_INVAL_ENTRY = uint32(100)
_OP_NOTIFY_INVAL_INODE = uint32(101) _OP_NOTIFY_INVAL_INODE = uint32(101)
...@@ -692,6 +698,10 @@ func init() { ...@@ -692,6 +698,10 @@ func init() {
_OP_RENAME2: "RENAME2", _OP_RENAME2: "RENAME2",
_OP_LSEEK: "LSEEK", _OP_LSEEK: "LSEEK",
_OP_COPY_FILE_RANGE: "COPY_FILE_RANGE", _OP_COPY_FILE_RANGE: "COPY_FILE_RANGE",
_OP_SETUPMAPPING: "SETUPMAPPING",
_OP_REMOVEMAPPING: "REMOVEMAPPING",
_OP_SYNCFS: "SYNCFS",
_OP_TMPFILE: "TMPFILE",
} { } {
operationHandlers[op].Name = v operationHandlers[op].Name = v
} }
......
...@@ -46,6 +46,17 @@ var ( ...@@ -46,6 +46,17 @@ var (
CAP_CACHE_SYMLINKS: "CACHE_SYMLINKS", CAP_CACHE_SYMLINKS: "CACHE_SYMLINKS",
CAP_NO_OPENDIR_SUPPORT: "NO_OPENDIR_SUPPORT", CAP_NO_OPENDIR_SUPPORT: "NO_OPENDIR_SUPPORT",
CAP_EXPLICIT_INVAL_DATA: "EXPLICIT_INVAL_DATA", CAP_EXPLICIT_INVAL_DATA: "EXPLICIT_INVAL_DATA",
CAP_MAP_ALIGNMENT: "MAP_ALIGNMENT",
CAP_SUBMOUNTS: "SUBMOUNTS",
CAP_HANDLE_KILLPRIV_V2: "HANDLE_KILLPRIV_V2",
CAP_SETXATTR_EXT: "SETXATTR_EXT",
CAP_INIT_EXT: "INIT_EXT",
CAP_INIT_RESERVED: "INIT_RESERVED",
CAP_SECURITY_CTX: "SECURITY_CTX",
CAP_HAS_INODE_DAX: "HAS_INODE_DAX",
CAP_CREATE_SUPP_GROUP: "CREATE_SUPP_GROUP",
CAP_HAS_EXPIRE_ONLY: "HAS_EXPIRE_ONLY",
CAP_DIRECT_IO_RELAX: "DIRECT_IO_RELAX",
}) })
releaseFlagNames = newFlagNames(map[int64]string{ releaseFlagNames = newFlagNames(map[int64]string{
RELEASE_FLUSH: "FLUSH", RELEASE_FLUSH: "FLUSH",
...@@ -209,7 +220,7 @@ func (in *OpenOut) string() string { ...@@ -209,7 +220,7 @@ func (in *OpenOut) string() string {
func (in *InitIn) string() string { func (in *InitIn) string() string {
return fmt.Sprintf("{%d.%d Ra %d %s}", return fmt.Sprintf("{%d.%d Ra %d %s}",
in.Major, in.Minor, in.MaxReadAhead, in.Major, in.Minor, in.MaxReadAhead,
flagString(initFlagNames, int64(in.Flags), "")) flagString(initFlagNames, int64(in.Flags)|(int64(in.Flags2)<<32), ""))
} }
func (o *InitOut) string() string { func (o *InitOut) string() string {
......
...@@ -181,7 +181,12 @@ func (r *request) parse() { ...@@ -181,7 +181,12 @@ func (r *request) parse() {
return return
} }
if len(r.arg) < int(r.handler.InputSize) { inSz := int(r.handler.InputSize)
if r.inHeader.Opcode == _OP_INIT && inSz > len(r.arg) {
// Minor version 36 extended the size of InitIn struct
inSz = len(r.arg)
}
if len(r.arg) < inSz {
log.Printf("Short read for %v: %v", operationName(r.inHeader.Opcode), r.arg) log.Printf("Short read for %v: %v", operationName(r.inHeader.Opcode), r.arg)
r.status = EIO r.status = EIO
return return
...@@ -189,7 +194,7 @@ func (r *request) parse() { ...@@ -189,7 +194,7 @@ func (r *request) parse() {
if r.handler.InputSize > 0 { if r.handler.InputSize > 0 {
r.inData = unsafe.Pointer(&r.arg[0]) r.inData = unsafe.Pointer(&r.arg[0])
r.arg = r.arg[r.handler.InputSize:] r.arg = r.arg[inSz:]
} else { } else {
r.arg = r.arg[unsafe.Sizeof(InHeader{}):] r.arg = r.arg[unsafe.Sizeof(InHeader{}):]
} }
......
...@@ -126,17 +126,18 @@ type Owner struct { ...@@ -126,17 +126,18 @@ type Owner struct {
} }
const ( // SetAttrIn.Valid const ( // SetAttrIn.Valid
FATTR_MODE = (1 << 0) FATTR_MODE = (1 << 0)
FATTR_UID = (1 << 1) FATTR_UID = (1 << 1)
FATTR_GID = (1 << 2) FATTR_GID = (1 << 2)
FATTR_SIZE = (1 << 3) FATTR_SIZE = (1 << 3)
FATTR_ATIME = (1 << 4) FATTR_ATIME = (1 << 4)
FATTR_MTIME = (1 << 5) FATTR_MTIME = (1 << 5)
FATTR_FH = (1 << 6) FATTR_FH = (1 << 6)
FATTR_ATIME_NOW = (1 << 7) FATTR_ATIME_NOW = (1 << 7)
FATTR_MTIME_NOW = (1 << 8) FATTR_MTIME_NOW = (1 << 8)
FATTR_LOCKOWNER = (1 << 9) FATTR_LOCKOWNER = (1 << 9)
FATTR_CTIME = (1 << 10) FATTR_CTIME = (1 << 10)
FATTR_KILL_SUIDGID = (1 << 11)
) )
type SetAttrInCommon struct { type SetAttrInCommon struct {
...@@ -251,11 +252,13 @@ type OpenIn struct { ...@@ -251,11 +252,13 @@ type OpenIn struct {
const ( const (
// OpenOut.Flags // OpenOut.Flags
FOPEN_DIRECT_IO = (1 << 0) FOPEN_DIRECT_IO = (1 << 0)
FOPEN_KEEP_CACHE = (1 << 1) FOPEN_KEEP_CACHE = (1 << 1)
FOPEN_NONSEEKABLE = (1 << 2) FOPEN_NONSEEKABLE = (1 << 2)
FOPEN_CACHE_DIR = (1 << 3) FOPEN_CACHE_DIR = (1 << 3)
FOPEN_STREAM = (1 << 4) FOPEN_STREAM = (1 << 4)
FOPEN_NOFLUSH = (1 << 5)
FOPEN_PARALLEL_DIRECT_WRITES = (1 << 6)
) )
type OpenOut struct { type OpenOut struct {
...@@ -299,6 +302,19 @@ const ( ...@@ -299,6 +302,19 @@ const (
CAP_CACHE_SYMLINKS = (1 << 23) CAP_CACHE_SYMLINKS = (1 << 23)
CAP_NO_OPENDIR_SUPPORT = (1 << 24) CAP_NO_OPENDIR_SUPPORT = (1 << 24)
CAP_EXPLICIT_INVAL_DATA = (1 << 25) CAP_EXPLICIT_INVAL_DATA = (1 << 25)
CAP_MAP_ALIGNMENT = (1 << 26)
CAP_SUBMOUNTS = (1 << 27)
CAP_HANDLE_KILLPRIV_V2 = (1 << 28)
CAP_SETXATTR_EXT = (1 << 29)
CAP_INIT_EXT = (1 << 30)
CAP_INIT_RESERVED = (1 << 31)
/* bits 32..63 get shifted down 32 bits into the Flags2 field */
CAP_SECURITY_CTX = (1 << 32)
CAP_HAS_INODE_DAX = (1 << 33)
CAP_CREATE_SUPP_GROUP = (1 << 34)
CAP_HAS_EXPIRE_ONLY = (1 << 35)
CAP_DIRECT_IO_RELAX = (1 << 36)
) )
type InitIn struct { type InitIn struct {
...@@ -308,6 +324,8 @@ type InitIn struct { ...@@ -308,6 +324,8 @@ type InitIn struct {
Minor uint32 Minor uint32
MaxReadAhead uint32 MaxReadAhead uint32
Flags uint32 Flags uint32
Flags2 uint32
Unused [11]uint32
} }
type InitOut struct { type InitOut struct {
...@@ -321,7 +339,8 @@ type InitOut struct { ...@@ -321,7 +339,8 @@ type InitOut struct {
TimeGran uint32 TimeGran uint32
MaxPages uint16 MaxPages uint16
Padding uint16 Padding uint16
Unused [8]uint32 Flags2 uint32
Unused [7]uint32
} }
type _CuseInitIn struct { type _CuseInitIn struct {
...@@ -645,8 +664,9 @@ const ( ...@@ -645,8 +664,9 @@ const (
) )
const ( const (
WRITE_CACHE = (1 << 0) WRITE_CACHE = (1 << 0)
WRITE_LOCKOWNER = (1 << 1) WRITE_LOCKOWNER = (1 << 1)
WRITE_KILL_SUIDGID = (1 << 2)
) )
type FallocateIn struct { type FallocateIn struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment