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
afbcb85e
Commit
afbcb85e
authored
Apr 01, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example/loopback: use new nodefs library
parent
b14c4e22
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
27 deletions
+13
-27
example/loopback/main.go
example/loopback/main.go
+13
-27
No files found.
example/loopback/main.go
View file @
afbcb85e
...
@@ -14,14 +14,11 @@ import (
...
@@ -14,14 +14,11 @@ import (
"os"
"os"
"os/signal"
"os/signal"
"path"
"path"
"path/filepath"
"runtime/pprof"
"runtime/pprof"
"syscall"
"syscall"
"time"
"time"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/pathfs"
)
)
func
writeMemProfile
(
fn
string
,
sigs
<-
chan
os
.
Signal
)
{
func
writeMemProfile
(
fn
string
,
sigs
<-
chan
os
.
Signal
)
{
...
@@ -48,7 +45,6 @@ func main() {
...
@@ -48,7 +45,6 @@ func main() {
// Scans the arg list and sets up flags
// Scans the arg list and sets up flags
debug
:=
flag
.
Bool
(
"debug"
,
false
,
"print debugging messages."
)
debug
:=
flag
.
Bool
(
"debug"
,
false
,
"print debugging messages."
)
other
:=
flag
.
Bool
(
"allow-other"
,
false
,
"mount with -o allowother."
)
other
:=
flag
.
Bool
(
"allow-other"
,
false
,
"mount with -o allowother."
)
enableLinks
:=
flag
.
Bool
(
"l"
,
false
,
"Enable hard link support"
)
cpuprofile
:=
flag
.
String
(
"cpuprofile"
,
""
,
"write cpu profile to this file"
)
cpuprofile
:=
flag
.
String
(
"cpuprofile"
,
""
,
"write cpu profile to this file"
)
memprofile
:=
flag
.
String
(
"memprofile"
,
""
,
"write memory profile to this file"
)
memprofile
:=
flag
.
String
(
"memprofile"
,
""
,
"write memory profile to this file"
)
flag
.
Parse
()
flag
.
Parse
()
...
@@ -78,36 +74,26 @@ func main() {
...
@@ -78,36 +74,26 @@ func main() {
fmt
.
Printf
(
"Note: You must unmount gracefully, otherwise the profile file(s) will stay empty!
\n
"
)
fmt
.
Printf
(
"Note: You must unmount gracefully, otherwise the profile file(s) will stay empty!
\n
"
)
}
}
var
finalFs
pathfs
.
FileSystem
orig
:=
flag
.
Arg
(
1
)
orig
:=
flag
.
Arg
(
1
)
loopbackfs
:=
pathfs
.
NewLoopbackFileSystem
(
orig
)
loopbackRoot
,
err
:=
nodefs
.
NewLoopbackRoot
(
orig
)
finalFs
=
loopbackfs
if
err
!=
nil
{
log
.
Fatalf
(
"NewLoopbackRoot(%s): %v
\n
"
,
orig
,
err
)
}
sec
:=
time
.
Second
opts
:=
&
nodefs
.
Options
{
opts
:=
&
nodefs
.
Options
{
// These options are to be compatible with libfuse defaults,
// These options are to be compatible with libfuse defaults,
// making benchmarking easier.
// making benchmarking easier.
NegativeTimeout
:
time
.
Second
,
AttrTimeout
:
&
sec
,
AttrTimeout
:
time
.
Second
,
EntryTimeout
:
&
sec
,
EntryTimeout
:
time
.
Second
,
}
// Enable ClientInodes so hard links work
pathFsOpts
:=
&
pathfs
.
PathNodeFsOptions
{
ClientInodes
:
*
enableLinks
}
pathFs
:=
pathfs
.
NewPathNodeFs
(
finalFs
,
pathFsOpts
)
conn
:=
nodefs
.
NewFileSystemConnector
(
pathFs
.
Root
(),
opts
)
mountPoint
:=
flag
.
Arg
(
0
)
origAbs
,
_
:=
filepath
.
Abs
(
orig
)
mOpts
:=
&
fuse
.
MountOptions
{
AllowOther
:
*
other
,
Name
:
"loopbackfs"
,
FsName
:
origAbs
,
Debug
:
*
debug
,
}
}
state
,
err
:=
fuse
.
NewServer
(
conn
.
RawFS
(),
mountPoint
,
mOpts
)
opts
.
Debug
=
*
debug
opts
.
AllowOther
=
*
other
server
,
err
:=
nodefs
.
Mount
(
flag
.
Arg
(
0
),
loopbackRoot
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
log
.
Fatalf
(
"Mount fail: %v
\n
"
,
err
)
os
.
Exit
(
1
)
}
}
fmt
.
Println
(
"Mounted!"
)
fmt
.
Println
(
"Mounted!"
)
s
tate
.
Serve
()
s
erver
.
Wait
()
}
}
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