Use InMessage in several places.
parent
0370159a68
commit
3b9092aca5
|
@ -15,6 +15,7 @@
|
||||||
package fuse
|
package fuse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"path"
|
"path"
|
||||||
|
@ -24,6 +25,7 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
"github.com/jacobsa/fuse/fuseops"
|
"github.com/jacobsa/fuse/fuseops"
|
||||||
|
"github.com/jacobsa/fuse/internal/buffer"
|
||||||
"github.com/jacobsa/fuse/internal/fusekernel"
|
"github.com/jacobsa/fuse/internal/fusekernel"
|
||||||
"github.com/jacobsa/fuse/internal/fuseshim"
|
"github.com/jacobsa/fuse/internal/fuseshim"
|
||||||
)
|
)
|
||||||
|
@ -202,6 +204,21 @@ func (c *Connection) handleInterrupt(fuseID uint64) {
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Connection) allocateInMessage() (m *buffer.InMessage) {
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Connection) destroyInMessage(m *buffer.InMessage) {
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the next message from the kernel. The message must later be destroyed
|
||||||
|
// using destroyInMessage.
|
||||||
|
func (c *Connection) readMessage() (m *buffer.InMessage, err error) {
|
||||||
|
err = errors.New("TODO")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Read the next op from the kernel process. Return io.EOF if the kernel has
|
// Read the next op from the kernel process. Return io.EOF if the kernel has
|
||||||
// closed the connection.
|
// closed the connection.
|
||||||
//
|
//
|
||||||
|
@ -212,9 +229,9 @@ func (c *Connection) handleInterrupt(fuseID uint64) {
|
||||||
func (c *Connection) ReadOp() (op fuseops.Op, err error) {
|
func (c *Connection) ReadOp() (op fuseops.Op, err error) {
|
||||||
// Keep going until we find a request we know how to convert.
|
// Keep going until we find a request we know how to convert.
|
||||||
for {
|
for {
|
||||||
// Read the next message from the fuseshim connection.
|
// Read the next message from the kernel.
|
||||||
var m *fuseshim.Message
|
var m *buffer.InMessage
|
||||||
m, err = c.wrapped.ReadMessage()
|
m, err = c.readMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -224,7 +241,7 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
|
||||||
c.nextOpID++
|
c.nextOpID++
|
||||||
|
|
||||||
// Set up op dependencies.
|
// Set up op dependencies.
|
||||||
opCtx := c.beginOp(m.Hdr.Opcode, m.Hdr.Unique)
|
opCtx := c.beginOp(m.Header().Opcode, m.Header().Unique)
|
||||||
|
|
||||||
var debugLogForOp func(int, string, ...interface{})
|
var debugLogForOp func(int, string, ...interface{})
|
||||||
if c.debugLogger != nil {
|
if c.debugLogger != nil {
|
||||||
|
@ -238,12 +255,11 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
|
||||||
fuseID uint64,
|
fuseID uint64,
|
||||||
replyMsg []byte,
|
replyMsg []byte,
|
||||||
opErr error) (err error) {
|
opErr error) (err error) {
|
||||||
// Make sure we destroy the message, as required by
|
// Make sure we destroy the message, as required by readMessage.
|
||||||
// fuseshim.Connection.ReadMessage.
|
defer c.destroyInMessage(m)
|
||||||
defer m.Destroy()
|
|
||||||
|
|
||||||
// Clean up state for this op.
|
// Clean up state for this op.
|
||||||
c.finishOp(m.Hdr.Opcode, m.Hdr.Unique)
|
c.finishOp(m.Header().Opcode, m.Header().Unique)
|
||||||
|
|
||||||
// Debug logging
|
// Debug logging
|
||||||
if c.debugLogger != nil {
|
if c.debugLogger != nil {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/jacobsa/fuse/internal/buffer"
|
||||||
"github.com/jacobsa/fuse/internal/fusekernel"
|
"github.com/jacobsa/fuse/internal/fusekernel"
|
||||||
"github.com/jacobsa/fuse/internal/fuseshim"
|
"github.com/jacobsa/fuse/internal/fuseshim"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
@ -39,7 +40,7 @@ import (
|
||||||
// responsible for arranging for the message to be destroyed.
|
// responsible for arranging for the message to be destroyed.
|
||||||
func Convert(
|
func Convert(
|
||||||
opCtx context.Context,
|
opCtx context.Context,
|
||||||
m *fuseshim.Message,
|
m *buffer.InMessage,
|
||||||
protocol fusekernel.Protocol,
|
protocol fusekernel.Protocol,
|
||||||
debugLogForOp func(int, string, ...interface{}),
|
debugLogForOp func(int, string, ...interface{}),
|
||||||
errorLogger *log.Logger,
|
errorLogger *log.Logger,
|
||||||
|
@ -47,7 +48,7 @@ func Convert(
|
||||||
var co *commonOp
|
var co *commonOp
|
||||||
|
|
||||||
var io internalOp
|
var io internalOp
|
||||||
switch m.Hdr.Opcode {
|
switch m.Header().Opcode {
|
||||||
case fusekernel.OpLookup:
|
case fusekernel.OpLookup:
|
||||||
buf := m.Bytes()
|
buf := m.Bytes()
|
||||||
n := len(buf)
|
n := len(buf)
|
||||||
|
@ -58,7 +59,7 @@ func Convert(
|
||||||
|
|
||||||
to := &LookUpInodeOp{
|
to := &LookUpInodeOp{
|
||||||
protocol: protocol,
|
protocol: protocol,
|
||||||
Parent: InodeID(m.Hdr.Nodeid),
|
Parent: InodeID(m.Header().Nodeid),
|
||||||
Name: string(buf[:n-1]),
|
Name: string(buf[:n-1]),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
|
@ -67,7 +68,7 @@ func Convert(
|
||||||
case fusekernel.OpGetattr:
|
case fusekernel.OpGetattr:
|
||||||
to := &GetInodeAttributesOp{
|
to := &GetInodeAttributesOp{
|
||||||
protocol: protocol,
|
protocol: protocol,
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
co = &to.commonOp
|
co = &to.commonOp
|
||||||
|
@ -81,7 +82,7 @@ func Convert(
|
||||||
|
|
||||||
to := &SetInodeAttributesOp{
|
to := &SetInodeAttributesOp{
|
||||||
protocol: protocol,
|
protocol: protocol,
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
}
|
}
|
||||||
|
|
||||||
valid := fusekernel.SetattrValid(in.Valid)
|
valid := fusekernel.SetattrValid(in.Valid)
|
||||||
|
@ -115,7 +116,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &ForgetInodeOp{
|
to := &ForgetInodeOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
N: in.Nlookup,
|
N: in.Nlookup,
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
|
@ -138,7 +139,7 @@ func Convert(
|
||||||
|
|
||||||
to := &MkDirOp{
|
to := &MkDirOp{
|
||||||
protocol: protocol,
|
protocol: protocol,
|
||||||
Parent: InodeID(m.Hdr.Nodeid),
|
Parent: InodeID(m.Header().Nodeid),
|
||||||
Name: string(name),
|
Name: string(name),
|
||||||
|
|
||||||
// On Linux, vfs_mkdir calls through to the inode with at most
|
// On Linux, vfs_mkdir calls through to the inode with at most
|
||||||
|
@ -170,7 +171,7 @@ func Convert(
|
||||||
|
|
||||||
to := &CreateFileOp{
|
to := &CreateFileOp{
|
||||||
protocol: protocol,
|
protocol: protocol,
|
||||||
Parent: InodeID(m.Hdr.Nodeid),
|
Parent: InodeID(m.Header().Nodeid),
|
||||||
Name: string(name),
|
Name: string(name),
|
||||||
Mode: fuseshim.FileMode(in.Mode),
|
Mode: fuseshim.FileMode(in.Mode),
|
||||||
}
|
}
|
||||||
|
@ -193,7 +194,7 @@ func Convert(
|
||||||
|
|
||||||
to := &CreateSymlinkOp{
|
to := &CreateSymlinkOp{
|
||||||
protocol: protocol,
|
protocol: protocol,
|
||||||
Parent: InodeID(m.Hdr.Nodeid),
|
Parent: InodeID(m.Header().Nodeid),
|
||||||
Name: string(newName),
|
Name: string(newName),
|
||||||
Target: string(target),
|
Target: string(target),
|
||||||
}
|
}
|
||||||
|
@ -224,7 +225,7 @@ func Convert(
|
||||||
oldName, newName := names[:i], names[i+1:len(names)-1]
|
oldName, newName := names[:i], names[i+1:len(names)-1]
|
||||||
|
|
||||||
to := &RenameOp{
|
to := &RenameOp{
|
||||||
OldParent: InodeID(m.Hdr.Nodeid),
|
OldParent: InodeID(m.Header().Nodeid),
|
||||||
OldName: string(oldName),
|
OldName: string(oldName),
|
||||||
NewParent: InodeID(in.Newdir),
|
NewParent: InodeID(in.Newdir),
|
||||||
NewName: string(newName),
|
NewName: string(newName),
|
||||||
|
@ -241,7 +242,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &UnlinkOp{
|
to := &UnlinkOp{
|
||||||
Parent: InodeID(m.Hdr.Nodeid),
|
Parent: InodeID(m.Header().Nodeid),
|
||||||
Name: string(buf[:n-1]),
|
Name: string(buf[:n-1]),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
|
@ -256,7 +257,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &RmDirOp{
|
to := &RmDirOp{
|
||||||
Parent: InodeID(m.Hdr.Nodeid),
|
Parent: InodeID(m.Header().Nodeid),
|
||||||
Name: string(buf[:n-1]),
|
Name: string(buf[:n-1]),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
|
@ -264,14 +265,14 @@ func Convert(
|
||||||
|
|
||||||
case fusekernel.OpOpen:
|
case fusekernel.OpOpen:
|
||||||
to := &OpenFileOp{
|
to := &OpenFileOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
co = &to.commonOp
|
co = &to.commonOp
|
||||||
|
|
||||||
case fusekernel.OpOpendir:
|
case fusekernel.OpOpendir:
|
||||||
to := &OpenDirOp{
|
to := &OpenDirOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
co = &to.commonOp
|
co = &to.commonOp
|
||||||
|
@ -284,7 +285,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &ReadFileOp{
|
to := &ReadFileOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
Handle: HandleID(in.Fh),
|
Handle: HandleID(in.Fh),
|
||||||
Offset: int64(in.Offset),
|
Offset: int64(in.Offset),
|
||||||
Size: int(in.Size),
|
Size: int(in.Size),
|
||||||
|
@ -300,7 +301,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &ReadDirOp{
|
to := &ReadDirOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
Handle: HandleID(in.Fh),
|
Handle: HandleID(in.Fh),
|
||||||
Offset: DirOffset(in.Offset),
|
Offset: DirOffset(in.Offset),
|
||||||
Size: int(in.Size),
|
Size: int(in.Size),
|
||||||
|
@ -349,7 +350,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &WriteFileOp{
|
to := &WriteFileOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
Handle: HandleID(in.Fh),
|
Handle: HandleID(in.Fh),
|
||||||
Data: buf,
|
Data: buf,
|
||||||
Offset: int64(in.Offset),
|
Offset: int64(in.Offset),
|
||||||
|
@ -365,7 +366,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &SyncFileOp{
|
to := &SyncFileOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
Handle: HandleID(in.Fh),
|
Handle: HandleID(in.Fh),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
|
@ -379,7 +380,7 @@ func Convert(
|
||||||
}
|
}
|
||||||
|
|
||||||
to := &FlushFileOp{
|
to := &FlushFileOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
Handle: HandleID(in.Fh),
|
Handle: HandleID(in.Fh),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
|
@ -387,7 +388,7 @@ func Convert(
|
||||||
|
|
||||||
case fusekernel.OpReadlink:
|
case fusekernel.OpReadlink:
|
||||||
to := &ReadSymlinkOp{
|
to := &ReadSymlinkOp{
|
||||||
Inode: InodeID(m.Hdr.Nodeid),
|
Inode: InodeID(m.Header().Nodeid),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
co = &to.commonOp
|
co = &to.commonOp
|
||||||
|
@ -412,8 +413,8 @@ func Convert(
|
||||||
|
|
||||||
default:
|
default:
|
||||||
to := &unknownOp{
|
to := &unknownOp{
|
||||||
opCode: m.Hdr.Opcode,
|
opCode: m.Header().Opcode,
|
||||||
inode: InodeID(m.Hdr.Nodeid),
|
inode: InodeID(m.Header().Nodeid),
|
||||||
}
|
}
|
||||||
io = to
|
io = to
|
||||||
co = &to.commonOp
|
co = &to.commonOp
|
||||||
|
@ -422,7 +423,7 @@ func Convert(
|
||||||
co.init(
|
co.init(
|
||||||
opCtx,
|
opCtx,
|
||||||
io,
|
io,
|
||||||
m.Hdr.Unique,
|
m.Header().Unique,
|
||||||
sendReply,
|
sendReply,
|
||||||
debugLogForOp,
|
debugLogForOp,
|
||||||
errorLogger)
|
errorLogger)
|
||||||
|
|
Loading…
Reference in New Issue