Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

mount,cmount: Add --volname flag and remove special chars from it #2287

Nick Craig-Wood6ce32e46613b
diff --git a/cmd/cmount/mount.go b/cmd/cmount/mount.go
index 325dfe175..096710745 100644
--- a/cmd/cmount/mount.go
+++ b/cmd/cmount/mount.go
@@ -53,7 +53,7 @@ func mountOptions(device string, mountpoint string) (options []string) {
// OSX options
if runtime.GOOS == "darwin" {
- options = append(options, "-o", "volname="+device)
+ options = append(options, "-o", "volname="+mountlib.VolumeName)
options = append(options, "-o", "noappledouble")
options = append(options, "-o", "noapplexattr")
}
diff --git a/cmd/mount/mount.go b/cmd/mount/mount.go
index 4e4bb38df..5f2ae6573 100644
--- a/cmd/mount/mount.go
+++ b/cmd/mount/mount.go
@@ -28,7 +28,7 @@ func mountOptions(device string) (options []fuse.MountOption) {
options = []fuse.MountOption{
fuse.MaxReadahead(uint32(mountlib.MaxReadAhead)),
fuse.Subtype("rclone"),
- fuse.FSName(device), fuse.VolumeName(device),
+ fuse.FSName(device), fuse.VolumeName(mountlib.VolumeName),
fuse.NoAppleDouble(),
fuse.NoAppleXattr(),
diff --git a/cmd/mountlib/mount.go b/cmd/mountlib/mount.go
index 0d7d347e5..7efecab42 100644
--- a/cmd/mountlib/mount.go
+++ b/cmd/mountlib/mount.go
@@ -5,6 +5,7 @@ import (
"log"
"os"
"runtime"
+ "strings"
"time"
"github.com/ncw/rclone/cmd"
@@ -29,6 +30,7 @@ var (
ExtraOptions []string
ExtraFlags []string
AttrTimeout = 1 * time.Second // how long the kernel caches attribute for
+ VolumeName string
)
// Check is folder is empty
@@ -228,6 +230,15 @@ be copied to the vfs cache before opening with --vfs-cache-mode full.
}
}
+ // Work out the volume name, removing special
+ // characters from it if necessary
+ if VolumeName == "" {
+ VolumeName = fdst.Name() + ":" + fdst.Root()
+ }
+ VolumeName = strings.Replace(VolumeName, ":", " ", -1)
+ VolumeName = strings.Replace(VolumeName, "/", " ", -1)
+ VolumeName = strings.TrimSpace(VolumeName)
+
// Start background task if --background is specified
if Daemon {
daemonized := startBackgroundMode()
@@ -260,6 +271,7 @@ be copied to the vfs cache before opening with --vfs-cache-mode full.
flags.StringArrayVarP(flagSet, &ExtraOptions, "option", "o", []string{}, "Option for libfuse/WinFsp. Repeat if required.")
flags.StringArrayVarP(flagSet, &ExtraFlags, "fuse-flag", "", []string{}, "Flags or arguments to be passed direct to libfuse/WinFsp. Repeat if required.")
flags.BoolVarP(flagSet, &Daemon, "daemon", "", Daemon, "Run mount as a daemon (background mode).")
+ flags.StringVarP(flagSet, &VolumeName, "volname", "", VolumeName, "Set the volume name (not supported by all OSes).")
// Add in the generic flags
vfsflags.AddFlags(flagSet)