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
84e8a52b
Commit
84e8a52b
authored
Aug 14, 2010
by
Ivan Krasin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
managerClient.lookup with typed arguments is added. One hack is eliminated
parent
78f93fbf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
fuse/fuse.go
fuse/fuse.go
+18
-6
No files found.
fuse/fuse.go
View file @
84e8a52b
...
...
@@ -216,7 +216,7 @@ func readDir(h *InHeader, r io.Reader, c *managerClient) (data [][]byte, err os.
}
dirRespChan
:=
make
(
chan
*
dirResponse
,
1
)
fmt
.
Printf
(
"Sending dir request, in.Offset: %v
\n
"
,
in
.
Offset
)
resp
.
dirReq
<-
&
dirRequest
{
false
,
in
.
Offset
,
dirRespChan
}
resp
.
dirReq
<-
&
dirRequest
{
false
,
h
.
NodeId
,
in
.
Offset
,
dirRespChan
}
fmt
.
Printf
(
"receiving dir response
\n
"
)
dirResp
:=
<-
dirRespChan
fmt
.
Printf
(
"received %v
\n
"
,
dirResp
)
...
...
@@ -264,7 +264,7 @@ func readDir(h *InHeader, r io.Reader, c *managerClient) (data [][]byte, err os.
func
lookup
(
h
*
InHeader
,
r
*
bytes
.
Buffer
,
c
*
managerClient
)
(
data
[][]
byte
,
err
os
.
Error
)
{
filename
:=
string
(
r
.
Bytes
())
fmt
.
Printf
(
"filename: %s
\n
"
,
filename
)
resp
:=
c
.
makeManagerRequest
(
h
.
NodeId
,
0
,
lookupOp
,
filename
)
resp
:=
c
.
lookup
(
h
.
NodeId
,
filename
)
if
resp
.
err
!=
nil
{
return
serialize
(
h
,
EIO
,
nil
)
}
...
...
@@ -345,6 +345,7 @@ type dirEntry struct {
type
dirRequest
struct
{
isClose
bool
nodeId
uint64
offset
uint64
resp
chan
*
dirResponse
}
...
...
@@ -362,6 +363,7 @@ type dirHandle struct {
type
manager
struct
{
fs
FileSystem
client
*
managerClient
dirHandles
map
[
uint64
]
*
dirHandle
cnt
uint64
nodes
map
[
uint64
]
string
...
...
@@ -372,6 +374,7 @@ type manager struct {
func
startManager
(
fs
FileSystem
,
requests
chan
*
managerRequest
)
{
m
:=
new
(
manager
)
m
.
fs
=
fs
m
.
client
=
&
managerClient
{
requests
}
m
.
dirHandles
=
make
(
map
[
uint64
]
*
dirHandle
)
m
.
nodes
=
make
(
map
[
uint64
]
string
)
m
.
nodes
[
1
]
=
""
// Root
...
...
@@ -394,6 +397,10 @@ func (c *managerClient) makeManagerRequest(nodeId uint64, fh uint64, op FileOp,
return
}
func
(
c
*
managerClient
)
lookup
(
nodeId
uint64
,
filename
string
)
(
resp
*
managerResponse
)
{
return
c
.
makeManagerRequest
(
nodeId
,
0
,
lookupOp
,
filename
)
}
func
(
m
*
manager
)
run
(
requests
chan
*
managerRequest
)
{
var
resp
*
managerResponse
for
req
:=
range
requests
{
...
...
@@ -422,7 +429,7 @@ func (m *manager) openDir(req *managerRequest) (resp *managerResponse) {
h
.
nodeId
=
req
.
nodeId
h
.
req
=
make
(
chan
*
dirRequest
,
1
)
m
.
dirHandles
[
h
.
fh
]
=
h
go
readDirRoutine
(
h
.
req
)
go
readDirRoutine
(
m
.
client
,
h
.
req
)
resp
.
fh
=
h
.
fh
return
}
...
...
@@ -481,7 +488,7 @@ func (m *manager) lookup(req *managerRequest) (resp *managerResponse) {
return
}
func
readDirRoutine
(
requests
chan
*
dirRequest
)
{
func
readDirRoutine
(
c
*
managerClient
,
requests
chan
*
dirRequest
)
{
defer
close
(
requests
)
dirs
:=
[]
string
{
"lala111"
,
"bb"
,
"ddddd"
}
i
:=
uint64
(
0
)
...
...
@@ -495,9 +502,14 @@ func readDirRoutine(requests chan *dirRequest) {
}
if
i
<
uint64
(
len
(
dirs
))
{
entry
:=
new
(
dirEntry
)
entry
.
nodeId
=
2
+
i
// hack. Almost always is incorrect
entry
.
mode
=
S_IFDIR
entry
.
name
=
dirs
[
i
]
lookupResp
:=
c
.
lookup
(
req
.
nodeId
,
entry
.
name
)
if
lookupResp
.
err
!=
nil
{
req
.
resp
<-
&
dirResponse
{
nil
,
lookupResp
.
err
}
return
}
entry
.
nodeId
=
lookupResp
.
nodeId
entry
.
mode
=
lookupResp
.
attr
.
Mode
req
.
resp
<-
&
dirResponse
{[]
*
dirEntry
{
entry
},
nil
}
i
++
}
else
{
...
...
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