Skip to content

Commit 4356468

Browse files
committed
Parse the new extension flags
Signed-off-by: Mrunal Patel <[email protected]>
1 parent f5103d3 commit 4356468

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

libcontainer/specconv/spec_linux.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
234234
}
235235

236236
func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount {
237-
flags, pgflags, data := parseMountOptions(m.Options)
237+
flags, pgflags, data, ext := parseMountOptions(m.Options)
238238
source := m.Source
239239
if m.Type == "bind" {
240240
if !filepath.IsAbs(source) {
@@ -248,6 +248,7 @@ func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount {
248248
Data: data,
249249
Flags: flags,
250250
PropagationFlags: pgflags,
251+
Extensions: ext,
251252
}
252253
}
253254

@@ -592,11 +593,12 @@ func setupUserNamespace(spec *specs.Spec, config *configs.Config) error {
592593

593594
// parseMountOptions parses the string and returns the flags, propagation
594595
// flags and any mount data that it contains.
595-
func parseMountOptions(options []string) (int, []int, string) {
596+
func parseMountOptions(options []string) (int, []int, string, int) {
596597
var (
597-
flag int
598-
pgflag []int
599-
data []string
598+
flag int
599+
pgflag []int
600+
data []string
601+
extFlags int
600602
)
601603
flags := map[string]struct {
602604
clear bool
@@ -638,6 +640,12 @@ func parseMountOptions(options []string) (int, []int, string) {
638640
"rslave": syscall.MS_SLAVE | syscall.MS_REC,
639641
"runbindable": syscall.MS_UNBINDABLE | syscall.MS_REC,
640642
}
643+
extensionFlags := map[string]struct {
644+
clear bool
645+
flag int
646+
}{
647+
"tmpcopyup": {false, configs.EXT_COPYUP},
648+
}
641649
for _, o := range options {
642650
// If the option does not exist in the flags table or the flag
643651
// is not supported on the platform,
@@ -650,11 +658,17 @@ func parseMountOptions(options []string) (int, []int, string) {
650658
}
651659
} else if f, exists := propagationFlags[o]; exists && f != 0 {
652660
pgflag = append(pgflag, f)
661+
} else if f, exists := extensionFlags[o]; exists && f.flag != 0 {
662+
if f.clear {
663+
extFlags &= ^f.flag
664+
} else {
665+
extFlags |= f.flag
666+
}
653667
} else {
654668
data = append(data, o)
655669
}
656670
}
657-
return flag, pgflag, strings.Join(data, ",")
671+
return flag, pgflag, strings.Join(data, ","), extFlags
658672
}
659673

660674
func setupSeccomp(config *specs.Seccomp) (*configs.Seccomp, error) {

0 commit comments

Comments
 (0)