File: linux_namespace.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 (30 lines) | stat: -rw-r--r-- 800 bytes parent folder | download | duplicates (4)
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
package util

// ProcNamespaces defines a list of namespaces to be found under /proc/*/ns/.
// NOTE: it is not the same as generate.Namespaces, because of naming
// mismatches like "mnt" vs "mount" or "net" vs "network".
var ProcNamespaces = []string{
	"cgroup",
	"ipc",
	"mnt",
	"net",
	"pid",
	"user",
	"uts",
}

// GetRuntimeToolsNamespace converts a namespace type string for /proc into
// a string for runtime-tools. It deals with exceptional cases of "net" and
// "mnt", because those strings cannot be recognized by mapStrToNamespace(),
// which actually expects "network" and "mount" respectively.
func GetRuntimeToolsNamespace(ns string) string {
	switch ns {
	case "net":
		return "network"
	case "mnt":
		return "mount"
	}

	// In other cases, return just the original string
	return ns
}