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
54857599
Commit
54857599
authored
Aug 16, 2010
by
Ivan Krasin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
File.Read -> File.ReadAt is now compatible with io.ReaderAt
parent
5e8fa0ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
fuse/fuse.go
fuse/fuse.go
+9
-7
fuse/fuse_test.go
fuse/fuse_test.go
+8
-3
No files found.
fuse/fuse.go
View file @
54857599
...
...
@@ -14,7 +14,7 @@ const (
)
type
File
interface
{
Read
(
offset
uint64
)
(
data
[]
byte
,
status
Status
)
Read
At
(
p
[]
byte
,
off
int64
)
(
n
int
,
err
os
.
Error
)
Close
()
(
status
Status
)
}
...
...
@@ -289,7 +289,7 @@ func read(fs FileSystem, h *InHeader, ing interface{}, c *managerClient) (interf
}
fileRespChan
:=
make
(
chan
*
fileResponse
,
1
)
fmt
.
Printf
(
"Sending file request, in.Offset: %v
\n
"
,
in
.
Offset
)
resp
.
fileReq
<-
&
fileRequest
{
h
.
NodeId
,
in
.
Offset
,
fileRespChan
}
resp
.
fileReq
<-
&
fileRequest
{
h
.
NodeId
,
in
.
Offset
,
in
.
Size
,
fileRespChan
}
fmt
.
Printf
(
"receiving file response
\n
"
)
fileResp
:=
<-
fileRespChan
fmt
.
Printf
(
"received %v
\n
"
,
fileResp
)
...
...
@@ -412,6 +412,7 @@ type dirHandle struct {
type
fileRequest
struct
{
nodeId
uint64
offset
uint64
size
uint32
resp
chan
*
fileResponse
}
...
...
@@ -695,11 +696,12 @@ func readFileRoutine(fs FileSystem, c *managerClient, h *fileHandle) {
defer
close
(
h
.
req
)
offset
:=
uint64
(
0
)
for
req
:=
range
h
.
req
{
if
req
.
offset
!=
offset
{
req
.
resp
<-
&
fileResponse
{
nil
,
OK
}
data
:=
make
([]
byte
,
req
.
size
)
n
,
err
:=
h
.
file
.
ReadAt
(
data
,
int64
(
offset
))
if
err
!=
nil
{
req
.
resp
<-
&
fileResponse
{
nil
,
EIO
}
continue
}
data
,
status
:=
h
.
file
.
Read
(
offset
)
req
.
resp
<-
&
fileResponse
{
data
,
status
}
offset
+=
uint64
(
len
(
data
))
req
.
resp
<-
&
fileResponse
{
data
[
0
:
n
],
OK
}
}
}
fuse/fuse_test.go
View file @
54857599
...
...
@@ -41,11 +41,16 @@ func (fs *testFuse) Open(path string) (file File, code Status) {
type
testFile
struct
{}
func
(
f
*
testFile
)
Read
(
offset
uint64
)
(
data
[]
byte
,
code
Status
)
{
func
(
f
*
testFile
)
Read
At
(
data
[]
byte
,
offset
int64
)
(
n
int
,
err
os
.
Error
)
{
if
offset
<
13
{
return
[]
byte
(
"Hello world!
\n
"
[
offset
:
]),
OK
our
:=
[]
byte
(
"Hello world!
\n
"
)[
offset
:
]
for
i
,
b
:=
range
our
{
data
[
i
]
=
b
}
n
=
len
(
our
)
return
}
return
nil
,
OK
return
0
,
os
.
EOF
}
func
(
f
*
testFile
)
Close
()
(
status
Status
)
{
...
...
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