Add mount options support

This commit is contained in:
Vitaliy Filippov 2021-07-16 16:12:57 +03:00
parent 0433ead376
commit d78d476d6d
6 changed files with 36 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"strings"
"context"
@ -49,15 +50,27 @@ func (goofys *goofysMounter) Unstage(stageTarget string) error {
}
func (goofys *goofysMounter) Mount(source string, target string) error {
mountOptions := make(map[string]string)
for _, opt := range goofys.meta.MountOptions {
s := 0
if len(opt) >= 2 && opt[0] == '-' && opt[1] == byte('-') {
s = 2
}
p := strings.Index(opt, "=")
if p > 0 {
mountOptions[string(opt[s : p])] = string(opt[p : ])
} else {
mountOptions[string(opt[s : ])] = ""
}
}
mountOptions["allow_other"] = ""
goofysCfg := &goofysApi.Config{
MountPoint: target,
Endpoint: goofys.endpoint,
Region: goofys.region,
DirMode: 0755,
FileMode: 0644,
MountOptions: map[string]string{
"allow_other": "",
},
MountOptions: mountOptions,
}
os.Setenv("AWS_ACCESS_KEY_ID", goofys.accessKeyID)

View file

@ -31,6 +31,7 @@ const (
rcloneMounterType = "rclone"
TypeKey = "mounter"
BucketKey = "bucket"
OptionsKey = "options"
)
// New returns a new mounter depending on the mounterType parameter

View file

@ -50,9 +50,9 @@ func (rclone *rcloneMounter) Mount(source string, target string) error {
fmt.Sprintf("--s3-region=%s", rclone.region),
fmt.Sprintf("--s3-endpoint=%s", rclone.url),
"--allow-other",
// TODO: make this configurable
"--vfs-cache-mode=writes",
}
args = append(args, rclone.meta.MountOptions...)
os.Setenv("AWS_ACCESS_KEY_ID", rclone.accessKeyID)
os.Setenv("AWS_SECRET_ACCESS_KEY", rclone.secretAccessKey)
return fuseMount(target, rcloneCmd, args)

View file

@ -50,6 +50,7 @@ func (s3fs *s3fsMounter) Mount(source string, target string) error {
"-o", "allow_other",
"-o", "mp_umask=000",
}
args = append(args, s3fs.meta.MountOptions...)
return fuseMount(target, s3fsCmd, args)
}