File: mounts.go

package info (click to toggle)
golang-github-opencontainers-runtime-tools 0.9.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,108 kB
  • sloc: sh: 557; makefile: 104
file content (92 lines) | stat: -rw-r--r-- 1,937 bytes parent folder | download | duplicates (3)
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
82
83
84
85
86
87
88
89
90
91
92
package main

import (
	rspec "github.com/opencontainers/runtime-spec/specs-go"
	"github.com/opencontainers/runtime-tools/validation/util"
)

func main() {
	defaultOptions := []string{
		"nosuid",
		"strictatime",
		"mode=755",
		"size=1k",
	}

	// Different combinations of mount types, mount options, mount propagation modes
	mounts := []rspec.Mount{
		{
			Destination: "/tmp/test-shared",
			Type:        "tmpfs",
			Source:      "tmpfs",
			Options:     []string{"shared"},
		},
		{
			Destination: "/tmp/test-slave",
			Type:        "tmpfs",
			Source:      "tmpfs",
			Options:     []string{"slave"},
		},
		{
			Destination: "/tmp/test-private",
			Type:        "tmpfs",
			Source:      "tmpfs",
			Options:     []string{"private"},
		},
		{
			Destination: "/mnt/etc-shared",
			Source:      "/etc",
			Options:     []string{"bind", "shared"},
		},
		{
			Destination: "/mnt/etc-rshared",
			Source:      "/etc",
			Options:     []string{"rbind", "rshared"},
		},
		{
			Destination: "/mnt/etc-slave",
			Source:      "/etc",
			Options:     []string{"bind", "slave"},
		},
		{
			Destination: "/mnt/etc-rslave",
			Source:      "/etc",
			Options:     []string{"rbind", "rslave"},
		},
		{
			Destination: "/mnt/etc-private",
			Source:      "/etc",
			Options:     []string{"bind", "private"},
		},
		{
			Destination: "/mnt/etc-rprivate",
			Source:      "/etc",
			Options:     []string{"rbind", "rprivate"},
		},
		{
			Destination: "/mnt/etc-unbindable",
			Source:      "/etc",
			Options:     []string{"bind", "unbindable"},
		},
		{
			Destination: "/mnt/etc-runbindable",
			Source:      "/etc",
			Options:     []string{"rbind", "runbindable"},
		},
	}

	g, err := util.GetDefaultGenerator()
	if err != nil {
		util.Fatal(err)
	}

	for _, m := range mounts {
		m.Options = append(defaultOptions, m.Options...)

		g.AddMount(m)
	}
	err = util.RuntimeInsideValidate(g, nil, nil)
	if err != nil {
		util.Fatal(err)
	}
}