From 8396ff4ee44deb6c9db6920140f70a8cfda09e08 Mon Sep 17 00:00:00 2001 From: Ma Shimiao Date: Wed, 27 Jul 2016 17:38:50 +0800 Subject: [PATCH] generate: fix tmpfs adding based on manpage Signed-off-by: Ma Shimiao --- generate/generate.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/generate/generate.go b/generate/generate.go index fd5d9c6f..342311f0 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -886,11 +886,26 @@ func (g *Generator) AddPostStartHook(s string) error { // AddTmpfsMount adds a tmpfs mount into g.spec.Mounts. func (g *Generator) AddTmpfsMount(dest string) error { - mnt := rspec.Mount{ - Destination: dest, - Type: "tmpfs", - Source: "tmpfs", - Options: []string{"nosuid", "nodev", "mode=755"}, + mnt := rspec.Mount{} + + parts := strings.Split(dest, ":") + if len(parts) == 2 { + options := strings.Split(parts[1], ",") + mnt = rspec.Mount{ + Destination: parts[0], + Type: "tmpfs", + Source: "tmpfs", + Options: options, + } + } else if len(parts) == 1 { + mnt = rspec.Mount{ + Destination: parts[0], + Type: "tmpfs", + Source: "tmpfs", + Options: []string{"rw", "noexec", "nosuid", "nodev", "size=65536k"}, + } + } else { + return fmt.Errorf("invalid value for --tmpfs") } g.initSpec()