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
09e0ba87
Commit
09e0ba87
authored
Mar 07, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: code -> status.
parent
bea6a031
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
140 additions
and
132 deletions
+140
-132
nodefs/api.go
nodefs/api.go
+15
-15
nodefs/bridge.go
nodefs/bridge.go
+87
-87
nodefs/default.go
nodefs/default.go
+15
-15
nodefs/files.go
nodefs/files.go
+7
-7
nodefs/inode.go
nodefs/inode.go
+1
-1
nodefs/loopback.go
nodefs/loopback.go
+4
-4
nodefs/simple_test.go
nodefs/simple_test.go
+11
-3
No files found.
nodefs/api.go
View file @
09e0ba87
...
...
@@ -101,9 +101,9 @@ type Operations interface {
setInode
(
*
Inode
)
bool
// File locking
GetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
SetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
SetLkw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
GetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
SetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
SetLkw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
// The methods below may be called on closed files, due to
// concurrency. In that case, you should return EBADF.
...
...
@@ -120,11 +120,11 @@ type Operations interface {
Rmdir
(
ctx
context
.
Context
,
name
string
)
fuse
.
Status
Unlink
(
ctx
context
.
Context
,
name
string
)
fuse
.
Status
Rename
(
ctx
context
.
Context
,
name
string
,
newParent
Operations
,
newName
string
,
flags
uint32
)
fuse
.
Status
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
node
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
code
fuse
.
Status
)
Link
(
ctx
context
.
Context
,
target
Operations
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
code
fuse
.
Status
)
Symlink
(
ctx
context
.
Context
,
target
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
code
fuse
.
Status
)
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
node
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
Link
(
ctx
context
.
Context
,
target
Operations
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
Symlink
(
ctx
context
.
Context
,
target
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
Readlink
(
ctx
context
.
Context
)
(
string
,
fuse
.
Status
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
code
fuse
.
Status
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
// OpenDir is called for sanity/permission checks on opening a
// directory.
...
...
@@ -135,9 +135,9 @@ type Operations interface {
Read
(
ctx
context
.
Context
,
f
FileHandle
,
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
Write
(
ctx
context
.
Context
,
f
FileHandle
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
code
fuse
.
Status
)
Write
(
ctx
context
.
Context
,
f
FileHandle
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
Fsync
(
ctx
context
.
Context
,
f
FileHandle
,
flags
uint32
)
(
code
fuse
.
Status
)
Fsync
(
ctx
context
.
Context
,
f
FileHandle
,
flags
uint32
)
(
status
fuse
.
Status
)
// Flush is called for close() call on a file descriptor. In
// case of duplicated descriptor, it may be called more than
...
...
@@ -161,17 +161,17 @@ type Operations interface {
Chown
(
ctx
context
.
Context
,
f
FileHandle
,
uid
uint32
,
gid
uint32
)
fuse
.
Status
Chmod
(
ctx
context
.
Context
,
f
FileHandle
,
perms
uint32
)
fuse
.
Status
Utimens
(
ctx
context
.
Context
,
f
FileHandle
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
fuse
.
Status
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
}
type
FileHandle
interface
{
Read
(
ctx
context
.
Context
,
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
code
fuse
.
Status
)
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
// File locking
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
// Flush is called for close() call on a file descriptor. In
// case of duplicated descriptor, it may be called more than
...
...
@@ -194,7 +194,7 @@ type FileHandle interface {
Chown
(
ctx
context
.
Context
,
uid
uint32
,
gid
uint32
)
fuse
.
Status
Chmod
(
ctx
context
.
Context
,
perms
uint32
)
fuse
.
Status
Utimens
(
ctx
context
.
Context
,
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
fuse
.
Status
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
}
type
Options
struct
{
...
...
nodefs/bridge.go
View file @
09e0ba87
This diff is collapsed.
Click to expand it.
nodefs/default.go
View file @
09e0ba87
...
...
@@ -88,7 +88,7 @@ func (n *DefaultOperations) Read(ctx context.Context, f FileHandle, dest []byte,
return
nil
,
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
Symlink
(
ctx
context
.
Context
,
target
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Symlink
(
ctx
context
.
Context
,
target
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
{
log
.
Println
(
"defsyml"
)
return
nil
,
fuse
.
ENOSYS
}
...
...
@@ -104,7 +104,7 @@ func (n *DefaultOperations) Fsync(ctx context.Context, f FileHandle, flags uint3
return
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
Write
(
ctx
context
.
Context
,
f
FileHandle
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Write
(
ctx
context
.
Context
,
f
FileHandle
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
{
if
f
!=
nil
{
return
f
.
Write
(
ctx
,
data
,
off
)
}
...
...
@@ -112,7 +112,7 @@ func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte
return
0
,
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
GetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
GetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
{
if
f
!=
nil
{
return
f
.
GetLk
(
ctx
,
owner
,
lk
,
flags
,
out
)
}
...
...
@@ -120,7 +120,7 @@ func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint6
return
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
SetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
SetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
if
f
!=
nil
{
return
f
.
SetLk
(
ctx
,
owner
,
lk
,
flags
)
}
...
...
@@ -128,7 +128,7 @@ func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint6
return
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
SetLkw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
SetLkw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
if
f
!=
nil
{
return
f
.
SetLkw
(
ctx
,
owner
,
lk
,
flags
)
}
...
...
@@ -149,7 +149,7 @@ func (n *DefaultOperations) Release(ctx context.Context, f FileHandle) {
}
}
func
(
n
*
DefaultOperations
)
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Allocate
(
ctx
context
.
Context
,
f
FileHandle
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
{
if
f
!=
nil
{
return
f
.
Allocate
(
ctx
,
off
,
size
,
mode
)
}
...
...
@@ -197,14 +197,14 @@ func (n *DefaultOperations) Utimens(ctx context.Context, f FileHandle, atime *ti
return
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
return
nil
,
0
,
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
node
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
node
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
return
nil
,
nil
,
0
,
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
Link
(
ctx
context
.
Context
,
target
Operations
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
code
fuse
.
Status
)
{
func
(
n
*
DefaultOperations
)
Link
(
ctx
context
.
Context
,
target
Operations
,
name
string
,
out
*
fuse
.
EntryOut
)
(
node
*
Inode
,
status
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
...
...
@@ -217,19 +217,19 @@ func (f *DefaultFile) Read(ctx context.Context, dest []byte, off int64) (fuse.Re
return
nil
,
fuse
.
ENOSYS
}
func
(
f
*
DefaultFile
)
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
code
fuse
.
Status
)
{
func
(
f
*
DefaultFile
)
Write
(
ctx
context
.
Context
,
data
[]
byte
,
off
int64
)
(
written
uint32
,
status
fuse
.
Status
)
{
return
0
,
fuse
.
ENOSYS
}
func
(
f
*
DefaultFile
)
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
{
func
(
f
*
DefaultFile
)
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
f
*
DefaultFile
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
DefaultFile
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
f
*
DefaultFile
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
DefaultFile
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
...
...
@@ -262,10 +262,10 @@ func (f *DefaultFile) Utimens(ctx context.Context, atime *time.Time, mtime *time
return
fuse
.
ENOSYS
}
func
(
f
*
DefaultFile
)
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
DefaultFile
)
Allocate
(
ctx
context
.
Context
,
off
uint64
,
size
uint64
,
mode
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
f
*
DefaultFile
)
Fsync
(
ctx
context
.
Context
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
DefaultFile
)
Fsync
(
ctx
context
.
Context
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
nodefs/files.go
View file @
09e0ba87
...
...
@@ -30,7 +30,7 @@ type loopbackFile struct {
mu
sync
.
Mutex
}
func
(
f
*
loopbackFile
)
Read
(
ctx
context
.
Context
,
buf
[]
byte
,
off
int64
)
(
res
fuse
.
ReadResult
,
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
Read
(
ctx
context
.
Context
,
buf
[]
byte
,
off
int64
)
(
res
fuse
.
ReadResult
,
status
fuse
.
Status
)
{
f
.
mu
.
Lock
()
// This is not racy by virtue of the kernel properly
// synchronizing the open/write/close.
...
...
@@ -68,7 +68,7 @@ func (f *loopbackFile) Flush(ctx context.Context) fuse.Status {
return
fuse
.
ToStatus
(
err
)
}
func
(
f
*
loopbackFile
)
Fsync
(
ctx
context
.
Context
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
Fsync
(
ctx
context
.
Context
,
flags
uint32
)
(
status
fuse
.
Status
)
{
f
.
mu
.
Lock
()
r
:=
fuse
.
ToStatus
(
syscall
.
Fsync
(
int
(
f
.
File
.
Fd
())))
f
.
mu
.
Unlock
()
...
...
@@ -82,23 +82,23 @@ const (
_OFD_SETLKW
=
38
)
func
(
f
*
loopbackFile
)
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
GetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
status
fuse
.
Status
)
{
flk
:=
syscall
.
Flock_t
{}
lk
.
ToFlockT
(
&
flk
)
code
=
fuse
.
ToStatus
(
syscall
.
FcntlFlock
(
f
.
File
.
Fd
(),
_OFD_GETLK
,
&
flk
))
status
=
fuse
.
ToStatus
(
syscall
.
FcntlFlock
(
f
.
File
.
Fd
(),
_OFD_GETLK
,
&
flk
))
out
.
FromFlockT
(
&
flk
)
return
}
func
(
f
*
loopbackFile
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
SetLk
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
f
.
setLock
(
ctx
,
owner
,
lk
,
flags
,
false
)
}
func
(
f
*
loopbackFile
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
SetLkw
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
{
return
f
.
setLock
(
ctx
,
owner
,
lk
,
flags
,
true
)
}
func
(
f
*
loopbackFile
)
setLock
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
blocking
bool
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
setLock
(
ctx
context
.
Context
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
blocking
bool
)
(
status
fuse
.
Status
)
{
if
(
flags
&
fuse
.
FUSE_LK_FLOCK
)
!=
0
{
var
op
int
switch
lk
.
Typ
{
...
...
nodefs/inode.go
View file @
09e0ba87
...
...
@@ -542,6 +542,6 @@ func (n *Inode) WriteCache(offset int64, data []byte) fuse.Status {
}
func
(
n
*
Inode
)
ReadCache
(
offset
int64
,
dest
[]
byte
)
(
count
int
,
code
fuse
.
Status
)
{
func
(
n
*
Inode
)
ReadCache
(
offset
int64
,
dest
[]
byte
)
(
count
int
,
status
fuse
.
Status
)
{
return
n
.
bridge
.
server
.
InodeRetrieveCache
(
n
.
nodeID
.
Ino
,
offset
,
dest
)
}
nodefs/loopback.go
View file @
09e0ba87
...
...
@@ -165,7 +165,7 @@ func idFromStat(st *syscall.Stat_t) FileID {
}
}
func
(
n
*
loopbackNode
)
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
inode
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
code
fuse
.
Status
)
{
func
(
n
*
loopbackNode
)
Create
(
ctx
context
.
Context
,
name
string
,
flags
uint32
,
mode
uint32
)
(
inode
*
Inode
,
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
p
:=
filepath
.
Join
(
n
.
path
(),
name
)
f
,
err
:=
os
.
OpenFile
(
p
,
int
(
flags
)
|
os
.
O_CREATE
,
os
.
FileMode
(
mode
))
...
...
@@ -242,7 +242,7 @@ func (n *loopbackNode) Readlink(ctx context.Context) (string, fuse.Status) {
}
}
func
(
n
*
loopbackNode
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
code
fuse
.
Status
)
{
func
(
n
*
loopbackNode
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
status
fuse
.
Status
)
{
p
:=
n
.
path
()
f
,
err
:=
os
.
OpenFile
(
p
,
int
(
flags
),
0
)
if
err
!=
nil
{
...
...
@@ -285,8 +285,8 @@ func (n *loopbackNode) GetAttr(ctx context.Context, f FileHandle, out *fuse.Attr
return
f
.
GetAttr
(
ctx
,
out
)
}
if
code
,
ok
:=
n
.
fGetAttr
(
ctx
,
out
);
ok
{
return
code
if
status
,
ok
:=
n
.
fGetAttr
(
ctx
,
out
);
ok
{
return
status
}
p
:=
n
.
path
()
...
...
nodefs/simple_test.go
View file @
09e0ba87
...
...
@@ -500,6 +500,14 @@ func TestReadDir(t *testing.T) {
tc
:=
newTestCase
(
t
)
defer
tc
.
Clean
()
f
,
err
:=
os
.
Open
(
tc
.
mntDir
)
if
err
!=
nil
{
t
.
Fatalf
(
"Open: %v"
,
err
)
}
defer
f
.
Close
()
// add entries after opening the directory
// XXX what about ".." and "." ?
want
:=
map
[
string
]
bool
{}
for
i
:=
0
;
i
<
110
;
i
++
{
...
...
@@ -512,13 +520,13 @@ func TestReadDir(t *testing.T) {
}
}
entries
,
err
:=
ioutil
.
ReadDir
(
tc
.
mntDir
)
names
,
err
:=
f
.
Readdirnames
(
-
1
)
if
err
!=
nil
{
t
.
Fatalf
(
"ReadDir: %v"
,
err
)
}
got
:=
map
[
string
]
bool
{}
for
_
,
e
:=
range
entri
es
{
got
[
e
.
Name
()
]
=
true
for
_
,
e
:=
range
nam
es
{
got
[
e
]
=
true
}
if
len
(
got
)
!=
len
(
want
)
{
t
.
Errorf
(
"got %d entries, want %d"
,
len
(
got
),
len
(
want
))
...
...
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