@@ -6,22 +6,85 @@ import (
66)
77
88func main () {
9+ defaultOptions := []string {
10+ "nosuid" ,
11+ "strictatime" ,
12+ "mode=755" ,
13+ "size=1k" ,
14+ }
15+
16+ // Different combinations of mount types, mount options, mount propagation modes
17+ mounts := []rspec.Mount {
18+ rspec.Mount {
19+ Destination : "/tmp/test-shared" ,
20+ Type : "tmpfs" ,
21+ Source : "tmpfs" ,
22+ Options : []string {"shared" },
23+ },
24+ rspec.Mount {
25+ Destination : "/tmp/test-slave" ,
26+ Type : "tmpfs" ,
27+ Source : "tmpfs" ,
28+ Options : []string {"slave" },
29+ },
30+ rspec.Mount {
31+ Destination : "/tmp/test-private" ,
32+ Type : "tmpfs" ,
33+ Source : "tmpfs" ,
34+ Options : []string {"private" },
35+ },
36+ rspec.Mount {
37+ Destination : "/mnt/etc-shared" ,
38+ Source : "/etc" ,
39+ Options : []string {"bind" , "shared" },
40+ },
41+ rspec.Mount {
42+ Destination : "/mnt/etc-rshared" ,
43+ Source : "/etc" ,
44+ Options : []string {"rbind" , "rshared" },
45+ },
46+ rspec.Mount {
47+ Destination : "/mnt/etc-slave" ,
48+ Source : "/etc" ,
49+ Options : []string {"bind" , "slave" },
50+ },
51+ rspec.Mount {
52+ Destination : "/mnt/etc-rslave" ,
53+ Source : "/etc" ,
54+ Options : []string {"rbind" , "rslave" },
55+ },
56+ rspec.Mount {
57+ Destination : "/mnt/etc-private" ,
58+ Source : "/etc" ,
59+ Options : []string {"bind" , "private" },
60+ },
61+ rspec.Mount {
62+ Destination : "/mnt/etc-rprivate" ,
63+ Source : "/etc" ,
64+ Options : []string {"rbind" , "rprivate" },
65+ },
66+ rspec.Mount {
67+ Destination : "/mnt/etc-unbindable" ,
68+ Source : "/etc" ,
69+ Options : []string {"bind" , "unbindable" },
70+ },
71+ rspec.Mount {
72+ Destination : "/mnt/etc-runbindable" ,
73+ Source : "/etc" ,
74+ Options : []string {"rbind" , "runbindable" },
75+ },
76+ }
77+
978 g , err := util .GetDefaultGenerator ()
1079 if err != nil {
1180 util .Fatal (err )
1281 }
13- mount := rspec.Mount {
14- Destination : "/tmp" ,
15- Type : "tmpfs" ,
16- Source : "tmpfs" ,
17- Options : []string {
18- "nosuid" ,
19- "strictatime" ,
20- "mode=755" ,
21- "size=1k" ,
22- },
82+
83+ for _ , m := range mounts {
84+ m .Options = append (defaultOptions , m .Options ... )
85+
86+ g .AddMount (m )
2387 }
24- g .AddMount (mount )
2588 err = util .RuntimeInsideValidate (g , nil , nil )
2689 if err != nil {
2790 util .Fatal (err )
0 commit comments