Skip to content

Commit 8396ff4

Browse files
author
Ma Shimiao
committed
generate: fix tmpfs adding based on manpage
Signed-off-by: Ma Shimiao <[email protected]>
1 parent 3334d03 commit 8396ff4

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
@@ -886,11 +886,26 @@ func (g *Generator) AddPostStartHook(s string) error {
886886

887887
// AddTmpfsMount adds a tmpfs mount into g.spec.Mounts.
888888
func (g *Generator) AddTmpfsMount(dest string) error {
889-
mnt := rspec.Mount{
890-
Destination: dest,
891-
Type: "tmpfs",
892-
Source: "tmpfs",
893-
Options: []string{"nosuid", "nodev", "mode=755"},
889+
mnt := rspec.Mount{}
890+
891+
parts := strings.Split(dest, ":")
892+
if len(parts) == 2 {
893+
options := strings.Split(parts[1], ",")
894+
mnt = rspec.Mount{
895+
Destination: parts[0],
896+
Type: "tmpfs",
897+
Source: "tmpfs",
898+
Options: options,
899+
}
900+
} else if len(parts) == 1 {
901+
mnt = rspec.Mount{
902+
Destination: parts[0],
903+
Type: "tmpfs",
904+
Source: "tmpfs",
905+
Options: []string{"rw", "noexec", "nosuid", "nodev", "size=65536k"},
906+
}
907+
} else {
908+
return fmt.Errorf("invalid value for --tmpfs")
894909
}
895910

896911
g.initSpec()

0 commit comments

Comments
 (0)