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
88b161f9
Commit
88b161f9
authored
Jul 30, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use normal umount if priviledged user.
This prevents "Failed to clone namespace" problem on some platforms.
parent
c8abd57b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
25 deletions
+32
-25
fuse/mount.go
fuse/mount.go
+32
-25
No files found.
fuse/mount.go
View file @
88b161f9
...
...
@@ -8,11 +8,11 @@ import (
"path/filepath"
"strings"
"syscall"
"time"
"unsafe"
)
var
mountBinary
string
=
"/bin/fusermount"
var
fusermountBinary
string
=
"/bin/fusermount"
var
umountBinary
string
=
"/bin/umount"
func
Socketpair
(
network
string
)
(
l
,
r
*
os
.
File
,
err
os
.
Error
)
{
var
domain
int
...
...
@@ -56,13 +56,13 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
mountPoint
=
filepath
.
Clean
(
filepath
.
Join
(
cwd
,
mountPoint
))
}
cmd
:=
[]
string
{
mountBinary
,
mountPoint
}
cmd
:=
[]
string
{
fuser
mountBinary
,
mountPoint
}
if
options
!=
""
{
cmd
=
append
(
cmd
,
"-o"
)
cmd
=
append
(
cmd
,
options
)
}
proc
,
err
:=
os
.
StartProcess
(
mountBinary
,
proc
,
err
:=
os
.
StartProcess
(
fuser
mountBinary
,
cmd
,
&
os
.
ProcAttr
{
Env
:
[]
string
{
"_FUSE_COMMFD=3"
},
...
...
@@ -86,28 +86,27 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
}
func
privilegedUnmount
(
mountPoint
string
)
os
.
Error
{
maxTry
:=
2
delay
:=
int64
(
0
)
errNo
:=
syscall
.
Unmount
(
mountPoint
,
0
)
for
try
:=
0
;
errNo
!=
0
&&
try
<
maxTry
;
try
++
{
// A file close operation must be processed and acked
// by the daemon. This takes some time, so retry if
// the first unmount fails.
delay
=
2
*
delay
+
0.01e9
time
.
Sleep
(
delay
)
errNo
=
syscall
.
Unmount
(
mountPoint
,
0
)
}
if
errNo
==
0
{
return
nil
}
return
os
.
Errno
(
errNo
)
dir
,
_
:=
filepath
.
Split
(
mountPoint
)
proc
,
err
:=
os
.
StartProcess
(
umountBinary
,
[]
string
{
umountBinary
,
mountPoint
},
&
os
.
ProcAttr
{
Dir
:
dir
,
Files
:
[]
*
os
.
File
{
nil
,
nil
,
os
.
Stderr
}})
if
err
!=
nil
{
return
err
}
w
,
err
:=
os
.
Wait
(
proc
.
Pid
,
0
)
if
w
.
ExitStatus
()
!=
0
{
return
os
.
NewError
(
fmt
.
Sprintf
(
"umount exited with code %d
\n
"
,
w
.
ExitStatus
()))
}
return
err
}
func
unmount
(
mountPoint
string
)
(
err
os
.
Error
)
{
if
os
.
Geteuid
()
==
0
{
return
privilegedUnmount
(
mountPoint
)
}
dir
,
_
:=
filepath
.
Split
(
mountPoint
)
proc
,
err
:=
os
.
StartProcess
(
mountBinary
,
[]
string
{
mountBinary
,
"-u"
,
mountPoint
},
proc
,
err
:=
os
.
StartProcess
(
fuser
mountBinary
,
[]
string
{
fuser
mountBinary
,
"-u"
,
mountPoint
},
&
os
.
ProcAttr
{
Dir
:
dir
,
Files
:
[]
*
os
.
File
{
nil
,
nil
,
os
.
Stderr
}})
if
err
!=
nil
{
return
...
...
@@ -156,10 +155,18 @@ func getConnection(local *os.File) (f *os.File, err os.Error) {
func
init
()
{
for
_
,
v
:=
range
strings
.
Split
(
os
.
Getenv
(
"PATH"
),
":"
)
{
tpath
:=
path
.
Join
(
v
,
"fusermount"
)
fi
,
err
:=
os
.
Stat
(
tpath
)
if
err
==
nil
&&
(
fi
.
Mode
&
0111
)
!=
0
{
mountBinary
=
tpath
fi
,
_
:=
os
.
Stat
(
tpath
)
if
fi
!=
nil
&&
(
fi
.
Mode
&
0111
)
!=
0
{
fusermountBinary
=
tpath
break
}
tpath
=
path
.
Join
(
v
,
"umount"
)
fi
,
_
=
os
.
Stat
(
tpath
)
if
fi
!=
nil
&&
(
fi
.
Mode
&
0111
)
!=
0
{
umountBinary
=
tpath
break
}
}
}
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