diff --git a/cmd/cmount/mount.go b/cmd/cmount/mount.go index 42b1c51ab..cafecafac 100644 --- a/cmd/cmount/mount.go +++ b/cmd/cmount/mount.go @@ -168,7 +168,7 @@ func mount(VFS *vfs.VFS, mountPath string, opt *mountlib.Options) (<-chan error, host.SetCapCaseInsensitive(f.Features().CaseInsensitive) // Create options - options := mountOptions(VFS, f.Name()+":"+f.Root(), mountpoint, opt) + options := mountOptions(VFS, opt.DeviceName, mountpoint, opt) fs.Debugf(f, "Mounting with options: %q", options) // Serve the mount point in the background returning error to errChan diff --git a/cmd/mount/mount.go b/cmd/mount/mount.go index 73fcbf550..d6fbf1a92 100644 --- a/cmd/mount/mount.go +++ b/cmd/mount/mount.go @@ -86,7 +86,7 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (<-chan error f := VFS.Fs() fs.Debugf(f, "Mounting on %q", mountpoint) - c, err := fuse.Mount(mountpoint, mountOptions(VFS, f.Name()+":"+f.Root(), opt)...) + c, err := fuse.Mount(mountpoint, mountOptions(VFS, opt.DeviceName, opt)...) if err != nil { return nil, nil, err } diff --git a/cmd/mount2/mount.go b/cmd/mount2/mount.go index fabf38b86..d33f44533 100644 --- a/cmd/mount2/mount.go +++ b/cmd/mount2/mount.go @@ -25,11 +25,10 @@ func init() { // mountOptions configures the options from the command line flags // // man mount.fuse for more info and note the -o flag for other options -func mountOptions(fsys *FS, f fs.Fs) (mountOpts *fuse.MountOptions) { - device := f.Name() + ":" + f.Root() +func mountOptions(fsys *FS, f fs.Fs, opt *mountlib.Options) (mountOpts *fuse.MountOptions) { mountOpts = &fuse.MountOptions{ AllowOther: fsys.opt.AllowOther, - FsName: device, + FsName: opt.DeviceName, Name: "rclone", DisableXAttrs: true, Debug: fsys.opt.DebugFUSE, @@ -120,7 +119,7 @@ func mountOptions(fsys *FS, f fs.Fs) (mountOpts *fuse.MountOptions) { if runtime.GOOS == "darwin" { opts = append(opts, // VolumeName sets the volume name shown in Finder. - fmt.Sprintf("volname=%s", device), + fmt.Sprintf("volname=%s", opt.VolumeName), // NoAppleXattr makes OSXFUSE disallow extended attributes with the // prefix "com.apple.". This disables persistent Finder state and @@ -167,7 +166,7 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (<-chan error //mOpts.Debug = mountlib.DebugFUSE //conn := fusefs.NewFileSystemConnector(nodeFs.Root(), mOpts) - mountOpts := mountOptions(fsys, f) + mountOpts := mountOptions(fsys, f, opt) // FIXME fill out opts := fusefs.Options{ diff --git a/cmd/mountlib/mount.go b/cmd/mountlib/mount.go index 60d2661e7..5a9b762a1 100644 --- a/cmd/mountlib/mount.go +++ b/cmd/mountlib/mount.go @@ -40,6 +40,7 @@ type Options struct { ExtraOptions []string ExtraFlags []string AttrTimeout time.Duration // how long the kernel caches attribute for + DeviceName string VolumeName string NoAppleDouble bool NoAppleXattr bool @@ -125,6 +126,7 @@ func AddFlags(flagSet *pflag.FlagSet) { flags.BoolVarP(flagSet, &Opt.AsyncRead, "async-read", "", Opt.AsyncRead, "Use asynchronous reads (not supported on Windows)") flags.FVarP(flagSet, &Opt.MaxReadAhead, "max-read-ahead", "", "The number of bytes that can be prefetched for sequential reads (not supported on Windows)") flags.BoolVarP(flagSet, &Opt.WritebackCache, "write-back-cache", "", Opt.WritebackCache, "Makes kernel buffer writes before sending them to rclone (without this, writethrough caching is used) (not supported on Windows)") + flags.StringVarP(flagSet, &Opt.DeviceName, "devname", "", Opt.DeviceName, "Set the device name - default is remote:path") // Windows and OSX flags.StringVarP(flagSet, &Opt.VolumeName, "volname", "", Opt.VolumeName, "Set the volume name (supported on Windows and OSX only)") // OSX only @@ -235,6 +237,7 @@ func (m *MountPoint) Mount() (daemon *os.Process, err error) { return nil, err } m.SetVolumeName(m.MountOpt.VolumeName) + m.SetDeviceName(m.MountOpt.DeviceName) // Start background task if --daemon is specified if m.MountOpt.Daemon { diff --git a/cmd/mountlib/utils.go b/cmd/mountlib/utils.go index 673903317..1ec4d786a 100644 --- a/cmd/mountlib/utils.go +++ b/cmd/mountlib/utils.go @@ -87,7 +87,7 @@ func (m *MountPoint) CheckAllowings() error { // SetVolumeName with sensible default func (m *MountPoint) SetVolumeName(vol string) { if vol == "" { - vol = m.Fs.Name() + ":" + m.Fs.Root() + vol = fs.ConfigString(m.Fs) } m.MountOpt.SetVolumeName(vol) } @@ -102,3 +102,11 @@ func (o *Options) SetVolumeName(vol string) { } o.VolumeName = vol } + +// SetDeviceName with sensible default +func (m *MountPoint) SetDeviceName(dev string) { + if dev == "" { + dev = fs.ConfigString(m.Fs) + } + m.MountOpt.DeviceName = dev +}