Skip to content

Commit

Permalink
MountConfig: add FuseImpl field to select macOS FUSE implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
labulakalia authored and stapelberg committed Sep 9, 2024
1 parent faebccf commit bc4b1b5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
20 changes: 17 additions & 3 deletions mount_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ type MountConfig struct {
//
// Normally on OS X we mount with the novncache option
// (https://tinyurl.com/52hz9vya), which disables entry caching in the
// kernel. This is because osxfuse does not honor the entry expiration values
// we return to it, instead caching potentially forever
// kernel. This is because macFUSE (osxfuse) does not honor the entry
// expiration values we return to it, instead caching potentially forever
// (https://tinyurl.com/2rr6cd3m), and it is probably better to fail to cache
// than to cache for too long, since the latter is more likely to hide
// consistency bugs that are difficult to detect and diagnose.
Expand Down Expand Up @@ -167,9 +167,16 @@ type MountConfig struct {
// OS X only.
//
// The name of the mounted volume, as displayed in the Finder. If empty, a
// default name involving the string 'osxfuse' is used.
// default name involving the string 'osxfuse' (the old name of macFUSE)
// is used.
VolumeName string

// OS X only.
//
// The FUSE implementation to use. One of FUSEImplFuseT (default) or
// FUSEImplMacFUSE.
FuseImpl FUSEImpl

// Additional key=value options to pass unadulterated to the underlying mount
// command. See `man 8 mount`, the fuse documentation, etc. for
// system-specific information.
Expand All @@ -193,6 +200,13 @@ type MountConfig struct {
EnableParallelDirOps bool
}

type FUSEImpl uint8

const (
FUSEImplFuseT = iota
FUSEImplMacFUSE
)

// Create a map containing all of the key=value mount options to be given to
// the mount helper.
func (c *MountConfig) toMap() (opts map[string]string) {
Expand Down
18 changes: 13 additions & 5 deletions mount_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,13 @@ func startFuseTServer(binary string, argv []string,
}

func mountFuset(
bin string,
dir string,
cfg *MountConfig,
ready chan<- error) (dev *os.File, err error) {
fuseTBin, err := fusetBinary()
if err != nil {
return nil, err
}

fusekernel.IsPlatformFuseT = true
env := []string{}
Expand All @@ -403,7 +406,7 @@ func mountFuset(
env = append(env, "_FUSE_COMMVERS=2")
argv = append(argv, dir)

return startFuseTServer(bin, argv, env, false, cfg.DebugLogger, ready)
return startFuseTServer(fuseTBin, argv, env, false, cfg.DebugLogger, ready)
}

func mount(
Expand All @@ -412,8 +415,13 @@ func mount(
ready chan<- error) (dev *os.File, err error) {

fusekernel.IsPlatformFuseT = false
if fuset_bin, err := fusetBinary(); err == nil {
return mountFuset(fuset_bin, dir, cfg, ready)
switch cfg.FuseImpl {
case FUSEImplMacFUSE:
dev, err = mountOsxFuse(dir, cfg, ready)
case FUSEImplFuseT:
fallthrough
default:
dev, err = mountFuset(dir, cfg, ready)
}
return mountOsxFuse(dir, cfg, ready)
return
}
1 change: 1 addition & 0 deletions samples/mount_hello/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func main() {

cfg := &fuse.MountConfig{
ReadOnly: *fReadOnly,
FuseImpl: fuse.FUSEImplMacFUSE,
}

if *fDebug {
Expand Down

0 comments on commit bc4b1b5

Please sign in to comment.