1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
package driver
import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/glog"
)
// Implements Mounter
type seaweedFsMounter struct {
path string
collection string
readOnly bool
driver *SeaweedFsDriver
volContext map[string]string
}
const (
seaweedFsCmd = "weed"
)
func newSeaweedFsMounter(path string, collection string, readOnly bool, driver *SeaweedFsDriver, volContext map[string]string) (Mounter, error) {
return &seaweedFsMounter{
path: path,
collection: collection,
readOnly: readOnly,
driver: driver,
volContext: volContext,
}, nil
}
func (seaweedFs *seaweedFsMounter) Mount(target string) error {
glog.V(0).Infof("mounting %s %s to %s", seaweedFs.driver.filer, seaweedFs.path, target)
args := []string{
"mount",
"-dirAutoCreate=true",
"-umask=000",
fmt.Sprintf("-dir=%s", target),
fmt.Sprintf("-collection=%s", seaweedFs.collection),
fmt.Sprintf("-filer=%s", seaweedFs.driver.filer),
fmt.Sprintf("-filer.path=%s", seaweedFs.path),
fmt.Sprintf("-cacheCapacityMB=%d", seaweedFs.driver.CacheSizeMB),
}
// came from https://github.com/seaweedfs/seaweedfs-csi-driver/pull/12
// preferring explicit settings
// keeping this for backward compatibility
for arg, value := range seaweedFs.volContext {
switch arg {
case "map.uid":
args = append(args, fmt.Sprintf("-map.uid=%s", value))
case "map.gid":
args = append(args, fmt.Sprintf("-map.gid=%s", value))
case "replication":
args = append(args, fmt.Sprintf("-replication=%s", value))
}
}
if seaweedFs.readOnly {
args = append(args, "-readOnly")
}
if seaweedFs.driver.ConcurrentWriters > 0 {
args = append(args, fmt.Sprintf("-concurrentWriters=%d", seaweedFs.driver.ConcurrentWriters))
}
if seaweedFs.driver.CacheDir != "" {
args = append(args, fmt.Sprintf("-cacheDir=%s", seaweedFs.driver.CacheDir))
}
if seaweedFs.driver.UidMap != "" {
args = append(args, fmt.Sprintf("-map.uid=%s", seaweedFs.driver.UidMap))
}
if seaweedFs.driver.GidMap != "" {
args = append(args, fmt.Sprintf("-map.gid=%s", seaweedFs.driver.GidMap))
}
err := fuseMount(target, seaweedFsCmd, args)
if err != nil {
glog.Errorf("mount %s %s to %s: %s", seaweedFs.driver.filer, seaweedFs.path, target, err)
}
return err
}
|