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
55f8d0c5
Commit
55f8d0c5
authored
Mar 07, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: fsyncdir, statfs.
parent
6a644588
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
2 deletions
+49
-2
nodefs/api.go
nodefs/api.go
+2
-0
nodefs/bridge.go
nodefs/bridge.go
+4
-2
nodefs/default.go
nodefs/default.go
+7
-0
nodefs/loopback.go
nodefs/loopback.go
+10
-0
nodefs/simple_test.go
nodefs/simple_test.go
+26
-0
No files found.
nodefs/api.go
View file @
55f8d0c5
...
...
@@ -100,6 +100,8 @@ type Operations interface {
inode
()
*
Inode
setInode
(
*
Inode
)
bool
StatFs
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
fuse
.
Status
// File locking
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
)
...
...
nodefs/bridge.go
View file @
55f8d0c5
...
...
@@ -638,11 +638,13 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse
}
func
(
b
*
rawBridge
)
FsyncDir
(
input
*
fuse
.
FsyncIn
)
(
status
fuse
.
Status
)
{
return
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
input
.
Fh
)
return
n
.
node
.
Fsync
(
context
.
TODO
(),
nil
,
input
.
FsyncFlags
)
}
func
(
b
*
rawBridge
)
StatFs
(
input
*
fuse
.
InHeader
,
out
*
fuse
.
StatfsOut
)
(
status
fuse
.
Status
)
{
return
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
return
n
.
node
.
StatFs
(
context
.
TODO
(),
out
)
}
func
(
b
*
rawBridge
)
Init
(
s
*
fuse
.
Server
)
{
...
...
nodefs/default.go
View file @
55f8d0c5
...
...
@@ -47,6 +47,12 @@ func (dn *DefaultOperations) setInode(inode *Inode) bool {
nil
,
unsafe
.
Pointer
(
inode
))
}
func
(
dn
*
DefaultOperations
)
StatFs
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
fuse
.
Status
{
// this should be defined on OSX, or the FS won't mount
*
out
=
fuse
.
StatfsOut
{}
return
fuse
.
OK
}
func
(
dn
*
DefaultOperations
)
inode
()
*
Inode
{
return
(
*
Inode
)(
atomic
.
LoadPointer
(
(
*
unsafe
.
Pointer
)(
unsafe
.
Pointer
(
&
dn
.
inode_
))))
...
...
@@ -59,6 +65,7 @@ func (n *DefaultOperations) Lookup(ctx context.Context, name string, out *fuse.E
func
(
n
*
DefaultOperations
)
Mkdir
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
Mknod
(
ctx
context
.
Context
,
name
string
,
mode
uint32
,
dev
uint32
,
out
*
fuse
.
EntryOut
)
(
*
Inode
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
...
...
nodefs/loopback.go
View file @
55f8d0c5
...
...
@@ -30,6 +30,16 @@ func (n *loopbackRoot) newLoopbackNode() *loopbackNode {
}
}
func
(
n
*
loopbackNode
)
StatFs
(
ctx
context
.
Context
,
out
*
fuse
.
StatfsOut
)
fuse
.
Status
{
s
:=
syscall
.
Statfs_t
{}
err
:=
syscall
.
Statfs
(
n
.
path
(),
&
s
)
if
err
!=
nil
{
return
fuse
.
ToStatus
(
err
)
}
out
.
FromStatfsT
(
&
s
)
return
fuse
.
OK
}
func
(
n
*
loopbackRoot
)
GetAttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
{
var
err
error
=
nil
st
:=
syscall
.
Stat_t
{}
...
...
nodefs/simple_test.go
View file @
55f8d0c5
...
...
@@ -537,3 +537,29 @@ func TestReadDir(t *testing.T) {
}
}
}
// This test is racy. If an external process consumes space while this
// runs, we may see spurious differences between the two statfs() calls.
func
TestStatFs
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
)
defer
tc
.
Clean
()
empty
:=
syscall
.
Statfs_t
{}
orig
:=
empty
if
err
:=
syscall
.
Statfs
(
tc
.
origDir
,
&
orig
);
err
!=
nil
{
t
.
Fatal
(
"statfs orig"
,
err
)
}
mnt
:=
syscall
.
Statfs_t
{}
if
err
:=
syscall
.
Statfs
(
tc
.
mntDir
,
&
mnt
);
err
!=
nil
{
t
.
Fatal
(
"statfs mnt"
,
err
)
}
var
mntFuse
,
origFuse
fuse
.
StatfsOut
mntFuse
.
FromStatfsT
(
&
mnt
)
origFuse
.
FromStatfsT
(
&
orig
)
if
!
reflect
.
DeepEqual
(
mntFuse
,
origFuse
)
{
t
.
Errorf
(
"Got %#v, want %#v"
,
mntFuse
,
origFuse
)
}
}
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