1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 11:31:54 +08:00

fix fuse mount error in linux

There has been a regression such that ./t0030-mount.sh fails on

  'ipfs mount' fails when there is no mount dir

The issue was a change in how fuse errors are reported to the client
process. We have introduced an optimistic categorization that hides
the obscure fusermount error and replaces it with something a bit
more helpful.

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
This commit is contained in:
Juan Batiz-Benet
2015-06-18 01:45:44 -07:00
parent c73d0e0b56
commit bc85a6384b

View File

@ -24,6 +24,9 @@ const mountTimeout = time.Second
// fuseNoDirectory used to check the returning fuse error
const fuseNoDirectory = "fusermount: failed to access mountpoint"
// fuseExitStatus1 used to check the returning fuse error
const fuseExitStatus1 = "fusermount: exit status 1"
// platformFuseChecks can get overridden by arch-specific files
// to run fuse checks (like checking the OSXFUSE version)
var platformFuseChecks = func(*core.IpfsNode) error {
@ -181,13 +184,17 @@ func Mount(node *core.IpfsNode, fsdir, nsdir string) error {
}
func doMount(node *core.IpfsNode, fsdir, nsdir string) error {
fmtFuseErr := func(err error) error {
fmtFuseErr := func(err error, mountpoint string) error {
s := err.Error()
if strings.Contains(s, fuseNoDirectory) {
s = strings.Replace(s, `fusermount: "fusermount:`, "", -1)
s = strings.Replace(s, `\n", exit status 1`, "", -1)
return cmds.ClientError(s)
}
if s == fuseExitStatus1 {
s = fmt.Sprintf("fuse failed to access mountpoint %s", mountpoint)
return cmds.ClientError(s)
}
return err
}
@ -222,9 +229,9 @@ func doMount(node *core.IpfsNode, fsdir, nsdir string) error {
}
if err1 != nil {
return fmtFuseErr(err1)
return fmtFuseErr(err1, fsdir)
}
return fmtFuseErr(err2)
return fmtFuseErr(err2, nsdir)
}
// setup node state, so that it can be cancelled