Skip to content

Commit 3c2125c

Browse files
author
Mrunal Patel
authored
Merge pull request #155 from Mashimiao/generate-fix-tmpfs-adding
generate: fix tmpfs adding based on manpage
2 parents bc8aadb + 8396ff4 commit 3c2125c

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

generate/generate.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,11 +893,26 @@ func (g *Generator) AddPostStartHook(s string) error {
893893

894894
// AddTmpfsMount adds a tmpfs mount into g.spec.Mounts.
895895
func (g *Generator) AddTmpfsMount(dest string) error {
896-
mnt := rspec.Mount{
897-
Destination: dest,
898-
Type: "tmpfs",
899-
Source: "tmpfs",
900-
Options: []string{"nosuid", "nodev", "mode=755"},
896+
mnt := rspec.Mount{}
897+
898+
parts := strings.Split(dest, ":")
899+
if len(parts) == 2 {
900+
options := strings.Split(parts[1], ",")
901+
mnt = rspec.Mount{
902+
Destination: parts[0],
903+
Type: "tmpfs",
904+
Source: "tmpfs",
905+
Options: options,
906+
}
907+
} else if len(parts) == 1 {
908+
mnt = rspec.Mount{
909+
Destination: parts[0],
910+
Type: "tmpfs",
911+
Source: "tmpfs",
912+
Options: []string{"rw", "noexec", "nosuid", "nodev", "size=65536k"},
913+
}
914+
} else {
915+
return fmt.Errorf("invalid value for --tmpfs")
901916
}
902917

903918
g.initSpec()

0 commit comments

Comments
 (0)