Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-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
go-fuse
Commits
75c95c33
Commit
75c95c33
authored
Apr 02, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move InHeader to raw. Drop opcode type.
parent
06ca7ac3
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
270 additions
and
254 deletions
+270
-254
fuse/api.go
fuse/api.go
+30
-30
fuse/defaultraw.go
fuse/defaultraw.go
+32
-32
fuse/direntry.go
fuse/direntry.go
+3
-1
fuse/fsconnector.go
fuse/fsconnector.go
+3
-3
fuse/fsops.go
fuse/fsops.go
+51
-51
fuse/lockingfs.go
fuse/lockingfs.go
+28
-28
fuse/mountstate.go
fuse/mountstate.go
+8
-8
fuse/opcode.go
fuse/opcode.go
+56
-62
fuse/request.go
fuse/request.go
+10
-10
fuse/types.go
fuse/types.go
+1
-29
raw/constants.go
raw/constants.go
+31
-0
raw/types.go
raw/types.go
+17
-0
No files found.
fuse/api.go
View file @
75c95c33
...
...
@@ -249,51 +249,51 @@ type DefaultFile struct{}
//
// Include DefaultRawFileSystem to inherit a null implementation.
type
RawFileSystem
interface
{
Lookup
(
header
*
InHeader
,
name
string
)
(
out
*
raw
.
EntryOut
,
status
Status
)
Lookup
(
header
*
raw
.
InHeader
,
name
string
)
(
out
*
raw
.
EntryOut
,
status
Status
)
Forget
(
nodeid
,
nlookup
uint64
)
// Attributes.
GetAttr
(
header
*
InHeader
,
input
*
raw
.
GetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
SetAttr
(
header
*
InHeader
,
input
*
raw
.
SetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
GetAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
GetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
SetAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
SetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
// Modifying structure.
Mknod
(
header
*
InHeader
,
input
*
raw
.
MknodIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Mkdir
(
header
*
InHeader
,
input
*
raw
.
MkdirIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
Rename
(
header
*
InHeader
,
input
*
raw
.
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
Link
(
header
*
InHeader
,
input
*
raw
.
LinkIn
,
filename
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Mknod
(
header
*
raw
.
InHeader
,
input
*
raw
.
MknodIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Mkdir
(
header
*
raw
.
InHeader
,
input
*
raw
.
MkdirIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Unlink
(
header
*
raw
.
InHeader
,
name
string
)
(
code
Status
)
Rmdir
(
header
*
raw
.
InHeader
,
name
string
)
(
code
Status
)
Rename
(
header
*
raw
.
InHeader
,
input
*
raw
.
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
Link
(
header
*
raw
.
InHeader
,
input
*
raw
.
LinkIn
,
filename
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
Access
(
header
*
InHeader
,
input
*
raw
.
AccessIn
)
(
code
Status
)
Symlink
(
header
*
raw
.
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
Readlink
(
header
*
raw
.
InHeader
)
(
out
[]
byte
,
code
Status
)
Access
(
header
*
raw
.
InHeader
,
input
*
raw
.
AccessIn
)
(
code
Status
)
// Extended attributes.
GetXAttrSize
(
header
*
InHeader
,
attr
string
)
(
sz
int
,
code
Status
)
GetXAttrData
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
ListXAttr
(
header
*
InHeader
)
(
attributes
[]
byte
,
code
Status
)
SetXAttr
(
header
*
InHeader
,
input
*
raw
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
(
code
Status
)
GetXAttrSize
(
header
*
raw
.
InHeader
,
attr
string
)
(
sz
int
,
code
Status
)
GetXAttrData
(
header
*
raw
.
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
ListXAttr
(
header
*
raw
.
InHeader
)
(
attributes
[]
byte
,
code
Status
)
SetXAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
RemoveXAttr
(
header
*
raw
.
InHeader
,
attr
string
)
(
code
Status
)
// File handling.
Create
(
header
*
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
raw
.
EntryOut
,
code
Status
)
Open
(
header
*
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
Read
(
*
InHeader
,
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
Create
(
header
*
raw
.
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
raw
.
EntryOut
,
code
Status
)
Open
(
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
Read
(
*
raw
.
InHeader
,
*
ReadIn
,
BufferPool
)
([]
byte
,
Status
)
Release
(
header
*
InHeader
,
input
*
raw
.
ReleaseIn
)
Write
(
*
InHeader
,
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Flush
(
header
*
InHeader
,
input
*
raw
.
FlushIn
)
Status
Fsync
(
*
InHeader
,
*
raw
.
FsyncIn
)
(
code
Status
)
Release
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
Write
(
*
raw
.
InHeader
,
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
Flush
(
header
*
raw
.
InHeader
,
input
*
raw
.
FlushIn
)
Status
Fsync
(
*
raw
.
InHeader
,
*
raw
.
FsyncIn
)
(
code
Status
)
// Directory handling
OpenDir
(
header
*
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
ReleaseDir
(
header
*
InHeader
,
input
*
raw
.
ReleaseIn
)
FsyncDir
(
header
*
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
OpenDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
ReadDir
(
header
*
raw
.
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
ReleaseDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
FsyncDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
//
Ioctl
(
header
*
InHeader
,
input
*
raw
.
IoctlIn
)
(
output
*
raw
.
IoctlOut
,
data
[]
byte
,
code
Status
)
StatFs
(
header
*
InHeader
)
*
StatfsOut
Ioctl
(
header
*
raw
.
InHeader
,
input
*
raw
.
IoctlIn
)
(
output
*
raw
.
IoctlOut
,
data
[]
byte
,
code
Status
)
StatFs
(
header
*
raw
.
InHeader
)
*
StatfsOut
// Provide callbacks for pushing notifications to the kernel.
Init
(
params
*
RawFsInit
)
...
...
fuse/defaultraw.go
View file @
75c95c33
...
...
@@ -7,131 +7,131 @@ import (
func
(
me
*
DefaultRawFileSystem
)
Init
(
init
*
RawFsInit
)
{
}
func
(
me
*
DefaultRawFileSystem
)
StatFs
(
h
*
InHeader
)
*
StatfsOut
{
func
(
me
*
DefaultRawFileSystem
)
StatFs
(
h
*
raw
.
InHeader
)
*
StatfsOut
{
return
nil
}
func
(
me
*
DefaultRawFileSystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Lookup
(
h
*
raw
.
InHeader
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Forget
(
nodeID
,
nlookup
uint64
)
{
}
func
(
me
*
DefaultRawFileSystem
)
GetAttr
(
header
*
InHeader
,
input
*
raw
.
GetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
GetAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
GetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Open
(
header
*
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Open
(
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
return
0
,
0
,
OK
}
func
(
me
*
DefaultRawFileSystem
)
SetAttr
(
header
*
InHeader
,
input
*
raw
.
SetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
SetAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
SetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Readlink
(
header
*
raw
.
InHeader
)
(
out
[]
byte
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Mknod
(
header
*
InHeader
,
input
*
raw
.
MknodIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Mknod
(
header
*
raw
.
InHeader
,
input
*
raw
.
MknodIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
return
new
(
raw
.
EntryOut
),
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Mkdir
(
header
*
InHeader
,
input
*
raw
.
MkdirIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Mkdir
(
header
*
raw
.
InHeader
,
input
*
raw
.
MkdirIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Unlink
(
header
*
raw
.
InHeader
,
name
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Rmdir
(
header
*
raw
.
InHeader
,
name
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Symlink
(
header
*
raw
.
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Rename
(
header
*
InHeader
,
input
*
raw
.
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Rename
(
header
*
raw
.
InHeader
,
input
*
raw
.
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Link
(
header
*
InHeader
,
input
*
raw
.
LinkIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Link
(
header
*
raw
.
InHeader
,
input
*
raw
.
LinkIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
GetXAttrSize
(
header
*
InHeader
,
attr
string
)
(
size
int
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
GetXAttrSize
(
header
*
raw
.
InHeader
,
attr
string
)
(
size
int
,
code
Status
)
{
return
0
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
GetXAttrData
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
GetXAttrData
(
header
*
raw
.
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
SetXAttr
(
header
*
InHeader
,
input
*
raw
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
func
(
me
*
DefaultRawFileSystem
)
SetXAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
ListXAttr
(
header
*
raw
.
InHeader
)
(
data
[]
byte
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
func
(
me
*
DefaultRawFileSystem
)
RemoveXAttr
(
header
*
raw
.
InHeader
,
attr
string
)
Status
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Access
(
header
*
InHeader
,
input
*
raw
.
AccessIn
)
(
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Access
(
header
*
raw
.
InHeader
,
input
*
raw
.
AccessIn
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Create
(
header
*
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Create
(
header
*
raw
.
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
raw
.
EntryOut
,
code
Status
)
{
return
0
,
0
,
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Bmap
(
header
*
InHeader
,
input
*
raw
.
BmapIn
)
(
out
*
raw
.
BmapOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Bmap
(
header
*
raw
.
InHeader
,
input
*
raw
.
BmapIn
)
(
out
*
raw
.
BmapOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Poll
(
header
*
InHeader
,
input
*
raw
.
PollIn
)
(
out
*
raw
.
PollOut
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Poll
(
header
*
raw
.
InHeader
,
input
*
raw
.
PollIn
)
(
out
*
raw
.
PollOut
,
code
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
OpenDir
(
header
*
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
OpenDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
return
0
,
0
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Read
(
header
*
InHeader
,
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Release
(
header
*
InHeader
,
input
*
raw
.
ReleaseIn
)
{
func
(
me
*
DefaultRawFileSystem
)
Release
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
{
}
func
(
me
*
DefaultRawFileSystem
)
Write
(
header
*
InHeader
,
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Write
(
header
*
raw
.
InHeader
,
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
return
0
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Flush
(
header
*
InHeader
,
input
*
raw
.
FlushIn
)
Status
{
func
(
me
*
DefaultRawFileSystem
)
Flush
(
header
*
raw
.
InHeader
,
input
*
raw
.
FlushIn
)
Status
{
return
OK
}
func
(
me
*
DefaultRawFileSystem
)
Fsync
(
header
*
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Fsync
(
header
*
raw
.
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
ReadDir
(
header
*
raw
.
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
ReleaseDir
(
header
*
InHeader
,
input
*
raw
.
ReleaseIn
)
{
func
(
me
*
DefaultRawFileSystem
)
ReleaseDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
{
}
func
(
me
*
DefaultRawFileSystem
)
FsyncDir
(
header
*
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
FsyncDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
return
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
Ioctl
(
header
*
InHeader
,
input
*
raw
.
IoctlIn
)
(
output
*
raw
.
IoctlOut
,
data
[]
byte
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
Ioctl
(
header
*
raw
.
InHeader
,
input
*
raw
.
IoctlIn
)
(
output
*
raw
.
IoctlOut
,
data
[]
byte
,
code
Status
)
{
return
nil
,
nil
,
ENOSYS
}
fuse/direntry.go
View file @
75c95c33
...
...
@@ -6,6 +6,8 @@ import (
"bytes"
"fmt"
"unsafe"
"github.com/hanwen/go-fuse/raw"
)
var
_
=
fmt
.
Print
...
...
@@ -31,7 +33,7 @@ func (me *DirEntryList) AddString(name string, inode uint64, mode uint32) bool {
}
func
(
me
*
DirEntryList
)
AddDirEntry
(
e
DirEntry
)
bool
{
return
me
.
Add
([]
byte
(
e
.
Name
),
uint64
(
FUSE_UNKNOWN_INO
),
e
.
Mode
)
return
me
.
Add
([]
byte
(
e
.
Name
),
uint64
(
raw
.
FUSE_UNKNOWN_INO
),
e
.
Mode
)
}
func
(
me
*
DirEntryList
)
Add
(
name
[]
byte
,
inode
uint64
,
mode
uint32
)
bool
{
...
...
fuse/fsconnector.go
View file @
75c95c33
...
...
@@ -103,7 +103,7 @@ func (me *FileSystemConnector) findMount(parent *Inode, name string) (mount *fil
}
func
(
me
*
FileSystemConnector
)
toInode
(
nodeid
uint64
)
*
Inode
{
if
nodeid
==
FUSE_ROOT_ID
{
if
nodeid
==
raw
.
FUSE_ROOT_ID
{
return
me
.
rootNode
}
i
:=
(
*
Inode
)(
unsafe
.
Pointer
(
me
.
inodeMap
.
Decode
(
nodeid
)))
...
...
@@ -333,7 +333,7 @@ func (me *FileSystemConnector) Unmount(node *Inode) Status {
func
(
me
*
FileSystemConnector
)
FileNotify
(
node
*
Inode
,
off
int64
,
length
int64
)
Status
{
n
:=
node
.
nodeId
if
node
==
me
.
rootNode
{
n
=
FUSE_ROOT_ID
n
=
raw
.
FUSE_ROOT_ID
}
if
n
==
0
{
return
OK
...
...
@@ -349,7 +349,7 @@ func (me *FileSystemConnector) FileNotify(node *Inode, off int64, length int64)
func
(
me
*
FileSystemConnector
)
EntryNotify
(
dir
*
Inode
,
name
string
)
Status
{
n
:=
dir
.
nodeId
if
dir
==
me
.
rootNode
{
n
=
FUSE_ROOT_ID
n
=
raw
.
FUSE_ROOT_ID
}
if
n
==
0
{
return
OK
...
...
fuse/fsops.go
View file @
75c95c33
This diff is collapsed.
Click to expand it.
fuse/lockingfs.go
View file @
75c95c33
...
...
@@ -160,7 +160,7 @@ func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem {
return
l
}
func
(
me
*
LockingRawFileSystem
)
Lookup
(
h
*
InHeader
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Lookup
(
h
*
raw
.
InHeader
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Lookup
(
h
,
name
)
}
...
...
@@ -170,137 +170,137 @@ func (me *LockingRawFileSystem) Forget(nodeID uint64, nlookup uint64) {
me
.
RawFileSystem
.
Forget
(
nodeID
,
nlookup
)
}
func
(
me
*
LockingRawFileSystem
)
GetAttr
(
header
*
InHeader
,
input
*
raw
.
GetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
GetAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
GetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
GetAttr
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
Open
(
header
*
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Open
(
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
handle
uint64
,
status
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Open
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
SetAttr
(
header
*
InHeader
,
input
*
raw
.
SetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
SetAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
SetAttrIn
)
(
out
*
raw
.
AttrOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
SetAttr
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
Readlink
(
header
*
InHeader
)
(
out
[]
byte
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Readlink
(
header
*
raw
.
InHeader
)
(
out
[]
byte
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Readlink
(
header
)
}
func
(
me
*
LockingRawFileSystem
)
Mknod
(
header
*
InHeader
,
input
*
raw
.
MknodIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Mknod
(
header
*
raw
.
InHeader
,
input
*
raw
.
MknodIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Mknod
(
header
,
input
,
name
)
}
func
(
me
*
LockingRawFileSystem
)
Mkdir
(
header
*
InHeader
,
input
*
raw
.
MkdirIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Mkdir
(
header
*
raw
.
InHeader
,
input
*
raw
.
MkdirIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Mkdir
(
header
,
input
,
name
)
}
func
(
me
*
LockingRawFileSystem
)
Unlink
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Unlink
(
header
*
raw
.
InHeader
,
name
string
)
(
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Unlink
(
header
,
name
)
}
func
(
me
*
LockingRawFileSystem
)
Rmdir
(
header
*
InHeader
,
name
string
)
(
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Rmdir
(
header
*
raw
.
InHeader
,
name
string
)
(
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Rmdir
(
header
,
name
)
}
func
(
me
*
LockingRawFileSystem
)
Symlink
(
header
*
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Symlink
(
header
*
raw
.
InHeader
,
pointedTo
string
,
linkName
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Symlink
(
header
,
pointedTo
,
linkName
)
}
func
(
me
*
LockingRawFileSystem
)
Rename
(
header
*
InHeader
,
input
*
raw
.
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Rename
(
header
*
raw
.
InHeader
,
input
*
raw
.
RenameIn
,
oldName
string
,
newName
string
)
(
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Rename
(
header
,
input
,
oldName
,
newName
)
}
func
(
me
*
LockingRawFileSystem
)
Link
(
header
*
InHeader
,
input
*
raw
.
LinkIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Link
(
header
*
raw
.
InHeader
,
input
*
raw
.
LinkIn
,
name
string
)
(
out
*
raw
.
EntryOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Link
(
header
,
input
,
name
)
}
func
(
me
*
LockingRawFileSystem
)
SetXAttr
(
header
*
InHeader
,
input
*
raw
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
func
(
me
*
LockingRawFileSystem
)
SetXAttr
(
header
*
raw
.
InHeader
,
input
*
raw
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
SetXAttr
(
header
,
input
,
attr
,
data
)
}
func
(
me
*
LockingRawFileSystem
)
GetXAttrData
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
GetXAttrData
(
header
*
raw
.
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
GetXAttrData
(
header
,
attr
)
}
func
(
me
*
LockingRawFileSystem
)
GetXAttrSize
(
header
*
InHeader
,
attr
string
)
(
sz
int
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
GetXAttrSize
(
header
*
raw
.
InHeader
,
attr
string
)
(
sz
int
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
GetXAttrSize
(
header
,
attr
)
}
func
(
me
*
LockingRawFileSystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
ListXAttr
(
header
*
raw
.
InHeader
)
(
data
[]
byte
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
ListXAttr
(
header
)
}
func
(
me
*
LockingRawFileSystem
)
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
Status
{
func
(
me
*
LockingRawFileSystem
)
RemoveXAttr
(
header
*
raw
.
InHeader
,
attr
string
)
Status
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
RemoveXAttr
(
header
,
attr
)
}
func
(
me
*
LockingRawFileSystem
)
Access
(
header
*
InHeader
,
input
*
raw
.
AccessIn
)
(
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Access
(
header
*
raw
.
InHeader
,
input
*
raw
.
AccessIn
)
(
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Access
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
Create
(
header
*
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
raw
.
EntryOut
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Create
(
header
*
raw
.
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
flags
uint32
,
handle
uint64
,
out
*
raw
.
EntryOut
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Create
(
header
,
input
,
name
)
}
func
(
me
*
LockingRawFileSystem
)
OpenDir
(
header
*
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
h
uint64
,
status
Status
)
{
func
(
me
*
LockingRawFileSystem
)
OpenDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
flags
uint32
,
h
uint64
,
status
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
OpenDir
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
Release
(
header
*
InHeader
,
input
*
raw
.
ReleaseIn
)
{
func
(
me
*
LockingRawFileSystem
)
Release
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
{
defer
me
.
locked
()()
me
.
RawFileSystem
.
Release
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
ReleaseDir
(
header
*
InHeader
,
h
*
raw
.
ReleaseIn
)
{
func
(
me
*
LockingRawFileSystem
)
ReleaseDir
(
header
*
raw
.
InHeader
,
h
*
raw
.
ReleaseIn
)
{
defer
me
.
locked
()()
me
.
RawFileSystem
.
ReleaseDir
(
header
,
h
)
}
func
(
me
*
LockingRawFileSystem
)
Read
(
header
*
InHeader
,
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Read
(
header
,
input
,
bp
)
}
func
(
me
*
LockingRawFileSystem
)
Write
(
header
*
InHeader
,
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Write
(
header
*
raw
.
InHeader
,
input
*
WriteIn
,
data
[]
byte
)
(
written
uint32
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Write
(
header
,
input
,
data
)
}
func
(
me
*
LockingRawFileSystem
)
Flush
(
header
*
InHeader
,
input
*
raw
.
FlushIn
)
Status
{
func
(
me
*
LockingRawFileSystem
)
Flush
(
header
*
raw
.
InHeader
,
input
*
raw
.
FlushIn
)
Status
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Flush
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
Fsync
(
header
*
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
Fsync
(
header
*
raw
.
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
Fsync
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
ReadDir
(
header
*
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
func
(
me
*
LockingRawFileSystem
)
ReadDir
(
header
*
raw
.
InHeader
,
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
ReadDir
(
header
,
input
)
}
func
(
me
*
LockingRawFileSystem
)
FsyncDir
(
header
*
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
FsyncDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
FsyncDir
(
header
,
input
)
}
fuse/mountstate.go
View file @
75c95c33
...
...
@@ -166,7 +166,7 @@ func (me *MountState) recordStats(req *request) {
endNs
:=
time
.
Now
()
.
UnixNano
()
dt
:=
endNs
-
req
.
startNs
opname
:=
operationName
(
req
.
inHeader
.
o
pcode
)
opname
:=
operationName
(
req
.
inHeader
.
O
pcode
)
me
.
latencies
.
AddMany
(
[]
LatencyArg
{
{
opname
,
""
,
dt
},
...
...
@@ -234,7 +234,7 @@ func (me *MountState) handleRequest(req *request) {
}
if
req
.
status
.
Ok
()
&&
req
.
handler
.
Func
==
nil
{
log
.
Printf
(
"Unimplemented opcode %v"
,
req
.
inHeader
.
opcode
)
log
.
Printf
(
"Unimplemented opcode %v"
,
operationName
(
req
.
inHeader
.
Opcode
)
)
req
.
status
=
ENOSYS
}
...
...
@@ -245,13 +245,13 @@ func (me *MountState) handleRequest(req *request) {
errNo
:=
me
.
write
(
req
)
if
errNo
!=
0
{
log
.
Printf
(
"writer: Write/Writev %v failed, err: %v. opcode: %v"
,
req
.
outHeaderBytes
,
errNo
,
operationName
(
req
.
inHeader
.
o
pcode
))
req
.
outHeaderBytes
,
errNo
,
operationName
(
req
.
inHeader
.
O
pcode
))
}
}
func
(
me
*
MountState
)
write
(
req
*
request
)
Status
{
// Forget does not wait for reply.
if
req
.
inHeader
.
opcode
==
_OP_FORGET
||
req
.
inHeader
.
o
pcode
==
_OP_BATCH_FORGET
{
if
req
.
inHeader
.
Opcode
==
_OP_FORGET
||
req
.
inHeader
.
O
pcode
==
_OP_BATCH_FORGET
{
return
OK
}
...
...
@@ -281,8 +281,8 @@ func (me *MountState) write(req *request) Status {
func
(
me
*
MountState
)
writeInodeNotify
(
entry
*
raw
.
NotifyInvalInodeOut
)
Status
{
req
:=
request
{
inHeader
:
&
InHeader
{
o
pcode
:
_OP_NOTIFY_INODE
,
inHeader
:
&
raw
.
InHeader
{
O
pcode
:
_OP_NOTIFY_INODE
,
},
handler
:
operationHandlers
[
_OP_NOTIFY_INODE
],
status
:
raw
.
NOTIFY_INVAL_INODE
,
...
...
@@ -299,8 +299,8 @@ func (me *MountState) writeInodeNotify(entry *raw.NotifyInvalInodeOut) Status {
func
(
me
*
MountState
)
writeEntryNotify
(
parent
uint64
,
name
string
)
Status
{
req
:=
request
{
inHeader
:
&
InHeader
{
o
pcode
:
_OP_NOTIFY_ENTRY
,
inHeader
:
&
raw
.
InHeader
{
O
pcode
:
_OP_NOTIFY_ENTRY
,
},
handler
:
operationHandlers
[
_OP_NOTIFY_ENTRY
],
status
:
raw
.
NOTIFY_INVAL_ENTRY
,
...
...
fuse/opcode.go
View file @
75c95c33
...
...
@@ -13,55 +13,53 @@ import (
var
_
=
log
.
Printf
var
_
=
fmt
.
Printf
type
opcode
int
const
(
_OP_LOOKUP
=
opcode
(
1
)
_OP_FORGET
=
opcode
(
2
)
_OP_GETATTR
=
opcode
(
3
)
_OP_SETATTR
=
opcode
(
4
)
_OP_READLINK
=
opcode
(
5
)
_OP_SYMLINK
=
opcode
(
6
)
_OP_MKNOD
=
opcode
(
8
)
_OP_MKDIR
=
opcode
(
9
)
_OP_UNLINK
=
opcode
(
10
)
_OP_RMDIR
=
opcode
(
11
)
_OP_RENAME
=
opcode
(
12
)
_OP_LINK
=
opcode
(
13
)
_OP_OPEN
=
opcode
(
14
)
_OP_READ
=
opcode
(
15
)
_OP_WRITE
=
opcode
(
16
)
_OP_STATFS
=
opcode
(
17
)
_OP_RELEASE
=
opcode
(
18
)
_OP_FSYNC
=
opcode
(
20
)
_OP_SETXATTR
=
opcode
(
21
)
_OP_GETXATTR
=
opcode
(
22
)
_OP_LISTXATTR
=
opcode
(
23
)
_OP_REMOVEXATTR
=
opcode
(
24
)
_OP_FLUSH
=
opcode
(
25
)
_OP_INIT
=
opcode
(
26
)
_OP_OPENDIR
=
opcode
(
27
)
_OP_READDIR
=
opcode
(
28
)
_OP_RELEASEDIR
=
opcode
(
29
)
_OP_FSYNCDIR
=
opcode
(
30
)
_OP_GETLK
=
opcode
(
31
)
_OP_SETLK
=
opcode
(
32
)
_OP_SETLKW
=
opcode
(
33
)
_OP_ACCESS
=
opcode
(
34
)
_OP_CREATE
=
opcode
(
35
)
_OP_INTERRUPT
=
opcode
(
36
)
_OP_BMAP
=
opcode
(
37
)
_OP_DESTROY
=
opcode
(
38
)
_OP_IOCTL
=
opcode
(
39
)
_OP_POLL
=
opcode
(
40
)
_OP_NOTIFY_REPLY
=
opcode
(
41
)
_OP_BATCH_FORGET
=
opcode
(
42
)
_OP_LOOKUP
=
int32
(
1
)
_OP_FORGET
=
int32
(
2
)
_OP_GETATTR
=
int32
(
3
)
_OP_SETATTR
=
int32
(
4
)
_OP_READLINK
=
int32
(
5
)
_OP_SYMLINK
=
int32
(
6
)
_OP_MKNOD
=
int32
(
8
)
_OP_MKDIR
=
int32
(
9
)
_OP_UNLINK
=
int32
(
10
)
_OP_RMDIR
=
int32
(
11
)
_OP_RENAME
=
int32
(
12
)
_OP_LINK
=
int32
(
13
)
_OP_OPEN
=
int32
(
14
)
_OP_READ
=
int32
(
15
)
_OP_WRITE
=
int32
(
16
)
_OP_STATFS
=
int32
(
17
)
_OP_RELEASE
=
int32
(
18
)
_OP_FSYNC
=
int32
(
20
)
_OP_SETXATTR
=
int32
(
21
)
_OP_GETXATTR
=
int32
(
22
)
_OP_LISTXATTR
=
int32
(
23
)
_OP_REMOVEXATTR
=
int32
(
24
)
_OP_FLUSH
=
int32
(
25
)
_OP_INIT
=
int32
(
26
)
_OP_OPENDIR
=
int32
(
27
)
_OP_READDIR
=
int32
(
28
)
_OP_RELEASEDIR
=
int32
(
29
)
_OP_FSYNCDIR
=
int32
(
30
)
_OP_GETLK
=
int32
(
31
)
_OP_SETLK
=
int32
(
32
)
_OP_SETLKW
=
int32
(
33
)
_OP_ACCESS
=
int32
(
34
)
_OP_CREATE
=
int32
(
35
)
_OP_INTERRUPT
=
int32
(
36
)
_OP_BMAP
=
int32
(
37
)
_OP_DESTROY
=
int32
(
38
)
_OP_IOCTL
=
int32
(
39
)
_OP_POLL
=
int32
(
40
)
_OP_NOTIFY_REPLY
=
int32
(
41
)
_OP_BATCH_FORGET
=
int32
(
42
)
// Ugh - what will happen if FUSE introduces a new opcode here?
_OP_NOTIFY_ENTRY
=
opcode
(
51
)
_OP_NOTIFY_INODE
=
opcode
(
52
)
_OP_NOTIFY_ENTRY
=
int32
(
51
)
_OP_NOTIFY_INODE
=
int32
(
52
)
_OPCODE_COUNT
=
opcode
(
53
)
_OPCODE_COUNT
=
int32
(
53
)
)
////////////////////////////////////////////////////////////////
...
...
@@ -172,7 +170,7 @@ const _SECURITY_ACL = "system.posix_acl_access"
const
_SECURITY_ACL_DEFAULT
=
"system.posix_acl_default"
func
doGetXAttr
(
state
*
MountState
,
req
*
request
)
{
if
state
.
opts
.
IgnoreSecurityLabels
&&
req
.
inHeader
.
o
pcode
==
_OP_GETXATTR
{
if
state
.
opts
.
IgnoreSecurityLabels
&&
req
.
inHeader
.
O
pcode
==
_OP_GETXATTR
{
fn
:=
req
.
filenames
[
0
]
if
fn
==
_SECURITY_CAPABILITY
||
fn
==
_SECURITY_ACL_DEFAULT
||
fn
==
_SECURITY_ACL
{
...
...
@@ -184,7 +182,7 @@ func doGetXAttr(state *MountState, req *request) {
input
:=
(
*
raw
.
GetXAttrIn
)(
req
.
inData
)
var
data
[]
byte
switch
{
case
req
.
inHeader
.
o
pcode
==
_OP_GETXATTR
&&
input
.
Size
==
0
:
case
req
.
inHeader
.
O
pcode
==
_OP_GETXATTR
&&
input
.
Size
==
0
:
sz
,
code
:=
state
.
fileSystem
.
GetXAttrSize
(
req
.
inHeader
,
req
.
filenames
[
0
])
if
code
.
Ok
()
{
out
:=
&
raw
.
GetXAttrOut
{
...
...
@@ -195,7 +193,7 @@ func doGetXAttr(state *MountState, req *request) {
return
}
req
.
status
=
code
case
req
.
inHeader
.
o
pcode
==
_OP_GETXATTR
:
case
req
.
inHeader
.
O
pcode
==
_OP_GETXATTR
:
data
,
req
.
status
=
state
.
fileSystem
.
GetXAttrData
(
req
.
inHeader
,
req
.
filenames
[
0
])
default
:
data
,
req
.
status
=
state
.
fileSystem
.
ListXAttr
(
req
.
inHeader
)
...
...
@@ -357,7 +355,7 @@ type operationHandler struct {
var
operationHandlers
[]
*
operationHandler
func
operationName
(
op
opcode
)
string
{
func
operationName
(
op
int32
)
string
{
h
:=
getHandler
(
op
)
if
h
==
nil
{
return
"unknown"
...
...
@@ -365,11 +363,7 @@ func operationName(op opcode) string {
return
h
.
Name
}
func
(
op
opcode
)
String
()
string
{
return
operationName
(
op
)
}
func
getHandler
(
o
opcode
)
*
operationHandler
{
func
getHandler
(
o
int32
)
*
operationHandler
{
if
o
>=
_OPCODE_COUNT
{
return
nil
}
...
...
@@ -382,12 +376,12 @@ func init() {
operationHandlers
[
i
]
=
&
operationHandler
{
Name
:
"UNKNOWN"
}
}
fileOps
:=
[]
opcode
{
_OP_READLINK
,
_OP_NOTIFY_ENTRY
}
fileOps
:=
[]
int32
{
_OP_READLINK
,
_OP_NOTIFY_ENTRY
}
for
_
,
op
:=
range
fileOps
{
operationHandlers
[
op
]
.
FileNameOut
=
true
}
for
op
,
sz
:=
range
map
[
opcode
]
uintptr
{
for
op
,
sz
:=
range
map
[
int32
]
uintptr
{
_OP_FORGET
:
unsafe
.
Sizeof
(
raw
.
ForgetIn
{}),
_OP_BATCH_FORGET
:
unsafe
.
Sizeof
(
raw
.
BatchForgetIn
{}),
_OP_GETATTR
:
unsafe
.
Sizeof
(
raw
.
GetAttrIn
{}),
...
...
@@ -420,7 +414,7 @@ func init() {
operationHandlers
[
op
]
.
InputSize
=
sz
}
for
op
,
sz
:=
range
map
[
opcode
]
uintptr
{
for
op
,
sz
:=
range
map
[
int32
]
uintptr
{
_OP_LOOKUP
:
unsafe
.
Sizeof
(
raw
.
EntryOut
{}),
_OP_GETATTR
:
unsafe
.
Sizeof
(
raw
.
AttrOut
{}),
_OP_SETATTR
:
unsafe
.
Sizeof
(
raw
.
AttrOut
{}),
...
...
@@ -445,7 +439,7 @@ func init() {
operationHandlers
[
op
]
.
OutputSize
=
sz
}
for
op
,
v
:=
range
map
[
opcode
]
string
{
for
op
,
v
:=
range
map
[
int32
]
string
{
_OP_LOOKUP
:
"LOOKUP"
,
_OP_FORGET
:
"FORGET"
,
_OP_BATCH_FORGET
:
"BATCH_FORGET"
,
...
...
@@ -491,7 +485,7 @@ func init() {
operationHandlers
[
op
]
.
Name
=
v
}
for
op
,
v
:=
range
map
[
opcode
]
operationFunc
{
for
op
,
v
:=
range
map
[
int32
]
operationFunc
{
_OP_OPEN
:
doOpen
,
_OP_READDIR
:
doReadDir
,
_OP_WRITE
:
doWrite
,
...
...
@@ -529,7 +523,7 @@ func init() {
}
// Outputs.
for
op
,
f
:=
range
map
[
opcode
]
castPointerFunc
{
for
op
,
f
:=
range
map
[
int32
]
castPointerFunc
{
_OP_LOOKUP
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
EntryOut
)(
ptr
)
},
_OP_OPEN
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
OpenOut
)(
ptr
)
},
_OP_OPENDIR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
OpenOut
)(
ptr
)
},
...
...
@@ -547,7 +541,7 @@ func init() {
}
// Inputs.
for
op
,
f
:=
range
map
[
opcode
]
castPointerFunc
{
for
op
,
f
:=
range
map
[
int32
]
castPointerFunc
{
_OP_FLUSH
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
FlushIn
)(
ptr
)
},
_OP_GETATTR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
GetAttrIn
)(
ptr
)
},
_OP_SETATTR
:
func
(
ptr
unsafe
.
Pointer
)
interface
{}
{
return
(
*
raw
.
SetAttrIn
)(
ptr
)
},
...
...
@@ -570,7 +564,7 @@ func init() {
}
// File name args.
for
op
,
count
:=
range
map
[
opcode
]
int
{
for
op
,
count
:=
range
map
[
int32
]
int
{
_OP_CREATE
:
1
,
_OP_GETXATTR
:
1
,
_OP_LINK
:
1
,
...
...
fuse/request.go
View file @
75c95c33
...
...
@@ -14,7 +14,7 @@ type request struct {
inputBuf
[]
byte
// These split up inputBuf.
inHeader
*
InHeader
// generic header
inHeader
*
raw
.
InHeader
// generic header
inData
unsafe
.
Pointer
// per op data
arg
[]
byte
// flat data.
filenames
[]
string
// filename arguments
...
...
@@ -51,8 +51,8 @@ func (me *request) InputDebug() string {
names
+=
fmt
.
Sprintf
(
" %d bytes"
,
len
(
me
.
arg
))
}
return
fmt
.
Sprintf
(
"Dispatch: %
v
, NodeId: %v.%v%v"
,
me
.
inHeader
.
opcode
,
me
.
inHeader
.
NodeId
,
val
,
names
)
return
fmt
.
Sprintf
(
"Dispatch: %
s
, NodeId: %v.%v%v"
,
operationName
(
me
.
inHeader
.
Opcode
)
,
me
.
inHeader
.
NodeId
,
val
,
names
)
}
func
(
me
*
request
)
OutputDebug
()
string
{
...
...
@@ -81,29 +81,29 @@ func (me *request) OutputDebug() string {
}
}
return
fmt
.
Sprintf
(
"Serialize: %
v
code: %v value: %v%v"
,
me
.
inHeader
.
opcode
,
me
.
status
,
dataStr
,
flatStr
)
return
fmt
.
Sprintf
(
"Serialize: %
s
code: %v value: %v%v"
,
operationName
(
me
.
inHeader
.
Opcode
)
,
me
.
status
,
dataStr
,
flatStr
)
}
func
(
me
*
request
)
parse
()
{
inHSize
:=
int
(
unsafe
.
Sizeof
(
InHeader
{}))
inHSize
:=
int
(
unsafe
.
Sizeof
(
raw
.
InHeader
{}))
if
len
(
me
.
inputBuf
)
<
inHSize
{
log
.
Printf
(
"Short read for input header: %v"
,
me
.
inputBuf
)
return
}
me
.
inHeader
=
(
*
InHeader
)(
unsafe
.
Pointer
(
&
me
.
inputBuf
[
0
]))
me
.
inHeader
=
(
*
raw
.
InHeader
)(
unsafe
.
Pointer
(
&
me
.
inputBuf
[
0
]))
me
.
arg
=
me
.
inputBuf
[
inHSize
:
]
me
.
handler
=
getHandler
(
me
.
inHeader
.
o
pcode
)
me
.
handler
=
getHandler
(
me
.
inHeader
.
O
pcode
)
if
me
.
handler
==
nil
{
log
.
Printf
(
"Unknown opcode %
v"
,
me
.
inHeader
.
o
pcode
)
log
.
Printf
(
"Unknown opcode %
d"
,
me
.
inHeader
.
O
pcode
)
me
.
status
=
ENOSYS
return
}
if
len
(
me
.
arg
)
<
int
(
me
.
handler
.
InputSize
)
{
log
.
Printf
(
"Short read for %v: %v"
,
me
.
inHeader
.
opcode
,
me
.
arg
)
log
.
Printf
(
"Short read for %v: %v"
,
operationName
(
me
.
inHeader
.
Opcode
)
,
me
.
arg
)
me
.
status
=
EIO
return
}
...
...
fuse/types.go
View file @
75c95c33
...
...
@@ -7,27 +7,11 @@ import (
)
const
(
FUSE_ROOT_ID
=
1
FUSE_UNKNOWN_INO
=
0xffffffff
CUSE_UNRESTRICTED_IOCTL
=
(
1
<<
0
)
FUSE_LK_FLOCK
=
(
1
<<
0
)
FUSE_IOCTL_MAX_IOV
=
256
FUSE_POLL_SCHEDULE_NOTIFY
=
(
1
<<
0
)
CUSE_INIT_INFO_MAX
=
4096
S_IFDIR
=
syscall
.
S_IFDIR
S_IFREG
=
syscall
.
S_IFREG
S_IFLNK
=
syscall
.
S_IFLNK
S_IFIFO
=
syscall
.
S_IFIFO
CUSE_INIT
=
4096
O_ANYWRITE
=
uint32
(
os
.
O_WRONLY
|
os
.
O_RDWR
|
os
.
O_APPEND
|
os
.
O_CREATE
|
os
.
O_TRUNC
)
)
...
...
@@ -62,10 +46,7 @@ type Attr raw.Attr
type
Owner
raw
.
Owner
type
Context
struct
{
Owner
Pid
uint32
}
type
Context
raw
.
Context
type
Kstatfs
struct
{
Blocks
uint64
...
...
@@ -113,15 +94,6 @@ type StatfsOut struct {
Kstatfs
}
type
InHeader
struct
{
Length
uint32
opcode
Unique
uint64
NodeId
uint64
Context
Padding
uint32
}
type
Dirent
struct
{
Ino
uint64
Off
uint64
...
...
raw/constants.go
0 → 100644
View file @
75c95c33
package
raw
import
(
"os"
"syscall"
)
const
(
FUSE_ROOT_ID
=
1
FUSE_UNKNOWN_INO
=
0xffffffff
CUSE_UNRESTRICTED_IOCTL
=
(
1
<<
0
)
FUSE_LK_FLOCK
=
(
1
<<
0
)
FUSE_IOCTL_MAX_IOV
=
256
FUSE_POLL_SCHEDULE_NOTIFY
=
(
1
<<
0
)
CUSE_INIT_INFO_MAX
=
4096
S_IFDIR
=
syscall
.
S_IFDIR
S_IFREG
=
syscall
.
S_IFREG
S_IFLNK
=
syscall
.
S_IFLNK
S_IFIFO
=
syscall
.
S_IFIFO
CUSE_INIT
=
4096
O_ANYWRITE
=
uint32
(
os
.
O_WRONLY
|
os
.
O_RDWR
|
os
.
O_APPEND
|
os
.
O_CREATE
|
os
.
O_TRUNC
)
)
raw/types.go
View file @
75c95c33
// The raw package contains types and constants used for the FUSE wire
// protocol.
package
raw
...
...
@@ -350,3 +353,17 @@ type CreateOut struct {
EntryOut
OpenOut
}
type
Context
struct
{
Owner
Pid
uint32
}
type
InHeader
struct
{
Length
uint32
Opcode
int32
Unique
uint64
NodeId
uint64
Context
Padding
uint32
}
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