From f4d8f9816579c857d0fb97295c476e391dde8560 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 24 Jul 2015 16:09:15 +1000 Subject: [PATCH] MountConfig.toOptionsString --- mount_config.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mount_config.go b/mount_config.go index e20c915..dd76561 100644 --- a/mount_config.go +++ b/mount_config.go @@ -15,8 +15,10 @@ package fuse import ( + "fmt" "log" "runtime" + "strings" "golang.org/x/net/context" ) @@ -126,7 +128,26 @@ func (c *MountConfig) toMap() (opts map[string]string) { return } +func escapeOptionsKey(s string) (res string) { + res = s + res = strings.Replace(res, `\`, `\\`, -1) + res = strings.Replace(res, `,`, `\,`, -1) + return +} + // Create an options string suitable for passing to the mount helper. func (c *MountConfig) toOptionsString() string { - panic("TODO") + var components []string + for k, v := range c.toMap() { + k = escapeOptionsKey(k) + + component := k + if v != "" { + component = fmt.Sprintf("%s=%s", k, v) + } + + components = append(components, component) + } + + return strings.Join(components, ",") }