From 7d477d692b68a2be86ec66846fe23b2cfb15d3f0 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Tue, 16 Jan 2018 22:59:43 +0100 Subject: MacOS: rely on OSXFuse to create mountpoint below /Volumes OSXFuse automatically creates the mountpoint if it is below /Volumes because this would require root permissions which the user might not have. Reported at https://github.com/rfjakob/gocryptfs/issues/194 --- checkdir.go | 3 ++- mount.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/checkdir.go b/checkdir.go index 6f7f75d..63dfef0 100644 --- a/checkdir.go +++ b/checkdir.go @@ -6,7 +6,8 @@ import ( "os" ) -// checkDirEmpty - check if "dir" exists and is an empty directory +// checkDirEmpty - check if "dir" exists and is an empty directory. +// Returns an *os.PathError if Stat() on the path fails. func checkDirEmpty(dir string) error { err := checkDir(dir) if err != nil { diff --git a/mount.go b/mount.go index c3fda80..6ee7c36 100644 --- a/mount.go +++ b/mount.go @@ -58,6 +58,12 @@ func doMount(args *argContainer) int { err = checkDir(args.mountpoint) } else { err = checkDirEmpty(args.mountpoint) + // OSXFuse will create the mountpoint for us if it is below /Volumes/ + if runtime.GOOS == "darwin" && os.IsNotExist(err) && strings.HasPrefix(args.mountpoint, "/Volumes/") { + tlog.Info.Printf("Mountpoint %q does not exist, but should be created by OSXFuse", + args.mountpoint) + err = nil + } } if err != nil { tlog.Fatal.Printf("Invalid mountpoint: %v", err) -- cgit v1.2.3