Skip to content

Commit

Permalink
Merge pull request #155 from Mashimiao/generate-fix-tmpfs-adding
Browse files Browse the repository at this point in the history
generate: fix tmpfs adding based on manpage
  • Loading branch information
Mrunal Patel authored Jul 27, 2016
2 parents bc8aadb + 8396ff4 commit 3c2125c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,11 +893,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()
Expand Down

0 comments on commit 3c2125c

Please sign in to comment.