forked from keybase/kbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmounter_osx.go
More file actions
69 lines (57 loc) · 1.95 KB
/
Copy pathmounter_osx.go
File metadata and controls
69 lines (57 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2016 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
// +build darwin
package libfuse
import (
"errors"
"bazil.org/fuse"
)
var kbfusePath = fuse.OSXFUSEPaths{
DevicePrefix: "/dev/kbfuse",
Load: "/Library/Filesystems/kbfuse.fs/Contents/Resources/load_kbfuse",
Mount: "/Library/Filesystems/kbfuse.fs/Contents/Resources/mount_kbfuse",
DaemonVar: "MOUNT_KBFUSE_DAEMON_PATH",
}
func getPlatformSpecificMountOptions(dir string, platformParams PlatformParams) ([]fuse.MountOption, error) {
options := []fuse.MountOption{}
var locationOption fuse.MountOption
if platformParams.UseSystemFuse {
// Only allow osxfuse 3.x.
locationOption = fuse.OSXFUSELocations(fuse.OSXFUSELocationV3)
} else {
// Only allow kbfuse.
locationOption = fuse.OSXFUSELocations(kbfusePath)
}
options = append(options, locationOption)
// Volume name option is only used on OSX (ignored on other platforms).
volName, err := volumeName(dir)
if err != nil {
return nil, err
}
options = append(options, fuse.VolumeName(volName))
options = append(options, fuse.ExclCreate())
return options, nil
}
// GetPlatformSpecificMountOptionsForTest makes cross-platform tests work
func GetPlatformSpecificMountOptionsForTest() []fuse.MountOption {
// For now, test with either kbfuse or OSXFUSE for now.
// TODO: Consider mandate testing with kbfuse?
return []fuse.MountOption{
fuse.OSXFUSELocations(kbfusePath, fuse.OSXFUSELocationV3),
fuse.ExclCreate(),
}
}
func translatePlatformSpecificError(err error, platformParams PlatformParams) error {
if err == fuse.ErrOSXFUSENotFound {
if platformParams.UseSystemFuse {
return errors.New(
"cannot locate OSXFUSE 3.x (3.2 recommended)")
}
return errors.New(
"cannot locate kbfuse; either install the Keybase " +
"app, or install OSXFUSE 3.x (3.2 " +
"recommended) and pass in --use-system-fuse")
}
return err
}