Make sure the mount point exists up front.

geesefs-0-30-9
Aaron Jacobs 2015-08-11 10:55:43 +10:00
parent 21ac1b6da5
commit 3574e9aa49
1 changed files with 17 additions and 0 deletions

View File

@ -16,6 +16,7 @@ package fuse
import (
"fmt"
"os"
"golang.org/x/net/context"
)
@ -35,6 +36,22 @@ func Mount(
dir string,
server Server,
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.
mfs = &MountedFileSystem{
dir: dir,