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:
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{
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
OpenFlags: &openFlags,
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
}

View File

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

View File

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