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: make mount/mount remote control take vfsOpt option

Nick Craig-Wood26b46982126c
diff --git a/cmd/mountlib/rc.go b/cmd/mountlib/rc.go
index 843380333..9876fa82f 100644
--- a/cmd/mountlib/rc.go
+++ b/cmd/mountlib/rc.go
@@ -55,11 +55,18 @@ This takes the following parameters
- fs - a remote path to be mounted (required)
- mountPoint: valid path on the local machine (required)
- mountType: One of the values (mount, cmount, mount2) specifies the mount implementation to use
+- vfsOpt: a JSON object with VFS options in.
Eg
rclone rc mount/mount fs=mydrive: mountPoint=/home/<user>/mountPoint
rclone rc mount/mount fs=mydrive: mountPoint=/home/<user>/mountPoint mountType=mount
+ rclone rc mount/mount fs=TestDrive: mountPoint=/mnt/tmp vfsOpt='{"CacheMode": 2}'
+
+The vfsOpt are as described in options/get and can be seen in the the
+"vfs" section when running:
+
+ rclone rc options/get
`,
})
}
@@ -71,6 +78,12 @@ func mountRc(_ context.Context, in rc.Params) (out rc.Params, err error) {
return nil, err
}
+ vfsOpt := vfsflags.Opt
+ err = in.GetStructMissingOK("vfsOpt", &vfsOpt)
+ if err != nil {
+ return nil, err
+ }
+
mountType, err := in.GetString("mountType")
mountMu.Lock()
@@ -93,7 +106,7 @@ func mountRc(_ context.Context, in rc.Params) (out rc.Params, err error) {
}
if mountFns[mountType] != nil {
- VFS := vfs.New(fdst, &vfsflags.Opt)
+ VFS := vfs.New(fdst, &vfsOpt)
_, unmountFn, err := mountFns[mountType](VFS, mountPoint)
if err != nil {
diff --git a/cmd/mountlib/rc_test.go b/cmd/mountlib/rc_test.go
index aa9f91fdd..de725d7b1 100644
--- a/cmd/mountlib/rc_test.go
+++ b/cmd/mountlib/rc_test.go
@@ -68,6 +68,9 @@ func TestRc(t *testing.T) {
in := rc.Params{
"fs": localDir,
"mountPoint": mountPoint,
+ "vfsOpt": rc.Params{
+ "FilePerms": 0400,
+ },
}
// check file.txt is not there
@@ -86,6 +89,9 @@ func TestRc(t *testing.T) {
fi, err := os.Stat(filePath)
require.NoError(t, err)
assert.Equal(t, int64(5), fi.Size())
+ if runtime.GOOS == "linux" {
+ assert.Equal(t, os.FileMode(0400), fi.Mode())
+ }
// FIXME the OS sometimes appears to be using the mount
// immediately after it appears so wait a moment