Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
3b9092ac
Commit
3b9092ac
authored
Jul 24, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use InMessage in several places.
parent
0370159a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
31 deletions
+48
-31
connection.go
connection.go
+24
-8
fuseops/convert.go
fuseops/convert.go
+24
-23
No files found.
connection.go
View file @
3b9092ac
...
...
@@ -15,6 +15,7 @@
package
fuse
import
(
"errors"
"fmt"
"log"
"path"
...
...
@@ -24,6 +25,7 @@ import (
"golang.org/x/net/context"
"github.com/jacobsa/fuse/fuseops"
"github.com/jacobsa/fuse/internal/buffer"
"github.com/jacobsa/fuse/internal/fusekernel"
"github.com/jacobsa/fuse/internal/fuseshim"
)
...
...
@@ -202,6 +204,21 @@ func (c *Connection) handleInterrupt(fuseID uint64) {
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
// closed the connection.
//
...
...
@@ -212,9 +229,9 @@ func (c *Connection) handleInterrupt(fuseID uint64) {
func
(
c
*
Connection
)
ReadOp
()
(
op
fuseops
.
Op
,
err
error
)
{
// Keep going until we find a request we know how to convert.
for
{
// Read the next message from the
fuseshim connection
.
var
m
*
fuseshim
.
Message
m
,
err
=
c
.
wrapped
.
R
eadMessage
()
// Read the next message from the
kernel
.
var
m
*
buffer
.
In
Message
m
,
err
=
c
.
r
eadMessage
()
if
err
!=
nil
{
return
}
...
...
@@ -224,7 +241,7 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
c
.
nextOpID
++
// Set up op dependencies.
opCtx
:=
c
.
beginOp
(
m
.
H
dr
.
Opcode
,
m
.
Hdr
.
Unique
)
opCtx
:=
c
.
beginOp
(
m
.
H
eader
()
.
Opcode
,
m
.
Header
()
.
Unique
)
var
debugLogForOp
func
(
int
,
string
,
...
interface
{})
if
c
.
debugLogger
!=
nil
{
...
...
@@ -238,12 +255,11 @@ func (c *Connection) ReadOp() (op fuseops.Op, err error) {
fuseID
uint64
,
replyMsg
[]
byte
,
opErr
error
)
(
err
error
)
{
// Make sure we destroy the message, as required by
// fuseshim.Connection.ReadMessage.
defer
m
.
Destroy
()
// Make sure we destroy the message, as required by readMessage.
defer
c
.
destroyInMessage
(
m
)
// Clean up state for this op.
c
.
finishOp
(
m
.
H
dr
.
Opcode
,
m
.
Hdr
.
Unique
)
c
.
finishOp
(
m
.
H
eader
()
.
Opcode
,
m
.
Header
()
.
Unique
)
// Debug logging
if
c
.
debugLogger
!=
nil
{
...
...
fuseops/convert.go
View file @
3b9092ac
...
...
@@ -23,6 +23,7 @@ import (
"time"
"unsafe"
"github.com/jacobsa/fuse/internal/buffer"
"github.com/jacobsa/fuse/internal/fusekernel"
"github.com/jacobsa/fuse/internal/fuseshim"
"golang.org/x/net/context"
...
...
@@ -39,7 +40,7 @@ import (
// responsible for arranging for the message to be destroyed.
func
Convert
(
opCtx
context
.
Context
,
m
*
fuseshim
.
Message
,
m
*
buffer
.
In
Message
,
protocol
fusekernel
.
Protocol
,
debugLogForOp
func
(
int
,
string
,
...
interface
{}),
errorLogger
*
log
.
Logger
,
...
...
@@ -47,7 +48,7 @@ func Convert(
var
co
*
commonOp
var
io
internalOp
switch
m
.
H
dr
.
Opcode
{
switch
m
.
H
eader
()
.
Opcode
{
case
fusekernel
.
OpLookup
:
buf
:=
m
.
Bytes
()
n
:=
len
(
buf
)
...
...
@@ -58,7 +59,7 @@ func Convert(
to
:=
&
LookUpInodeOp
{
protocol
:
protocol
,
Parent
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Parent
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Name
:
string
(
buf
[
:
n
-
1
]),
}
io
=
to
...
...
@@ -67,7 +68,7 @@ func Convert(
case
fusekernel
.
OpGetattr
:
to
:=
&
GetInodeAttributesOp
{
protocol
:
protocol
,
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
}
io
=
to
co
=
&
to
.
commonOp
...
...
@@ -81,7 +82,7 @@ func Convert(
to
:=
&
SetInodeAttributesOp
{
protocol
:
protocol
,
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
}
valid
:=
fusekernel
.
SetattrValid
(
in
.
Valid
)
...
...
@@ -115,7 +116,7 @@ func Convert(
}
to
:=
&
ForgetInodeOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
N
:
in
.
Nlookup
,
}
io
=
to
...
...
@@ -138,7 +139,7 @@ func Convert(
to
:=
&
MkDirOp
{
protocol
:
protocol
,
Parent
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Parent
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Name
:
string
(
name
),
// On Linux, vfs_mkdir calls through to the inode with at most
...
...
@@ -170,7 +171,7 @@ func Convert(
to
:=
&
CreateFileOp
{
protocol
:
protocol
,
Parent
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Parent
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Name
:
string
(
name
),
Mode
:
fuseshim
.
FileMode
(
in
.
Mode
),
}
...
...
@@ -193,7 +194,7 @@ func Convert(
to
:=
&
CreateSymlinkOp
{
protocol
:
protocol
,
Parent
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Parent
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Name
:
string
(
newName
),
Target
:
string
(
target
),
}
...
...
@@ -224,7 +225,7 @@ func Convert(
oldName
,
newName
:=
names
[
:
i
],
names
[
i
+
1
:
len
(
names
)
-
1
]
to
:=
&
RenameOp
{
OldParent
:
InodeID
(
m
.
H
dr
.
Nodeid
),
OldParent
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
OldName
:
string
(
oldName
),
NewParent
:
InodeID
(
in
.
Newdir
),
NewName
:
string
(
newName
),
...
...
@@ -241,7 +242,7 @@ func Convert(
}
to
:=
&
UnlinkOp
{
Parent
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Parent
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Name
:
string
(
buf
[
:
n
-
1
]),
}
io
=
to
...
...
@@ -256,7 +257,7 @@ func Convert(
}
to
:=
&
RmDirOp
{
Parent
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Parent
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Name
:
string
(
buf
[
:
n
-
1
]),
}
io
=
to
...
...
@@ -264,14 +265,14 @@ func Convert(
case
fusekernel
.
OpOpen
:
to
:=
&
OpenFileOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
}
io
=
to
co
=
&
to
.
commonOp
case
fusekernel
.
OpOpendir
:
to
:=
&
OpenDirOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
}
io
=
to
co
=
&
to
.
commonOp
...
...
@@ -284,7 +285,7 @@ func Convert(
}
to
:=
&
ReadFileOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Handle
:
HandleID
(
in
.
Fh
),
Offset
:
int64
(
in
.
Offset
),
Size
:
int
(
in
.
Size
),
...
...
@@ -300,7 +301,7 @@ func Convert(
}
to
:=
&
ReadDirOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Handle
:
HandleID
(
in
.
Fh
),
Offset
:
DirOffset
(
in
.
Offset
),
Size
:
int
(
in
.
Size
),
...
...
@@ -349,7 +350,7 @@ func Convert(
}
to
:=
&
WriteFileOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Handle
:
HandleID
(
in
.
Fh
),
Data
:
buf
,
Offset
:
int64
(
in
.
Offset
),
...
...
@@ -365,7 +366,7 @@ func Convert(
}
to
:=
&
SyncFileOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Handle
:
HandleID
(
in
.
Fh
),
}
io
=
to
...
...
@@ -379,7 +380,7 @@ func Convert(
}
to
:=
&
FlushFileOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
Handle
:
HandleID
(
in
.
Fh
),
}
io
=
to
...
...
@@ -387,7 +388,7 @@ func Convert(
case
fusekernel
.
OpReadlink
:
to
:=
&
ReadSymlinkOp
{
Inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
Inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
}
io
=
to
co
=
&
to
.
commonOp
...
...
@@ -412,8 +413,8 @@ func Convert(
default
:
to
:=
&
unknownOp
{
opCode
:
m
.
H
dr
.
Opcode
,
inode
:
InodeID
(
m
.
H
dr
.
Nodeid
),
opCode
:
m
.
H
eader
()
.
Opcode
,
inode
:
InodeID
(
m
.
H
eader
()
.
Nodeid
),
}
io
=
to
co
=
&
to
.
commonOp
...
...
@@ -422,7 +423,7 @@ func Convert(
co
.
init
(
opCtx
,
io
,
m
.
H
dr
.
Unique
,
m
.
H
eader
()
.
Unique
,
sendReply
,
debugLogForOp
,
errorLogger
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment