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
376d1aa1
Commit
376d1aa1
authored
Aug 11, 2010
by
Ivan Krasin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added fuse.Mount
parent
3f53f564
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
fuse/Makefile
fuse/Makefile
+1
-0
fuse/fuse.go
fuse/fuse.go
+73
-0
No files found.
fuse/Makefile
View file @
376d1aa1
...
...
@@ -4,6 +4,7 @@ include $(GOROOT)/src/Make.$(GOARCH)
TARG
=
github.com/krasin/go-fuse-zip/fuse
GOFILES
=
\
fuse.go
\
types.go
\
include
$(GOROOT)/src/Make.pkg
...
...
fuse/fuse.go
0 → 100644
View file @
376d1aa1
package
fuse
// Written with a look to http://ptspts.blogspot.com/2009/11/fuse-protocol-tutorial-for-linux-26.html
import
(
"fmt"
"net"
"os"
"path"
)
type
FileSystem
interface
{
}
type
MountPoint
struct
{
mountPoint
string
}
// Mount create a fuse fs on the specified mount point.
func
Mount
(
mountPoint
string
,
fs
FileSystem
)
(
m
*
MountPoint
,
err
os
.
Error
)
{
local
,
remote
,
err
:=
net
.
Socketpair
(
"unixgram"
)
if
err
!=
nil
{
return
}
defer
local
.
Close
()
defer
remote
.
Close
()
mountPoint
=
path
.
Clean
(
mountPoint
)
if
!
path
.
Rooted
(
mountPoint
)
{
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
return
}
mountPoint
=
path
.
Clean
(
path
.
Join
(
cwd
,
mountPoint
))
}
pid
,
err
:=
os
.
ForkExec
(
"/bin/fusermount"
,
[]
string
{
"/bin/fusermount"
,
mountPoint
},
[]
string
{
"_FUSE_COMMFD=3"
},
""
,
[]
*
os
.
File
{
nil
,
nil
,
os
.
Stderr
,
remote
.
File
()
})
if
err
!=
nil
{
return
}
w
,
err
:=
os
.
Wait
(
pid
,
0
)
if
err
!=
nil
{
return
}
if
w
.
ExitStatus
()
!=
0
{
return
nil
,
os
.
NewError
(
fmt
.
Sprintf
(
"fusermount exited with code %d
\n
"
,
w
.
ExitStatus
()))
}
m
=
&
MountPoint
{
mountPoint
}
return
}
func
(
m
*
MountPoint
)
Unmount
()
(
err
os
.
Error
)
{
pid
,
err
:=
os
.
ForkExec
(
"/bin/fusermount"
,
[]
string
{
"/bin/fusermount"
,
"-u"
,
"m"
,
m
.
mountPoint
},
nil
,
""
,
[]
*
os
.
File
{
nil
,
nil
,
os
.
Stderr
})
if
err
!=
nil
{
return
}
w
,
err
:=
os
.
Wait
(
pid
,
0
)
if
err
!=
nil
{
return
}
if
w
.
ExitStatus
()
!=
0
{
return
os
.
NewError
(
fmt
.
Sprintf
(
"fusermount exited with code %d
\n
"
,
w
.
ExitStatus
()))
}
return
}
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