Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
2c0c70f4
Commit
2c0c70f4
authored
Feb 29, 2016
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kill off silly fusermount screen scraping.
parent
2e4cd672
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
53 deletions
+8
-53
mount_linux.go
mount_linux.go
+8
-53
No files found.
mount_linux.go
View file @
2c0c70f4
package
fuse
package
fuse
import
(
import
(
"b
ufio
"
"b
ytes
"
"fmt"
"fmt"
"io"
"log"
"net"
"net"
"os"
"os"
"os/exec"
"os/exec"
"sync"
"syscall"
"syscall"
)
)
func
lineLogger
(
wg
*
sync
.
WaitGroup
,
prefix
string
,
r
io
.
ReadCloser
)
{
defer
wg
.
Done
()
scanner
:=
bufio
.
NewScanner
(
r
)
for
scanner
.
Scan
()
{
switch
line
:=
scanner
.
Text
();
line
{
case
`fusermount: failed to open /etc/fuse.conf: Permission denied`
:
// Silence this particular message, it occurs way too
// commonly and isn't very relevant to whether the mount
// succeeds or not.
continue
default
:
log
.
Printf
(
"%s: %s"
,
prefix
,
line
)
}
}
if
err
:=
scanner
.
Err
();
err
!=
nil
{
log
.
Printf
(
"%s, error reading: %v"
,
prefix
,
err
)
}
}
// Begin the process of mounting at the given directory, returning a connection
// Begin the process of mounting at the given directory, returning a connection
// to the kernel. Mounting continues in the background, and is complete when an
// to the kernel. Mounting continues in the background, and is complete when an
// error is written to the supplied channel. The file system may need to
// error is written to the supplied channel. The file system may need to
...
@@ -57,7 +34,9 @@ func mount(
...
@@ -57,7 +34,9 @@ func mount(
readFile
:=
os
.
NewFile
(
uintptr
(
fds
[
1
]),
"fusermount-parent-reads"
)
readFile
:=
os
.
NewFile
(
uintptr
(
fds
[
1
]),
"fusermount-parent-reads"
)
defer
readFile
.
Close
()
defer
readFile
.
Close
()
// Start fusermount, passing it pipes for stdout and stderr.
// Start fusermount, passing it a buffer in which to write stderr.
var
stderr
bytes
.
Buffer
cmd
:=
exec
.
Command
(
cmd
:=
exec
.
Command
(
"fusermount"
,
"fusermount"
,
"-o"
,
cfg
.
toOptionsString
(),
"-o"
,
cfg
.
toOptionsString
(),
...
@@ -67,36 +46,12 @@ func mount(
...
@@ -67,36 +46,12 @@ func mount(
cmd
.
Env
=
append
(
os
.
Environ
(),
"_FUSE_COMMFD=3"
)
cmd
.
Env
=
append
(
os
.
Environ
(),
"_FUSE_COMMFD=3"
)
cmd
.
ExtraFiles
=
[]
*
os
.
File
{
writeFile
}
cmd
.
ExtraFiles
=
[]
*
os
.
File
{
writeFile
}
cmd
.
Stderr
=
&
stderr
stdout
,
err
:=
cmd
.
StdoutPipe
()
// Run the command.
if
err
!=
nil
{
err
=
cmd
.
Run
()
err
=
fmt
.
Errorf
(
"StdoutPipe: %v"
,
err
)
return
}
stderr
,
err
:=
cmd
.
StderrPipe
()
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"StderrPipe: %v"
,
err
)
return
}
err
=
cmd
.
Start
()
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Starting fusermount: %v"
,
err
)
return
}
// Log fusermount output until it closes stdout and stderr.
var
wg
sync
.
WaitGroup
wg
.
Add
(
2
)
go
lineLogger
(
&
wg
,
"mount helper output"
,
stdout
)
go
lineLogger
(
&
wg
,
"mount helper error"
,
stderr
)
wg
.
Wait
()
// Wait for the command.
err
=
cmd
.
Wait
()
if
err
!=
nil
{
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"
fusermount: %v"
,
err
)
err
=
fmt
.
Errorf
(
"
running fusermount: %v
\n\n
stderr:
\n
%s"
,
err
,
stderr
.
Bytes
()
)
return
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