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
e6ec0065
Commit
e6ec0065
authored
Mar 27, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: regularize method naming
parent
1ab130b4
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
97 additions
and
88 deletions
+97
-88
nodefs/README.md
nodefs/README.md
+4
-0
nodefs/api.go
nodefs/api.go
+27
-26
nodefs/bridge.go
nodefs/bridge.go
+15
-15
nodefs/cache_test.go
nodefs/cache_test.go
+1
-1
nodefs/default.go
nodefs/default.go
+29
-27
nodefs/files.go
nodefs/files.go
+6
-6
nodefs/loopback.go
nodefs/loopback.go
+8
-6
nodefs/loopback_linux.go
nodefs/loopback_linux.go
+4
-4
nodefs/simple_test.go
nodefs/simple_test.go
+1
-1
nodefs/zip_test.go
nodefs/zip_test.go
+2
-2
No files found.
nodefs/README.md
View file @
e6ec0065
...
@@ -50,6 +50,10 @@ Decisions
...
@@ -50,6 +50,10 @@ Decisions
reading) are handled automatically. No support for directory
reading) are handled automatically. No support for directory
seeks.
seeks.
*
Method names are based on syscall names. Where there is no
syscall (eg. "open directory"), we bias towards writing
everything together (Opendir)
To do/To decide
To do/To decide
=========
=========
...
...
nodefs/api.go
View file @
e6ec0065
...
@@ -67,7 +67,8 @@ import (
...
@@ -67,7 +67,8 @@ import (
// Operations is the interface that implements the filesystem inode.
// Operations is the interface that implements the filesystem inode.
// Each Operations instance must embed OperationStubs. All error
// Each Operations instance must embed OperationStubs. All error
// reporting must use the syscall.Errno type. The value 0 (`OK`)
// reporting must use the syscall.Errno type. The value 0 (`OK`)
// should be used to indicate success.
// should be used to indicate success. The method names are inspired
// on the system call names, so we have Listxattr rather than ListXAttr.
type
Operations
interface
{
type
Operations
interface
{
// populateInode and inode are used by nodefs internally to
// populateInode and inode are used by nodefs internally to
// link Inode to a Node.
// link Inode to a Node.
...
@@ -82,9 +83,9 @@ type Operations interface {
...
@@ -82,9 +83,9 @@ type Operations interface {
// OperationStubs, and should not be reimplemented.
// OperationStubs, and should not be reimplemented.
Inode
()
*
Inode
Inode
()
*
Inode
// Stat
F
s implements statistics for the filesystem that holds
// Stat
f
s implements statistics for the filesystem that holds
// this Inode.
// this Inode.
Stat
F
s
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
Stat
f
s
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
// Access should return if the caller can access the file with
// Access should return if the caller can access the file with
// the given mode. In this case, the context has data about
// the given mode. In this case, the context has data about
...
@@ -95,10 +96,10 @@ type Operations interface {
...
@@ -95,10 +96,10 @@ type Operations interface {
// GetAttr reads attributes for an Inode. The library will
// GetAttr reads attributes for an Inode. The library will
// ensure that Mode and Ino are set correctly. For regular
// ensure that Mode and Ino are set correctly. For regular
// files, Size should be set so it can be read correctly.
// files, Size should be set so it can be read correctly.
Get
A
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
Get
a
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
// SetAttr sets attributes for an Inode.
// SetAttr sets attributes for an Inode.
Set
A
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
Set
a
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
// OnAdd is called once this Operations object is attached to
// OnAdd is called once this Operations object is attached to
// an Inode.
// an Inode.
...
@@ -112,19 +113,19 @@ type XAttrOperations interface {
...
@@ -112,19 +113,19 @@ type XAttrOperations interface {
// GetXAttr should read data for the given attribute into
// GetXAttr should read data for the given attribute into
// `dest` and return the number of bytes. If `dest` is too
// `dest` and return the number of bytes. If `dest` is too
// small, it should return ERANGE and the size of the attribute.
// small, it should return ERANGE and the size of the attribute.
Get
XA
ttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
Get
xa
ttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
// SetXAttr should store data for the given attribute. See
// SetXAttr should store data for the given attribute. See
// setxattr(2) for information about flags.
// setxattr(2) for information about flags.
Set
XA
ttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
syscall
.
Errno
Set
xa
ttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
syscall
.
Errno
// RemoveXAttr should delete the given attribute.
// RemoveXAttr should delete the given attribute.
Remove
XA
ttr
(
ctx
context
.
Context
,
attr
string
)
syscall
.
Errno
Remove
xa
ttr
(
ctx
context
.
Context
,
attr
string
)
syscall
.
Errno
// ListXAttr should read all attributes (null terminated) into
// ListXAttr should read all attributes (null terminated) into
// `dest`. If the `dest` buffer is too small, it should return
// `dest`. If the `dest` buffer is too small, it should return
// ERANGE and the correct size.
// ERANGE and the correct size.
List
XA
ttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
List
xa
ttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
}
}
// SymlinkOperations holds operations specific to symlinks.
// SymlinkOperations holds operations specific to symlinks.
...
@@ -177,11 +178,11 @@ type FileOperations interface {
...
@@ -177,11 +178,11 @@ type FileOperations interface {
// never encounter ESPACE.
// never encounter ESPACE.
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
syscall
.
Errno
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
syscall
.
Errno
// FGet
Attr is like GetA
ttr but provides a file handle if available.
// FGet
attr is like Geta
ttr but provides a file handle if available.
F
GetA
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
F
geta
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
// FSet
A
ttr is like SetAttr but provides a file handle if available.
// FSet
a
ttr is like SetAttr but provides a file handle if available.
F
SetA
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
F
seta
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
// CopyFileRange copies data between sections of two files,
// CopyFileRange copies data between sections of two files,
// without the data having to pass through the calling process.
// without the data having to pass through the calling process.
...
@@ -199,18 +200,18 @@ type FileOperations interface {
...
@@ -199,18 +200,18 @@ type FileOperations interface {
type
LockOperations
interface
{
type
LockOperations
interface
{
FileOperations
FileOperations
// Get
L
k returns locks that would conflict with the given
// Get
l
k returns locks that would conflict with the given
// input lock. If no locks conflict, the output has type
// input lock. If no locks conflict, the output has type
// L_UNLCK. See fcntl(2) for more information.
// L_UNLCK. See fcntl(2) for more information.
Get
L
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
syscall
.
Errno
Get
l
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
syscall
.
Errno
//
Obtain
a lock on a file, or fail if the lock could not
//
Setlk obtains
a lock on a file, or fail if the lock could not
// obtained. See fcntl(2) for more information.
// obtained. See fcntl(2) for more information.
Set
L
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
Set
l
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
//
Obtain
a lock on a file, waiting if necessary. See fcntl(2)
//
Setlkw obtains
a lock on a file, waiting if necessary. See fcntl(2)
// for more information.
// for more information.
Set
L
kw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
Set
l
kw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
}
}
// DirStream lists directory entries.
// DirStream lists directory entries.
...
@@ -246,10 +247,10 @@ type DirOperations interface {
...
@@ -246,10 +247,10 @@ type DirOperations interface {
// contents. The actual reading is driven from ReadDir, so
// contents. The actual reading is driven from ReadDir, so
// this method is just for performing sanity/permission
// this method is just for performing sanity/permission
// checks.
// checks.
Open
D
ir
(
ctx
context
.
Context
)
syscall
.
Errno
Open
d
ir
(
ctx
context
.
Context
)
syscall
.
Errno
// ReadDir opens a stream of directory entries.
// ReadDir opens a stream of directory entries.
Read
D
ir
(
ctx
context
.
Context
)
(
DirStream
,
syscall
.
Errno
)
Read
d
ir
(
ctx
context
.
Context
)
(
DirStream
,
syscall
.
Errno
)
}
}
// MutableDirOperations are operations for directories that can add or
// MutableDirOperations are operations for directories that can add or
...
@@ -307,9 +308,9 @@ type FileHandle interface {
...
@@ -307,9 +308,9 @@ type FileHandle interface {
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
errno
syscall
.
Errno
)
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
errno
syscall
.
Errno
)
Get
L
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
syscall
.
Errno
Get
l
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
syscall
.
Errno
Set
L
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
Set
l
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
Set
L
kw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
Set
l
kw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
syscall
.
Errno
Lseek
(
ctx
context
.
Context
,
off
uint64
,
whence
uint32
)
(
uint64
,
syscall
.
Errno
)
Lseek
(
ctx
context
.
Context
,
off
uint64
,
whence
uint32
)
(
uint64
,
syscall
.
Errno
)
...
@@ -319,8 +320,8 @@ type FileHandle interface {
...
@@ -319,8 +320,8 @@ type FileHandle interface {
Release
(
ctx
context
.
Context
)
syscall
.
Errno
Release
(
ctx
context
.
Context
)
syscall
.
Errno
Get
A
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
Get
a
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
Set
A
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
Set
a
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
syscall
.
Errno
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
syscall
.
Errno
}
}
...
...
nodefs/bridge.go
View file @
e6ec0065
...
@@ -320,7 +320,7 @@ func (b *rawBridge) Create(cancel <-chan struct{}, input *fuse.CreateIn, name st
...
@@ -320,7 +320,7 @@ func (b *rawBridge) Create(cancel <-chan struct{}, input *fuse.CreateIn, name st
out
.
OpenFlags
=
flags
out
.
OpenFlags
=
flags
var
temp
fuse
.
AttrOut
var
temp
fuse
.
AttrOut
f
.
Get
A
ttr
(
ctx
,
&
temp
)
f
.
Get
a
ttr
(
ctx
,
&
temp
)
out
.
Attr
=
temp
.
Attr
out
.
Attr
=
temp
.
Attr
out
.
AttrValid
=
temp
.
AttrValid
out
.
AttrValid
=
temp
.
AttrValid
out
.
AttrValidNsec
=
temp
.
AttrValidNsec
out
.
AttrValidNsec
=
temp
.
AttrValidNsec
...
@@ -360,13 +360,13 @@ func (b *rawBridge) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *
...
@@ -360,13 +360,13 @@ func (b *rawBridge) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *
b
.
mu
.
Unlock
()
b
.
mu
.
Unlock
()
}
}
errno
:=
fops
.
F
GetA
ttr
(
ctx
,
f
,
out
)
errno
:=
fops
.
F
geta
ttr
(
ctx
,
f
,
out
)
b
.
setAttrTimeout
(
out
)
b
.
setAttrTimeout
(
out
)
out
.
Ino
=
input
.
NodeId
out
.
Ino
=
input
.
NodeId
out
.
Mode
=
(
out
.
Attr
.
Mode
&
07777
)
|
n
.
nodeAttr
.
Mode
out
.
Mode
=
(
out
.
Attr
.
Mode
&
07777
)
|
n
.
nodeAttr
.
Mode
return
errnoToStatus
(
errno
)
return
errnoToStatus
(
errno
)
}
}
return
errnoToStatus
(
n
.
ops
.
Get
A
ttr
(
ctx
,
out
))
return
errnoToStatus
(
n
.
ops
.
Get
a
ttr
(
ctx
,
out
))
}
}
func
(
b
*
rawBridge
)
SetAttr
(
cancel
<-
chan
struct
{},
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
SetAttr
(
cancel
<-
chan
struct
{},
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
...
@@ -379,10 +379,10 @@ func (b *rawBridge) SetAttr(cancel <-chan struct{}, in *fuse.SetAttrIn, out *fus
...
@@ -379,10 +379,10 @@ func (b *rawBridge) SetAttr(cancel <-chan struct{}, in *fuse.SetAttrIn, out *fus
}
}
if
fops
,
ok
:=
n
.
ops
.
(
FileOperations
);
ok
{
if
fops
,
ok
:=
n
.
ops
.
(
FileOperations
);
ok
{
return
errnoToStatus
(
fops
.
F
SetA
ttr
(
ctx
,
f
,
in
,
out
))
return
errnoToStatus
(
fops
.
F
seta
ttr
(
ctx
,
f
,
in
,
out
))
}
}
return
errnoToStatus
(
n
.
ops
.
Set
A
ttr
(
ctx
,
in
,
out
))
return
errnoToStatus
(
n
.
ops
.
Set
a
ttr
(
ctx
,
in
,
out
))
}
}
func
(
b
*
rawBridge
)
Rename
(
cancel
<-
chan
struct
{},
input
*
fuse
.
RenameIn
,
oldName
string
,
newName
string
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
Rename
(
cancel
<-
chan
struct
{},
input
*
fuse
.
RenameIn
,
oldName
string
,
newName
string
)
fuse
.
Status
{
...
@@ -458,7 +458,7 @@ func (b *rawBridge) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr
...
@@ -458,7 +458,7 @@ func (b *rawBridge) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
nb
,
errno
:=
xops
.
Get
XA
ttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
attr
,
data
)
nb
,
errno
:=
xops
.
Get
xa
ttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
attr
,
data
)
return
nb
,
errnoToStatus
(
errno
)
return
nb
,
errnoToStatus
(
errno
)
}
}
...
@@ -468,7 +468,7 @@ func (b *rawBridge) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr
...
@@ -468,7 +468,7 @@ func (b *rawBridge) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr
func
(
b
*
rawBridge
)
ListXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
dest
[]
byte
)
(
sz
uint32
,
status
fuse
.
Status
)
{
func
(
b
*
rawBridge
)
ListXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
dest
[]
byte
)
(
sz
uint32
,
status
fuse
.
Status
)
{
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
sz
,
errno
:=
xops
.
List
XA
ttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
dest
)
sz
,
errno
:=
xops
.
List
xa
ttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
dest
)
return
sz
,
errnoToStatus
(
errno
)
return
sz
,
errnoToStatus
(
errno
)
}
}
return
0
,
fuse
.
ENOTSUP
return
0
,
fuse
.
ENOTSUP
...
@@ -477,7 +477,7 @@ func (b *rawBridge) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, des
...
@@ -477,7 +477,7 @@ func (b *rawBridge) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, des
func
(
b
*
rawBridge
)
SetXAttr
(
cancel
<-
chan
struct
{},
input
*
fuse
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
SetXAttr
(
cancel
<-
chan
struct
{},
input
*
fuse
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
fuse
.
Status
{
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
return
errnoToStatus
(
xops
.
Set
XA
ttr
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
attr
,
data
,
input
.
Flags
))
return
errnoToStatus
(
xops
.
Set
xa
ttr
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
attr
,
data
,
input
.
Flags
))
}
}
return
fuse
.
ENOTSUP
return
fuse
.
ENOTSUP
}
}
...
@@ -485,7 +485,7 @@ func (b *rawBridge) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, att
...
@@ -485,7 +485,7 @@ func (b *rawBridge) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, att
func
(
b
*
rawBridge
)
RemoveXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
attr
string
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
RemoveXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
attr
string
)
fuse
.
Status
{
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
if
xops
,
ok
:=
n
.
ops
.
(
XAttrOperations
);
ok
{
return
errnoToStatus
(
xops
.
Remove
XA
ttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
attr
))
return
errnoToStatus
(
xops
.
Remove
xa
ttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
attr
))
}
}
return
fuse
.
ENOTSUP
return
fuse
.
ENOTSUP
}
}
...
@@ -536,7 +536,7 @@ func (b *rawBridge) GetLk(cancel <-chan struct{}, input *fuse.LkIn, out *fuse.Lk
...
@@ -536,7 +536,7 @@ func (b *rawBridge) GetLk(cancel <-chan struct{}, input *fuse.LkIn, out *fuse.Lk
n
,
f
:=
b
.
inode
(
input
.
NodeId
,
input
.
Fh
)
n
,
f
:=
b
.
inode
(
input
.
NodeId
,
input
.
Fh
)
if
lops
,
ok
:=
n
.
ops
.
(
LockOperations
);
ok
{
if
lops
,
ok
:=
n
.
ops
.
(
LockOperations
);
ok
{
return
errnoToStatus
(
lops
.
Get
L
k
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
f
.
file
,
input
.
Owner
,
&
input
.
Lk
,
input
.
LkFlags
,
&
out
.
Lk
))
return
errnoToStatus
(
lops
.
Get
l
k
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
f
.
file
,
input
.
Owner
,
&
input
.
Lk
,
input
.
LkFlags
,
&
out
.
Lk
))
}
}
return
fuse
.
ENOTSUP
return
fuse
.
ENOTSUP
}
}
...
@@ -544,14 +544,14 @@ func (b *rawBridge) GetLk(cancel <-chan struct{}, input *fuse.LkIn, out *fuse.Lk
...
@@ -544,14 +544,14 @@ func (b *rawBridge) GetLk(cancel <-chan struct{}, input *fuse.LkIn, out *fuse.Lk
func
(
b
*
rawBridge
)
SetLk
(
cancel
<-
chan
struct
{},
input
*
fuse
.
LkIn
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
SetLk
(
cancel
<-
chan
struct
{},
input
*
fuse
.
LkIn
)
fuse
.
Status
{
n
,
f
:=
b
.
inode
(
input
.
NodeId
,
input
.
Fh
)
n
,
f
:=
b
.
inode
(
input
.
NodeId
,
input
.
Fh
)
if
lops
,
ok
:=
n
.
ops
.
(
LockOperations
);
ok
{
if
lops
,
ok
:=
n
.
ops
.
(
LockOperations
);
ok
{
return
errnoToStatus
(
lops
.
Set
L
k
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
f
.
file
,
input
.
Owner
,
&
input
.
Lk
,
input
.
LkFlags
))
return
errnoToStatus
(
lops
.
Set
l
k
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
f
.
file
,
input
.
Owner
,
&
input
.
Lk
,
input
.
LkFlags
))
}
}
return
fuse
.
ENOTSUP
return
fuse
.
ENOTSUP
}
}
func
(
b
*
rawBridge
)
SetLkw
(
cancel
<-
chan
struct
{},
input
*
fuse
.
LkIn
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
SetLkw
(
cancel
<-
chan
struct
{},
input
*
fuse
.
LkIn
)
fuse
.
Status
{
n
,
f
:=
b
.
inode
(
input
.
NodeId
,
input
.
Fh
)
n
,
f
:=
b
.
inode
(
input
.
NodeId
,
input
.
Fh
)
if
lops
,
ok
:=
n
.
ops
.
(
LockOperations
);
ok
{
if
lops
,
ok
:=
n
.
ops
.
(
LockOperations
);
ok
{
return
errnoToStatus
(
lops
.
Set
L
kw
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
f
.
file
,
input
.
Owner
,
&
input
.
Lk
,
input
.
LkFlags
))
return
errnoToStatus
(
lops
.
Set
l
kw
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
f
.
file
,
input
.
Owner
,
&
input
.
Lk
,
input
.
LkFlags
))
}
}
return
fuse
.
ENOTSUP
return
fuse
.
ENOTSUP
}
}
...
@@ -625,7 +625,7 @@ func (b *rawBridge) Fallocate(cancel <-chan struct{}, input *fuse.FallocateIn) f
...
@@ -625,7 +625,7 @@ func (b *rawBridge) Fallocate(cancel <-chan struct{}, input *fuse.FallocateIn) f
func
(
b
*
rawBridge
)
OpenDir
(
cancel
<-
chan
struct
{},
input
*
fuse
.
OpenIn
,
out
*
fuse
.
OpenOut
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
OpenDir
(
cancel
<-
chan
struct
{},
input
*
fuse
.
OpenIn
,
out
*
fuse
.
OpenOut
)
fuse
.
Status
{
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
errno
:=
n
.
dirOps
()
.
Open
D
ir
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
})
errno
:=
n
.
dirOps
()
.
Open
d
ir
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
})
if
errno
!=
0
{
if
errno
!=
0
{
return
errnoToStatus
(
errno
)
return
errnoToStatus
(
errno
)
}
}
...
@@ -641,7 +641,7 @@ func (b *rawBridge) getStream(cancel <-chan struct{}, input *fuse.ReadIn, inode
...
@@ -641,7 +641,7 @@ func (b *rawBridge) getStream(cancel <-chan struct{}, input *fuse.ReadIn, inode
f
.
dirStream
.
Close
()
f
.
dirStream
.
Close
()
f
.
dirStream
=
nil
f
.
dirStream
=
nil
}
}
str
,
errno
:=
inode
.
dirOps
()
.
Read
D
ir
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
})
str
,
errno
:=
inode
.
dirOps
()
.
Read
d
ir
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
})
if
errno
!=
0
{
if
errno
!=
0
{
return
errno
return
errno
}
}
...
@@ -737,7 +737,7 @@ func (b *rawBridge) FsyncDir(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.S
...
@@ -737,7 +737,7 @@ func (b *rawBridge) FsyncDir(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.S
func
(
b
*
rawBridge
)
StatFs
(
cancel
<-
chan
struct
{},
input
*
fuse
.
InHeader
,
out
*
fuse
.
StatfsOut
)
fuse
.
Status
{
func
(
b
*
rawBridge
)
StatFs
(
cancel
<-
chan
struct
{},
input
*
fuse
.
InHeader
,
out
*
fuse
.
StatfsOut
)
fuse
.
Status
{
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
return
errnoToStatus
(
n
.
ops
.
Stat
F
s
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
out
))
return
errnoToStatus
(
n
.
ops
.
Stat
f
s
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
out
))
}
}
func
(
b
*
rawBridge
)
Init
(
s
*
fuse
.
Server
)
{
func
(
b
*
rawBridge
)
Init
(
s
*
fuse
.
Server
)
{
...
...
nodefs/cache_test.go
View file @
e6ec0065
...
@@ -44,7 +44,7 @@ func (f *keepCacheFile) Open(ctx context.Context, flags uint32) (FileHandle, uin
...
@@ -44,7 +44,7 @@ func (f *keepCacheFile) Open(ctx context.Context, flags uint32) (FileHandle, uin
return
nil
,
fl
,
OK
return
nil
,
fl
,
OK
}
}
func
(
f
*
keepCacheFile
)
Get
A
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
f
*
keepCacheFile
)
Get
a
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
f
.
mu
.
Lock
()
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
defer
f
.
mu
.
Unlock
()
out
.
Size
=
uint64
(
len
(
f
.
content
))
out
.
Size
=
uint64
(
len
(
f
.
content
))
...
...
nodefs/default.go
View file @
e6ec0065
...
@@ -24,7 +24,9 @@ type OperationStubs struct {
...
@@ -24,7 +24,9 @@ type OperationStubs struct {
}
}
// check that we have implemented all interface methods
// check that we have implemented all interface methods
var
_
Operations
=
&
OperationStubs
{}
var
_
DirOperations
=
&
OperationStubs
{}
var
_
FileOperations
=
&
OperationStubs
{}
var
_
LockOperations
=
&
OperationStubs
{}
func
(
n
*
OperationStubs
)
inode
()
*
Inode
{
func
(
n
*
OperationStubs
)
inode
()
*
Inode
{
return
&
n
.
inode_
return
&
n
.
inode_
...
@@ -50,7 +52,7 @@ func (n *OperationStubs) Inode() *Inode {
...
@@ -50,7 +52,7 @@ func (n *OperationStubs) Inode() *Inode {
// StatFs zeroes the out argument and returns OK. This is because OSX
// StatFs zeroes the out argument and returns OK. This is because OSX
// filesystems must define this, or the mount will not work.
// filesystems must define this, or the mount will not work.
func
(
n
*
OperationStubs
)
Stat
F
s
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
{
func
(
n
*
OperationStubs
)
Stat
f
s
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
{
// this should be defined on OSX, or the FS won't mount
// this should be defined on OSX, or the FS won't mount
*
out
=
fuse
.
StatfsOut
{}
*
out
=
fuse
.
StatfsOut
{}
return
OK
return
OK
...
@@ -61,12 +63,12 @@ func (n *OperationStubs) OnAdd(ctx context.Context) {
...
@@ -61,12 +63,12 @@ func (n *OperationStubs) OnAdd(ctx context.Context) {
}
}
// GetAttr zeroes out argument and returns OK.
// GetAttr zeroes out argument and returns OK.
func
(
n
*
OperationStubs
)
Get
A
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
n
*
OperationStubs
)
Get
a
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
*
out
=
fuse
.
AttrOut
{}
*
out
=
fuse
.
AttrOut
{}
return
OK
return
OK
}
}
func
(
n
*
OperationStubs
)
Set
A
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
n
*
OperationStubs
)
Set
a
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
return
syscall
.
EROFS
return
syscall
.
EROFS
}
}
...
@@ -79,7 +81,7 @@ func (n *OperationStubs) Access(ctx context.Context, mask uint32) syscall.Errno
...
@@ -79,7 +81,7 @@ func (n *OperationStubs) Access(ctx context.Context, mask uint32) syscall.Errno
}
}
var
out
fuse
.
AttrOut
var
out
fuse
.
AttrOut
if
s
:=
n
.
inode
()
.
Operations
()
.
Get
A
ttr
(
ctx
,
&
out
);
s
!=
0
{
if
s
:=
n
.
inode
()
.
Operations
()
.
Get
a
ttr
(
ctx
,
&
out
);
s
!=
0
{
return
s
return
s
}
}
...
@@ -91,12 +93,12 @@ func (n *OperationStubs) Access(ctx context.Context, mask uint32) syscall.Errno
...
@@ -91,12 +93,12 @@ func (n *OperationStubs) Access(ctx context.Context, mask uint32) syscall.Errno
// FSetAttr delegates to the FileHandle's if f is not nil, or else to the
// FSetAttr delegates to the FileHandle's if f is not nil, or else to the
// Inode's SetAttr method.
// Inode's SetAttr method.
func
(
n
*
OperationStubs
)
F
SetA
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
n
*
OperationStubs
)
F
seta
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Set
A
ttr
(
ctx
,
in
,
out
)
return
f
.
Set
a
ttr
(
ctx
,
in
,
out
)
}
}
return
n
.
inode_
.
Operations
()
.
Set
A
ttr
(
ctx
,
in
,
out
)
return
n
.
inode_
.
Operations
()
.
Set
a
ttr
(
ctx
,
in
,
out
)
}
}
// The Lookup method on the OperationStubs type looks for an
// The Lookup method on the OperationStubs type looks for an
...
@@ -108,7 +110,7 @@ func (n *OperationStubs) Lookup(ctx context.Context, name string, out *fuse.Entr
...
@@ -108,7 +110,7 @@ func (n *OperationStubs) Lookup(ctx context.Context, name string, out *fuse.Entr
}
}
var
a
fuse
.
AttrOut
var
a
fuse
.
AttrOut
errno
:=
ch
.
Operations
()
.
Get
A
ttr
(
ctx
,
&
a
)
errno
:=
ch
.
Operations
()
.
Get
a
ttr
(
ctx
,
&
a
)
out
.
Attr
=
a
.
Attr
out
.
Attr
=
a
.
Attr
return
ch
,
errno
return
ch
,
errno
}
}
...
@@ -134,12 +136,12 @@ func (n *OperationStubs) Unlink(ctx context.Context, name string) syscall.Errno
...
@@ -134,12 +136,12 @@ func (n *OperationStubs) Unlink(ctx context.Context, name string) syscall.Errno
}
}
// The default OpenDir always succeeds
// The default OpenDir always succeeds
func
(
n
*
OperationStubs
)
Open
D
ir
(
ctx
context
.
Context
)
syscall
.
Errno
{
func
(
n
*
OperationStubs
)
Open
d
ir
(
ctx
context
.
Context
)
syscall
.
Errno
{
return
OK
return
OK
}
}
// The default ReadDir returns the list of children from the tree
// The default ReadDir returns the list of children from the tree
func
(
n
*
OperationStubs
)
Read
D
ir
(
ctx
context
.
Context
)
(
DirStream
,
syscall
.
Errno
)
{
func
(
n
*
OperationStubs
)
Read
d
ir
(
ctx
context
.
Context
)
(
DirStream
,
syscall
.
Errno
)
{
r
:=
[]
fuse
.
DirEntry
{}
r
:=
[]
fuse
.
DirEntry
{}
for
k
,
ch
:=
range
n
.
inode
()
.
Children
()
{
for
k
,
ch
:=
range
n
.
inode
()
.
Children
()
{
r
=
append
(
r
,
fuse
.
DirEntry
{
Mode
:
ch
.
Mode
(),
r
=
append
(
r
,
fuse
.
DirEntry
{
Mode
:
ch
.
Mode
(),
...
@@ -208,28 +210,28 @@ func (n *OperationStubs) Lseek(ctx context.Context, f FileHandle, off uint64, wh
...
@@ -208,28 +210,28 @@ func (n *OperationStubs) Lseek(ctx context.Context, f FileHandle, off uint64, wh
return
0
,
syscall
.
ENOTSUP
return
0
,
syscall
.
ENOTSUP
}
}
// Get
L
k delegates to the FileHandlef
// Get
l
k delegates to the FileHandlef
func
(
n
*
OperationStubs
)
Get
L
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
errno
syscall
.
Errno
)
{
func
(
n
*
OperationStubs
)
Get
l
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
errno
syscall
.
Errno
)
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Get
L
k
(
ctx
,
owner
,
lk
,
flags
,
out
)
return
f
.
Get
l
k
(
ctx
,
owner
,
lk
,
flags
,
out
)
}
}
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
// SetLk delegates to the FileHandle
// SetLk delegates to the FileHandle
func
(
n
*
OperationStubs
)
Set
L
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
func
(
n
*
OperationStubs
)
Set
l
k
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Set
L
k
(
ctx
,
owner
,
lk
,
flags
)
return
f
.
Set
l
k
(
ctx
,
owner
,
lk
,
flags
)
}
}
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
// SetLkw delegates to the FileHandle
// SetLkw delegates to the FileHandle
func
(
n
*
OperationStubs
)
Set
L
kw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
func
(
n
*
OperationStubs
)
Set
l
kw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Set
L
kw
(
ctx
,
owner
,
lk
,
flags
)
return
f
.
Set
l
kw
(
ctx
,
owner
,
lk
,
flags
)
}
}
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
...
@@ -261,13 +263,13 @@ func (n *OperationStubs) Allocate(ctx context.Context, f FileHandle, off uint64,
...
@@ -261,13 +263,13 @@ func (n *OperationStubs) Allocate(ctx context.Context, f FileHandle, off uint64,
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
// F
GetA
ttr delegates to the FileHandle's if f is not nil, or else to the
// F
geta
ttr delegates to the FileHandle's if f is not nil, or else to the
// Inode's GetAttr method.
// Inode's GetAttr method.
func
(
n
*
OperationStubs
)
F
GetA
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
n
*
OperationStubs
)
F
geta
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
if
f
!=
nil
{
if
f
!=
nil
{
f
.
Get
A
ttr
(
ctx
,
out
)
f
.
Get
a
ttr
(
ctx
,
out
)
}
}
return
n
.
inode_
.
ops
.
Get
A
ttr
(
ctx
,
out
)
return
n
.
inode_
.
ops
.
Get
a
ttr
(
ctx
,
out
)
}
}
// Open returns ENOTSUP
// Open returns ENOTSUP
...
@@ -320,15 +322,15 @@ func (f *FileHandleStubs) Write(ctx context.Context, data []byte, off int64) (wr
...
@@ -320,15 +322,15 @@ func (f *FileHandleStubs) Write(ctx context.Context, data []byte, off int64) (wr
return
0
,
syscall
.
ENOTSUP
return
0
,
syscall
.
ENOTSUP
}
}
func
(
f
*
FileHandleStubs
)
Get
L
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
errno
syscall
.
Errno
)
{
func
(
f
*
FileHandleStubs
)
Get
l
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
errno
syscall
.
Errno
)
{
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
func
(
f
*
FileHandleStubs
)
Set
L
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
func
(
f
*
FileHandleStubs
)
Set
l
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
func
(
f
*
FileHandleStubs
)
Set
L
kw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
func
(
f
*
FileHandleStubs
)
Set
l
kw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
...
@@ -340,11 +342,11 @@ func (f *FileHandleStubs) Release(ctx context.Context) syscall.Errno {
...
@@ -340,11 +342,11 @@ func (f *FileHandleStubs) Release(ctx context.Context) syscall.Errno {
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
func
(
f
*
FileHandleStubs
)
Get
A
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
f
*
FileHandleStubs
)
Get
a
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
func
(
f
*
FileHandleStubs
)
Set
A
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
f
*
FileHandleStubs
)
Set
a
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
return
syscall
.
ENOTSUP
return
syscall
.
ENOTSUP
}
}
...
...
nodefs/files.go
View file @
e6ec0065
...
@@ -64,7 +64,7 @@ const (
...
@@ -64,7 +64,7 @@ const (
_OFD_SETLKW
=
38
_OFD_SETLKW
=
38
)
)
func
(
f
*
loopbackFile
)
Get
L
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
errno
syscall
.
Errno
)
{
func
(
f
*
loopbackFile
)
Get
l
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
errno
syscall
.
Errno
)
{
flk
:=
syscall
.
Flock_t
{}
flk
:=
syscall
.
Flock_t
{}
lk
.
ToFlockT
(
&
flk
)
lk
.
ToFlockT
(
&
flk
)
errno
=
ToErrno
(
syscall
.
FcntlFlock
(
uintptr
(
f
.
fd
),
_OFD_GETLK
,
&
flk
))
errno
=
ToErrno
(
syscall
.
FcntlFlock
(
uintptr
(
f
.
fd
),
_OFD_GETLK
,
&
flk
))
...
@@ -72,11 +72,11 @@ func (f *loopbackFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLoc
...
@@ -72,11 +72,11 @@ func (f *loopbackFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLoc
return
return
}
}
func
(
f
*
loopbackFile
)
Set
L
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
func
(
f
*
loopbackFile
)
Set
l
k
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
return
f
.
setLock
(
ctx
,
owner
,
lk
,
flags
,
false
)
return
f
.
setLock
(
ctx
,
owner
,
lk
,
flags
,
false
)
}
}
func
(
f
*
loopbackFile
)
Set
L
kw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
func
(
f
*
loopbackFile
)
Set
l
kw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
errno
syscall
.
Errno
)
{
return
f
.
setLock
(
ctx
,
owner
,
lk
,
flags
,
true
)
return
f
.
setLock
(
ctx
,
owner
,
lk
,
flags
,
true
)
}
}
...
@@ -110,12 +110,12 @@ func (f *loopbackFile) setLock(ctx context.Context, owner uint64, lk *fuse.FileL
...
@@ -110,12 +110,12 @@ func (f *loopbackFile) setLock(ctx context.Context, owner uint64, lk *fuse.FileL
}
}
}
}
func
(
f
*
loopbackFile
)
Set
A
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
f
*
loopbackFile
)
Set
a
ttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
if
errno
:=
f
.
setAttr
(
ctx
,
in
);
errno
!=
0
{
if
errno
:=
f
.
setAttr
(
ctx
,
in
);
errno
!=
0
{
return
errno
return
errno
}
}
return
f
.
Get
A
ttr
(
ctx
,
out
)
return
f
.
Get
a
ttr
(
ctx
,
out
)
}
}
func
(
f
*
loopbackFile
)
setAttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
)
syscall
.
Errno
{
func
(
f
*
loopbackFile
)
setAttr
(
ctx
context
.
Context
,
in
*
fuse
.
SetAttrIn
)
syscall
.
Errno
{
...
@@ -172,7 +172,7 @@ func (f *loopbackFile) setAttr(ctx context.Context, in *fuse.SetAttrIn) syscall.
...
@@ -172,7 +172,7 @@ func (f *loopbackFile) setAttr(ctx context.Context, in *fuse.SetAttrIn) syscall.
return
OK
return
OK
}
}
func
(
f
*
loopbackFile
)
Get
A
ttr
(
ctx
context
.
Context
,
a
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
f
*
loopbackFile
)
Get
a
ttr
(
ctx
context
.
Context
,
a
*
fuse
.
AttrOut
)
syscall
.
Errno
{
st
:=
syscall
.
Stat_t
{}
st
:=
syscall
.
Stat_t
{}
err
:=
syscall
.
Fstat
(
f
.
fd
,
&
st
)
err
:=
syscall
.
Fstat
(
f
.
fd
,
&
st
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
nodefs/loopback.go
View file @
e6ec0065
...
@@ -6,6 +6,7 @@ package nodefs
...
@@ -6,6 +6,7 @@ package nodefs
import
(
import
(
"context"
"context"
"log"
"os"
"os"
"path/filepath"
"path/filepath"
"syscall"
"syscall"
...
@@ -20,7 +21,7 @@ type loopbackRoot struct {
...
@@ -20,7 +21,7 @@ type loopbackRoot struct {
rootDev
uint64
rootDev
uint64
}
}
func
(
n
*
loopbackNode
)
Stat
F
s
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
{
func
(
n
*
loopbackNode
)
Stat
f
s
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
syscall
.
Errno
{
s
:=
syscall
.
Statfs_t
{}
s
:=
syscall
.
Statfs_t
{}
err
:=
syscall
.
Statfs
(
n
.
path
(),
&
s
)
err
:=
syscall
.
Statfs
(
n
.
path
(),
&
s
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -30,7 +31,8 @@ func (n *loopbackNode) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.
...
@@ -30,7 +31,8 @@ func (n *loopbackNode) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.
return
OK
return
OK
}
}
func
(
n
*
loopbackRoot
)
GetAttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
n
*
loopbackRoot
)
Getattr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
log
.
Println
(
"getattr"
)
st
:=
syscall
.
Stat_t
{}
st
:=
syscall
.
Stat_t
{}
err
:=
syscall
.
Stat
(
n
.
rootPath
,
&
st
)
err
:=
syscall
.
Stat
(
n
.
rootPath
,
&
st
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -243,7 +245,7 @@ func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, f
...
@@ -243,7 +245,7 @@ func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, f
return
lf
,
0
,
0
return
lf
,
0
,
0
}
}
func
(
n
*
loopbackNode
)
Open
D
ir
(
ctx
context
.
Context
)
syscall
.
Errno
{
func
(
n
*
loopbackNode
)
Open
d
ir
(
ctx
context
.
Context
)
syscall
.
Errno
{
fd
,
err
:=
syscall
.
Open
(
n
.
path
(),
syscall
.
O_DIRECTORY
,
0755
)
fd
,
err
:=
syscall
.
Open
(
n
.
path
(),
syscall
.
O_DIRECTORY
,
0755
)
if
err
!=
nil
{
if
err
!=
nil
{
return
ToErrno
(
err
)
return
ToErrno
(
err
)
...
@@ -252,13 +254,13 @@ func (n *loopbackNode) OpenDir(ctx context.Context) syscall.Errno {
...
@@ -252,13 +254,13 @@ func (n *loopbackNode) OpenDir(ctx context.Context) syscall.Errno {
return
OK
return
OK
}
}
func
(
n
*
loopbackNode
)
Read
D
ir
(
ctx
context
.
Context
)
(
DirStream
,
syscall
.
Errno
)
{
func
(
n
*
loopbackNode
)
Read
d
ir
(
ctx
context
.
Context
)
(
DirStream
,
syscall
.
Errno
)
{
return
NewLoopbackDirStream
(
n
.
path
())
return
NewLoopbackDirStream
(
n
.
path
())
}
}
func
(
n
*
loopbackNode
)
F
GetA
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
n
*
loopbackNode
)
F
geta
ttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
if
f
!=
nil
{
if
f
!=
nil
{
return
f
.
Get
A
ttr
(
ctx
,
out
)
return
f
.
Get
a
ttr
(
ctx
,
out
)
}
}
p
:=
n
.
path
()
p
:=
n
.
path
()
...
...
nodefs/loopback_linux.go
View file @
e6ec0065
...
@@ -11,22 +11,22 @@ import (
...
@@ -11,22 +11,22 @@ import (
"golang.org/x/sys/unix"
"golang.org/x/sys/unix"
)
)
func
(
n
*
loopbackNode
)
Get
XA
ttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
{
func
(
n
*
loopbackNode
)
Get
xa
ttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
{
sz
,
err
:=
syscall
.
Getxattr
(
n
.
path
(),
attr
,
dest
)
sz
,
err
:=
syscall
.
Getxattr
(
n
.
path
(),
attr
,
dest
)
return
uint32
(
sz
),
ToErrno
(
err
)
return
uint32
(
sz
),
ToErrno
(
err
)
}
}
func
(
n
*
loopbackNode
)
Set
XA
ttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
syscall
.
Errno
{
func
(
n
*
loopbackNode
)
Set
xa
ttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
syscall
.
Errno
{
err
:=
syscall
.
Setxattr
(
n
.
path
(),
attr
,
data
,
int
(
flags
))
err
:=
syscall
.
Setxattr
(
n
.
path
(),
attr
,
data
,
int
(
flags
))
return
ToErrno
(
err
)
return
ToErrno
(
err
)
}
}
func
(
n
*
loopbackNode
)
Remove
XA
ttr
(
ctx
context
.
Context
,
attr
string
)
syscall
.
Errno
{
func
(
n
*
loopbackNode
)
Remove
xa
ttr
(
ctx
context
.
Context
,
attr
string
)
syscall
.
Errno
{
err
:=
syscall
.
Removexattr
(
n
.
path
(),
attr
)
err
:=
syscall
.
Removexattr
(
n
.
path
(),
attr
)
return
ToErrno
(
err
)
return
ToErrno
(
err
)
}
}
func
(
n
*
loopbackNode
)
List
XA
ttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
{
func
(
n
*
loopbackNode
)
List
xa
ttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
syscall
.
Errno
)
{
sz
,
err
:=
syscall
.
Listxattr
(
n
.
path
(),
dest
)
sz
,
err
:=
syscall
.
Listxattr
(
n
.
path
(),
dest
)
return
uint32
(
sz
),
ToErrno
(
err
)
return
uint32
(
sz
),
ToErrno
(
err
)
}
}
...
...
nodefs/simple_test.go
View file @
e6ec0065
...
@@ -142,7 +142,7 @@ func TestFileBasic(t *testing.T) {
...
@@ -142,7 +142,7 @@ func TestFileBasic(t *testing.T) {
if
got
,
err
:=
ioutil
.
ReadFile
(
fn
);
err
!=
nil
{
if
got
,
err
:=
ioutil
.
ReadFile
(
fn
);
err
!=
nil
{
t
.
Fatalf
(
"ReadFile: %v"
,
err
)
t
.
Fatalf
(
"ReadFile: %v"
,
err
)
}
else
if
bytes
.
Compare
(
got
,
content
)
!=
0
{
}
else
if
bytes
.
Compare
(
got
,
content
)
!=
0
{
t
.
Errorf
(
"got %q, want %q"
,
got
,
content
)
t
.
Errorf
(
"
ReadFile:
got %q, want %q"
,
got
,
content
)
}
}
f
,
err
:=
os
.
Open
(
fn
)
f
,
err
:=
os
.
Open
(
fn
)
...
...
nodefs/zip_test.go
View file @
e6ec0065
...
@@ -115,9 +115,9 @@ type zipFile struct {
...
@@ -115,9 +115,9 @@ type zipFile struct {
var
_
=
(
FileOperations
)((
*
zipFile
)(
nil
))
var
_
=
(
FileOperations
)((
*
zipFile
)(
nil
))
// Get
A
ttr sets the minimum, which is the size. A more full-featured
// Get
a
ttr sets the minimum, which is the size. A more full-featured
// FS would also set timestamps and permissions.
// FS would also set timestamps and permissions.
func
(
zf
*
zipFile
)
Get
A
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
func
(
zf
*
zipFile
)
Get
a
ttr
(
ctx
context
.
Context
,
out
*
fuse
.
AttrOut
)
syscall
.
Errno
{
out
.
Size
=
zf
.
file
.
UncompressedSize64
out
.
Size
=
zf
.
file
.
UncompressedSize64
return
OK
return
OK
}
}
...
...
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