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
9ab6ad5b
Commit
9ab6ad5b
authored
Dec 29, 2010
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not run loop in go-routine, but let caller decide.
parent
2dff88ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
example/main.go
example/main.go
+2
-2
examplelib/passthrough_test.go
examplelib/passthrough_test.go
+4
-1
fuse/fuse.go
fuse/fuse.go
+14
-9
No files found.
example/main.go
View file @
9ab6ad5b
...
@@ -26,9 +26,9 @@ func main() {
...
@@ -26,9 +26,9 @@ func main() {
state
.
Debug
=
*
debug
state
.
Debug
=
*
debug
mountPoint
:=
flag
.
Arg
(
1
)
mountPoint
:=
flag
.
Arg
(
1
)
state
.
Mount
(
mountPoint
,
*
threaded
)
state
.
Mount
(
mountPoint
)
fmt
.
Printf
(
"Mounted %s on %s (threaded=%v, debug=%v)
\n
"
,
orig
,
mountPoint
,
*
threaded
,
*
debug
)
fmt
.
Printf
(
"Mounted %s on %s (threaded=%v, debug=%v)
\n
"
,
orig
,
mountPoint
,
*
threaded
,
*
debug
)
state
.
Loop
(
*
threaded
)
}
}
examplelib/passthrough_test.go
View file @
9ab6ad5b
...
@@ -72,12 +72,15 @@ func (self *testCase) Setup(t *testing.T) {
...
@@ -72,12 +72,15 @@ func (self *testCase) Setup(t *testing.T) {
fs
:=
fuse
.
NewPathFileSystemConnector
(
NewPassThroughFuse
(
self
.
origDir
))
fs
:=
fuse
.
NewPathFileSystemConnector
(
NewPassThroughFuse
(
self
.
origDir
))
self
.
state
=
fuse
.
NewMountState
(
fs
)
self
.
state
=
fuse
.
NewMountState
(
fs
)
self
.
state
.
Mount
(
self
.
mountPoint
,
false
)
self
.
state
.
Mount
(
self
.
mountPoint
)
//self.state.Debug = false
//self.state.Debug = false
self
.
state
.
Debug
=
true
self
.
state
.
Debug
=
true
fmt
.
Println
(
"Orig "
,
self
.
origDir
,
" mount "
,
self
.
mountPoint
)
fmt
.
Println
(
"Orig "
,
self
.
origDir
,
" mount "
,
self
.
mountPoint
)
// Unthreaded, but in background.
go
self
.
state
.
Loop
(
false
)
}
}
// Unmount and del.
// Unmount and del.
...
...
fuse/fuse.go
View file @
9ab6ad5b
...
@@ -99,15 +99,20 @@ func (self *MountState) UnregisterDir(handle uint64) {
...
@@ -99,15 +99,20 @@ func (self *MountState) UnregisterDir(handle uint64) {
// using channels.
// using channels.
//
//
// TODO - error handling should perhaps be user-serviceable.
// TODO - error handling should perhaps be user-serviceable.
func
(
self
*
MountState
)
Mount
(
mountPoint
string
,
threaded
bool
)
os
.
Error
{
func
(
self
*
MountState
)
Mount
(
mountPoint
string
)
os
.
Error
{
file
,
mp
,
err
:=
mount
(
mountPoint
)
file
,
mp
,
err
:=
mount
(
mountPoint
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
self
.
mountPoint
=
mp
self
.
mountPoint
=
mp
self
.
mountFile
=
file
self
.
mountFile
=
file
return
nil
}
// Normally, callers should run loop() and wait for FUSE to exit, but
// tests will want to run this in a goroutine.
func
(
self
*
MountState
)
Loop
(
threaded
bool
)
{
self
.
threaded
=
threaded
self
.
threaded
=
threaded
if
self
.
threaded
{
if
self
.
threaded
{
self
.
outputChannel
=
make
(
chan
[][]
byte
,
100
)
self
.
outputChannel
=
make
(
chan
[][]
byte
,
100
)
self
.
errorChannel
=
make
(
chan
os
.
Error
,
100
)
self
.
errorChannel
=
make
(
chan
os
.
Error
,
100
)
...
@@ -115,8 +120,12 @@ func (self *MountState) Mount(mountPoint string, threaded bool) os.Error {
...
@@ -115,8 +120,12 @@ func (self *MountState) Mount(mountPoint string, threaded bool) os.Error {
go
self
.
DefaultErrorHandler
()
go
self
.
DefaultErrorHandler
()
}
}
go
self
.
loop
()
self
.
loop
()
return
nil
if
self
.
threaded
{
close
(
self
.
outputChannel
)
close
(
self
.
errorChannel
)
}
}
}
func
(
self
*
MountState
)
Unmount
()
os
.
Error
{
func
(
self
*
MountState
)
Unmount
()
os
.
Error
{
...
@@ -130,7 +139,7 @@ func (self *MountState) Unmount() os.Error {
...
@@ -130,7 +139,7 @@ func (self *MountState) Unmount() os.Error {
func
(
self
*
MountState
)
DefaultErrorHandler
()
{
func
(
self
*
MountState
)
DefaultErrorHandler
()
{
for
err
:=
range
self
.
errorChannel
{
for
err
:=
range
self
.
errorChannel
{
if
err
==
os
.
EOF
{
if
err
==
os
.
EOF
||
err
==
nil
{
break
break
}
}
log
.
Println
(
"error: "
,
err
)
log
.
Println
(
"error: "
,
err
)
...
@@ -223,10 +232,6 @@ func (self *MountState) loop() {
...
@@ -223,10 +232,6 @@ func (self *MountState) loop() {
}
}
self
.
mountFile
.
Close
()
self
.
mountFile
.
Close
()
if
self
.
threaded
{
close
(
self
.
outputChannel
)
close
(
self
.
errorChannel
)
}
}
}
func
(
self
*
MountState
)
handle
(
in_data
[]
byte
)
{
func
(
self
*
MountState
)
handle
(
in_data
[]
byte
)
{
...
...
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