Skip to content

Commit

Permalink
add defaultFS back; output 'MUST' errs when loglevel >= error
Browse files Browse the repository at this point in the history
Signed-off-by: liangchenye <liangchenye@huawei.com>
  • Loading branch information
liangchenye committed Mar 30, 2017
1 parent 61a52e2 commit 2541823
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ const PR_GET_NO_NEW_PRIVS = 39
const specConfig = "config.json"

var (
defaultFS = map[string]string{
"/proc": "proc",
"/sys": "sysfs",
"/dev/pts": "devpts",
"/dev/shm": "tmpfs",
}

defaultSymlinks = map[string]string{
"/dev/fd": "/proc/self/fd",
"/dev/stdin": "/proc/self/fd/0",
Expand Down Expand Up @@ -266,6 +273,28 @@ func validateRootFS(spec *rspec.Spec) error {
return nil
}

func validateDefaultFS(spec *rspec.Spec) error {
logrus.Debugf("validating linux default filesystem")

mountInfos, err := mount.GetMounts()
if err != nil {
return ociErr.NewOCIError(ociErr.DEFAULT_FILESYSTEMS, err.Error())
}

mountsMap := make(map[string]string)
for _, mountInfo := range mountInfos {
mountsMap[mountInfo.Mountpoint] = mountInfo.Fstype
}

for fs, fstype := range defaultFS {
if !(mountsMap[fs] == fstype) {
return ociErr.NewOCIError(ociErr.DEFAULT_FILESYSTEMS, fmt.Sprintf("%v must exist and expected type is %v", fs, fstype))
}
}

return nil
}

func validateLinuxDevices(spec *rspec.Spec) error {
logrus.Debugf("validating linux devices")

Expand Down Expand Up @@ -585,6 +614,10 @@ func validate(context *cli.Context) error {
test: validateDefaultSymlinks,
description: "default symlinks",
},
{
test: validateDefaultFS,
description: "default file system",
},
{
test: validateDefaultDevices,
description: "default devices",
Expand Down

0 comments on commit 2541823

Please sign in to comment.