Mount the fuse volume
( client *drive.Client, chunkManager *chunk.Manager, mountpoint string, mountOptions []string, uid, gid uint32, umask os.FileMode)
| 22 | |
| 23 | // Mount the fuse volume |
| 24 | func Mount( |
| 25 | client *drive.Client, |
| 26 | chunkManager *chunk.Manager, |
| 27 | mountpoint string, |
| 28 | mountOptions []string, |
| 29 | uid, gid uint32, |
| 30 | umask os.FileMode) error { |
| 31 | |
| 32 | Log.Infof("Mounting path %v", mountpoint) |
| 33 | |
| 34 | if _, err := os.Stat(mountpoint); os.IsNotExist(err) { |
| 35 | Log.Debugf("Mountpoint doesn't exist, creating...") |
| 36 | if err := os.MkdirAll(mountpoint, 0644); nil != err { |
| 37 | Log.Debugf("%v", err) |
| 38 | return fmt.Errorf("Could not create mount directory %v", mountpoint) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | fuse.Debug = func(msg interface{}) { |
| 43 | Log.Tracef("FUSE %v", msg) |
| 44 | } |
| 45 | |
| 46 | // Set mount options |
| 47 | options := []fuse.MountOption{ |
| 48 | fuse.NoAppleDouble(), |
| 49 | fuse.NoAppleXattr(), |
| 50 | } |
| 51 | directIO := false |
| 52 | maxReadahead := uint32(128 << 10) // 128 KB is the FUSE default |
| 53 | for _, option := range mountOptions { |
| 54 | if "allow_other" == option { |
| 55 | options = append(options, fuse.AllowOther()) |
| 56 | } else if "allow_root" == option { |
| 57 | return fmt.Errorf("The allow_root mount option is no longer supported") |
| 58 | } else if "allow_dev" == option { |
| 59 | options = append(options, fuse.AllowDev()) |
| 60 | } else if "allow_non_empty_mount" == option { |
| 61 | options = append(options, fuse.AllowNonEmptyMount()) |
| 62 | } else if "allow_suid" == option { |
| 63 | options = append(options, fuse.AllowSUID()) |
| 64 | } else if strings.HasPrefix(option, "max_readahead=") { |
| 65 | data := strings.Split(option, "=") |
| 66 | value, err := strconv.ParseUint(data[1], 10, 32) |
| 67 | if nil != err { |
| 68 | Log.Debugf("%v", err) |
| 69 | return fmt.Errorf("Could not parse max_readahead value") |
| 70 | } |
| 71 | maxReadahead = uint32(value) |
| 72 | } else if "default_permissions" == option { |
| 73 | options = append(options, fuse.DefaultPermissions()) |
| 74 | } else if "direct_io" == option { |
| 75 | directIO = true |
| 76 | } else if "excl_create" == option { |
| 77 | options = append(options, fuse.ExclCreate()) |
| 78 | } else if strings.HasPrefix(option, "fs_name") { |
| 79 | data := strings.Split(option, "=") |
| 80 | options = append(options, fuse.FSName(data[1])) |
| 81 | } else if "local_volume" == option { |
no test coverage detected