Pass OpenFlags for OpenFileOp (#127)

notifications
Mei Gui 2022-07-18 04:15:27 -07:00 committed by GitHub
parent 13117049f3
commit 9cc4ff0bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -294,8 +294,16 @@ func convertInMessage(
} }
case fusekernel.OpOpen: case fusekernel.OpOpen:
type input fusekernel.OpenIn
in := (*input)(inMsg.Consume(unsafe.Sizeof(input{})))
if in == nil {
return nil, errors.New("Corrupt OpOpen")
}
openFlags := fusekernel.OpenFlags(in.Flags)
o = &fuseops.OpenFileOp{ o = &fuseops.OpenFileOp{
Inode: fuseops.InodeID(inMsg.Header().Nodeid), Inode: fuseops.InodeID(inMsg.Header().Nodeid),
OpenFlags: &openFlags,
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid}, OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
} }

View File

@ -17,6 +17,8 @@ package fuseops
import ( import (
"os" "os"
"time" "time"
"github.com/jacobsa/fuse/internal/fusekernel"
) )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -646,6 +648,8 @@ type OpenFileOp struct {
// advance, for example, because contents are generated on the fly. // advance, for example, because contents are generated on the fly.
UseDirectIO bool UseDirectIO bool
OpenFlags *fusekernel.OpenFlags
OpContext OpContext OpContext OpContext
} }

View File

@ -661,6 +661,9 @@ func (fs *memFS) OpenFile(
// OpenFileOp should have a valid pid in context. // OpenFileOp should have a valid pid in context.
return fuse.EINVAL return fuse.EINVAL
} }
if op.OpenFlags == nil {
return fuse.EINVAL
}
fs.mu.Lock() fs.mu.Lock()
defer fs.mu.Unlock() defer fs.mu.Unlock()