From fc5bd98d6508fd4bf6411389677bae9ca5cd7e3f Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Sun, 16 Oct 2016 08:56:34 +0100 Subject: [PATCH 1/3] Don't allow configurability for osxfuse paths. There's no need to complicate the API. If osxfuse makes a backwards-incompatible change again, we can add support for it. --- mount_config.go | 36 ++++++++++++++++-------------------- mount_darwin.go | 16 +++------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/mount_config.go b/mount_config.go index 45d9546..ac3c1f3 100644 --- a/mount_config.go +++ b/mount_config.go @@ -135,14 +135,6 @@ type MountConfig struct { // default name involving the string 'osxfuse' is used. VolumeName string - // OS X only. - // - // OSXFUSELocations sets where to look for OSXFUSE files. The arguments are - // all the possible locations. The previous locations are replaced. - // - // Without this option, OSXFUSELocationV3 and OSXFUSELocationV2 are used. - OSXFUSELocations []OSXFUSEPaths - // Additional key=value options to pass unadulterated to the underlying mount // command. See `man 8 mount`, the fuse documentation, etc. for // system-specific information. @@ -258,18 +250,22 @@ type OSXFUSEPaths struct { DaemonVar string } -// Default paths for OSXFUSE. See OSXFUSELocations. var ( - OSXFUSELocationV3 = OSXFUSEPaths{ - DevicePrefix: "/dev/osxfuse", - Load: "/Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse", - Mount: "/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", - DaemonVar: "MOUNT_OSXFUSE_DAEMON_PATH", - } - OSXFUSELocationV2 = OSXFUSEPaths{ - DevicePrefix: "/dev/osxfuse", - Load: "/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", - Mount: "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", - DaemonVar: "MOUNT_FUSEFS_DAEMON_PATH", + osxfuseLocations = []OSXFUSEPaths{ + // v3 + { + DevicePrefix: "/dev/osxfuse", + Load: "/Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse", + Mount: "/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", + DaemonVar: "MOUNT_OSXFUSE_DAEMON_PATH", + }, + + // v2 + { + DevicePrefix: "/dev/osxfuse", + Load: "/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", + Mount: "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", + DaemonVar: "MOUNT_FUSEFS_DAEMON_PATH", + }, } ) diff --git a/mount_darwin.go b/mount_darwin.go index 97dc1a1..7bff85c 100644 --- a/mount_darwin.go +++ b/mount_darwin.go @@ -17,9 +17,7 @@ var errNoAvail = errors.New("no available fuse devices") var errNotLoaded = errors.New("osxfuse is not loaded") // errOSXFUSENotFound is returned from Mount when the OSXFUSE installation is -// not detected. -// -// Make sure OSXFUSE is installed, or see OSXFUSELocations for customization. +// not detected. Make sure OSXFUSE is installed. var errOSXFUSENotFound = errors.New("cannot locate OSXFUSE") func loadOSXFUSE(bin string) error { @@ -136,16 +134,8 @@ func mount( dir string, cfg *MountConfig, ready chan<- error) (dev *os.File, err error) { - // get OSXFUSE locations - locations := cfg.OSXFUSELocations - if locations == nil { - locations = []OSXFUSEPaths{ - OSXFUSELocationV3, - OSXFUSELocationV2, - } - } - - for _, loc := range locations { + // Find the version of osxfuse installed on this machine. + for _, loc := range osxfuseLocations { if _, err := os.Stat(loc.Mount); os.IsNotExist(err) { // try the other locations continue From f1e482d1552e30cfdd5d1f8d43fe956e43807c96 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Sun, 16 Oct 2016 08:56:40 +0100 Subject: [PATCH 2/3] Move osxfuse-specific config into mount_darwin.go. --- mount_config.go | 39 --------------------------------------- mount_darwin.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/mount_config.go b/mount_config.go index ac3c1f3..6828ed3 100644 --- a/mount_config.go +++ b/mount_config.go @@ -230,42 +230,3 @@ func (c *MountConfig) toOptionsString() string { return strings.Join(components, ",") } - -// OSXFUSEPaths describes the paths used by an installed OSXFUSE version. -// See OSXFUSELocationV3 for typical values. -type OSXFUSEPaths struct { - // Prefix for the device file. At mount time, an incrementing number is - // suffixed until a free FUSE device is found. - DevicePrefix string - - // Path of the load helper, used to load the kernel extension if no device - // files are found. - Load string - - // Path of the mount helper, used for the actual mount operation. - Mount string - - // Environment variable used to pass the path to the executable calling the - // mount helper. - DaemonVar string -} - -var ( - osxfuseLocations = []OSXFUSEPaths{ - // v3 - { - DevicePrefix: "/dev/osxfuse", - Load: "/Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse", - Mount: "/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", - DaemonVar: "MOUNT_OSXFUSE_DAEMON_PATH", - }, - - // v2 - { - DevicePrefix: "/dev/osxfuse", - Load: "/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", - Mount: "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", - DaemonVar: "MOUNT_FUSEFS_DAEMON_PATH", - }, - } -) diff --git a/mount_darwin.go b/mount_darwin.go index 7bff85c..81fb3e1 100644 --- a/mount_darwin.go +++ b/mount_darwin.go @@ -20,6 +20,45 @@ var errNotLoaded = errors.New("osxfuse is not loaded") // not detected. Make sure OSXFUSE is installed. var errOSXFUSENotFound = errors.New("cannot locate OSXFUSE") +// OSXFUSEPaths describes the paths used by an installed OSXFUSE version. +// See OSXFUSELocationV3 for typical values. +type OSXFUSEPaths struct { + // Prefix for the device file. At mount time, an incrementing number is + // suffixed until a free FUSE device is found. + DevicePrefix string + + // Path of the load helper, used to load the kernel extension if no device + // files are found. + Load string + + // Path of the mount helper, used for the actual mount operation. + Mount string + + // Environment variable used to pass the path to the executable calling the + // mount helper. + DaemonVar string +} + +var ( + osxfuseLocations = []OSXFUSEPaths{ + // v3 + { + DevicePrefix: "/dev/osxfuse", + Load: "/Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse", + Mount: "/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", + DaemonVar: "MOUNT_OSXFUSE_DAEMON_PATH", + }, + + // v2 + { + DevicePrefix: "/dev/osxfuse", + Load: "/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs", + Mount: "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs", + DaemonVar: "MOUNT_FUSEFS_DAEMON_PATH", + }, + } +) + func loadOSXFUSE(bin string) error { cmd := exec.Command(bin) cmd.Dir = "/" From 8b5caee5750dff673f51f5262438b509bddc90ce Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Sun, 16 Oct 2016 08:56:44 +0100 Subject: [PATCH 3/3] Unexport OSXFUSEPaths. --- mount_darwin.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mount_darwin.go b/mount_darwin.go index 81fb3e1..d3dbbb9 100644 --- a/mount_darwin.go +++ b/mount_darwin.go @@ -20,9 +20,9 @@ var errNotLoaded = errors.New("osxfuse is not loaded") // not detected. Make sure OSXFUSE is installed. var errOSXFUSENotFound = errors.New("cannot locate OSXFUSE") -// OSXFUSEPaths describes the paths used by an installed OSXFUSE version. -// See OSXFUSELocationV3 for typical values. -type OSXFUSEPaths struct { +// osxfuseInstallation describes the paths used by an installed OSXFUSE +// version. +type osxfuseInstallation struct { // Prefix for the device file. At mount time, an incrementing number is // suffixed until a free FUSE device is found. DevicePrefix string @@ -40,7 +40,7 @@ type OSXFUSEPaths struct { } var ( - osxfuseLocations = []OSXFUSEPaths{ + osxfuseInstallations = []osxfuseInstallation{ // v3 { DevicePrefix: "/dev/osxfuse", @@ -174,7 +174,7 @@ func mount( cfg *MountConfig, ready chan<- error) (dev *os.File, err error) { // Find the version of osxfuse installed on this machine. - for _, loc := range osxfuseLocations { + for _, loc := range osxfuseInstallations { if _, err := os.Stat(loc.Mount); os.IsNotExist(err) { // try the other locations continue