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
f5e4c658
Commit
f5e4c658
authored
Apr 01, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: add MemRegularFile.Flush
parent
9723c2be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
nodefs/bridge.go
nodefs/bridge.go
+1
-0
nodefs/mem.go
nodefs/mem.go
+5
-0
nodefs/mem_test.go
nodefs/mem_test.go
+15
-4
No files found.
nodefs/bridge.go
View file @
f5e4c658
...
...
@@ -728,6 +728,7 @@ func (b *rawBridge) Flush(cancel <-chan struct{}, input *fuse.FlushIn) fuse.Stat
if
fl
,
ok
:=
f
.
file
.
(
FileFlusher
);
ok
{
return
errnoToStatus
(
fl
.
Flush
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}))
}
// XXX should return OK to reflect r/o filesystem?
return
fuse
.
ENOTSUP
}
...
...
nodefs/mem.go
View file @
f5e4c658
...
...
@@ -22,6 +22,7 @@ type MemRegularFile struct {
var
_
=
(
Opener
)((
*
MemRegularFile
)(
nil
))
var
_
=
(
Getattrer
)((
*
MemRegularFile
)(
nil
))
var
_
=
(
Reader
)((
*
MemRegularFile
)(
nil
))
var
_
=
(
Flusher
)((
*
MemRegularFile
)(
nil
))
func
(
f
*
MemRegularFile
)
Open
(
ctx
context
.
Context
,
flags
uint32
)
(
fh
FileHandle
,
fuseFlags
uint32
,
errno
syscall
.
Errno
)
{
if
flags
&
(
syscall
.
O_RDWR
)
!=
0
||
flags
&
syscall
.
O_WRONLY
!=
0
{
...
...
@@ -38,6 +39,10 @@ func (f *MemRegularFile) Getattr(ctx context.Context, fh FileHandle, out *fuse.A
return
OK
}
func
(
f
*
MemRegularFile
)
Flush
(
ctx
context
.
Context
,
fh
FileHandle
)
syscall
.
Errno
{
return
0
}
func
(
f
*
MemRegularFile
)
Read
(
ctx
context
.
Context
,
fh
FileHandle
,
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
syscall
.
Errno
)
{
end
:=
int
(
off
)
+
len
(
dest
)
if
end
>
len
(
f
.
Data
)
{
...
...
nodefs/mem_test.go
View file @
f5e4c658
...
...
@@ -6,7 +6,6 @@ package nodefs
import
(
"context"
"io/ioutil"
"os"
"syscall"
"testing"
...
...
@@ -54,11 +53,23 @@ func TestDataFile(t *testing.T) {
})
defer
clean
()
c
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/file"
)
fd
,
err
:=
syscall
.
Open
(
mntDir
+
"/file"
,
syscall
.
O_RDONLY
,
0
)
if
err
!=
nil
{
t
.
Fatalf
(
"
ReadFile
: %v"
,
err
)
t
.
Fatalf
(
"
Open
: %v"
,
err
)
}
if
got
:=
string
(
c
);
got
!=
want
{
var
buf
[
1024
]
byte
n
,
err
:=
syscall
.
Read
(
fd
,
buf
[
:
])
if
err
!=
nil
{
t
.
Errorf
(
"Read: %v"
,
err
)
}
if
err
:=
syscall
.
Close
(
fd
);
err
!=
nil
{
t
.
Errorf
(
"Close: %v"
,
err
)
}
got
:=
string
(
buf
[
:
n
])
if
got
!=
want
{
t
.
Errorf
(
"got %q want %q"
,
got
,
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