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
Levin Zimmermann
go-fuse
Commits
928afa1c
Commit
928afa1c
authored
Apr 04, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: use offset for MemRegularFile reads. Test it.
parent
d1deed27
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
nodefs/mem.go
nodefs/mem.go
+1
-1
nodefs/mem_test.go
nodefs/mem_test.go
+35
-0
No files found.
nodefs/mem.go
View file @
928afa1c
...
@@ -47,7 +47,7 @@ func (f *MemRegularFile) Read(ctx context.Context, fh FileHandle, dest []byte, o
...
@@ -47,7 +47,7 @@ func (f *MemRegularFile) Read(ctx context.Context, fh FileHandle, dest []byte, o
if
end
>
len
(
f
.
Data
)
{
if
end
>
len
(
f
.
Data
)
{
end
=
len
(
f
.
Data
)
end
=
len
(
f
.
Data
)
}
}
return
fuse
.
ReadResultData
(
f
.
Data
[
:
end
]),
OK
return
fuse
.
ReadResultData
(
f
.
Data
[
off
:
end
]),
OK
}
}
// MemSymlink is an inode holding a symlink in memory.
// MemSymlink is an inode holding a symlink in memory.
...
...
nodefs/mem_test.go
View file @
928afa1c
...
@@ -5,7 +5,10 @@
...
@@ -5,7 +5,10 @@
package
nodefs
package
nodefs
import
(
import
(
"bytes"
"context"
"context"
"io/ioutil"
"math/rand"
"os"
"os"
"syscall"
"syscall"
"testing"
"testing"
...
@@ -86,6 +89,38 @@ func TestDataFile(t *testing.T) {
...
@@ -86,6 +89,38 @@ func TestDataFile(t *testing.T) {
}
}
}
}
func
TestDataFileLargeRead
(
t
*
testing
.
T
)
{
root
:=
&
Inode
{}
data
:=
make
([]
byte
,
256
*
1024
)
rand
.
Read
(
data
[
:
])
mntDir
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
FirstAutomaticIno
:
1
,
OnAdd
:
func
(
ctx
context
.
Context
)
{
n
:=
root
.
EmbeddedInode
()
ch
:=
n
.
NewPersistentInode
(
ctx
,
&
MemRegularFile
{
Data
:
data
,
Attr
:
fuse
.
Attr
{
Mode
:
0464
,
},
},
NodeAttr
{})
n
.
AddChild
(
"file"
,
ch
,
false
)
},
})
defer
clean
()
got
,
err
:=
ioutil
.
ReadFile
(
mntDir
+
"/file"
)
if
err
!=
nil
{
t
.
Fatalf
(
"ReadFile: %v"
,
err
)
}
if
!
bytes
.
Equal
(
got
,
data
)
{
t
.
Errorf
(
"roundtrip read had change"
)
}
}
type
SymlinkerRoot
struct
{
type
SymlinkerRoot
struct
{
Inode
Inode
}
}
...
...
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