// mountOptions configures the options from the command line flags func mountOptions(device string) (options []fuse.MountOption) { options = []fuse.MountOption{ fuse.MaxReadahead(uint32(maxReadAhead)), fuse.Subtype("rclone"), fuse.FSName(device), fuse.VolumeName(device), fuse.NoAppleDouble(), fuse.NoAppleXattr(), // Options from benchmarking in the fuse module //fuse.MaxReadahead(64 * 1024 * 1024), //fuse.AsyncRead(), - FIXME this causes // ReadFileHandle.Read error: read /home/files/ISOs/xubuntu-15.10-desktop-amd64.iso: bad file descriptor // which is probably related to errors people are having //fuse.WritebackCache(), } if allowNonEmpty { options = append(options, fuse.AllowNonEmptyMount()) } if allowOther { options = append(options, fuse.AllowOther()) } if allowRoot { options = append(options, fuse.AllowRoot()) } if defaultPermissions { options = append(options, fuse.DefaultPermissions()) } if readOnly { options = append(options, fuse.ReadOnly()) } if writebackCache { options = append(options, fuse.WritebackCache()) } return options }
// NewMount mounts a fuse endpoint at `mountpoint` retrieving data from `store`. func NewMount(store *store.Store, mountpoint string) (*Mount, error) { conn, err := fuse.Mount( mountpoint, fuse.FSName("brigfs"), fuse.Subtype("brig"), fuse.AllowNonEmptyMount(), ) if err != nil { return nil, err } filesys := &Filesystem{Store: store} mnt := &Mount{ Conn: conn, Server: fs.New(conn, nil), FS: filesys, Dir: mountpoint, Store: store, done: make(chan util.Empty), errors: make(chan error), } go func() { defer close(mnt.done) log.Debugf("Serving FUSE at %v", mountpoint) mnt.errors <- mnt.Server.Serve(filesys) mnt.done <- util.Empty{} log.Debugf("Stopped serving FUSE at %v", mountpoint) }() select { case <-mnt.Conn.Ready: if err := mnt.Conn.MountError; err != nil { return nil, err } case err = <-mnt.errors: // Serve quit early if err != nil { return nil, err } return nil, errors.New("Serve exited early") } return mnt, nil }