Make sure the mount point exists up front.
parent
21ac1b6da5
commit
3574e9aa49
17
mount.go
17
mount.go
|
@ -16,6 +16,7 @@ package fuse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
@ -35,6 +36,22 @@ func Mount(
|
||||||
dir string,
|
dir string,
|
||||||
server Server,
|
server Server,
|
||||||
config *MountConfig) (mfs *MountedFileSystem, err error) {
|
config *MountConfig) (mfs *MountedFileSystem, err error) {
|
||||||
|
// Sanity check: make sure the mount point exists and is a directory. This
|
||||||
|
// saves us from some confusing errors later on OS X.
|
||||||
|
fi, err := os.Stat(dir)
|
||||||
|
switch {
|
||||||
|
case os.IsNotExist(err):
|
||||||
|
return
|
||||||
|
|
||||||
|
case err != nil:
|
||||||
|
err = fmt.Errorf("Statting mount point: %v", err)
|
||||||
|
return
|
||||||
|
|
||||||
|
case !fi.IsDir():
|
||||||
|
err = fmt.Errorf("Mount point %s is not a directory", dir)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the struct.
|
// Initialize the struct.
|
||||||
mfs = &MountedFileSystem{
|
mfs = &MountedFileSystem{
|
||||||
dir: dir,
|
dir: dir,
|
||||||
|
|
Loading…
Reference in New Issue