From 4356468f492da3cf7ba3689bab13bdf4fa89186b Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Thu, 26 May 2016 12:36:29 -0700 Subject: [PATCH] Parse the new extension flags Signed-off-by: Mrunal Patel --- libcontainer/specconv/spec_linux.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index 7e12ffd19..e2a523369 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -234,7 +234,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) { } func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount { - flags, pgflags, data := parseMountOptions(m.Options) + flags, pgflags, data, ext := parseMountOptions(m.Options) source := m.Source if m.Type == "bind" { if !filepath.IsAbs(source) { @@ -248,6 +248,7 @@ func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount { Data: data, Flags: flags, PropagationFlags: pgflags, + Extensions: ext, } } @@ -592,11 +593,12 @@ func setupUserNamespace(spec *specs.Spec, config *configs.Config) error { // parseMountOptions parses the string and returns the flags, propagation // flags and any mount data that it contains. -func parseMountOptions(options []string) (int, []int, string) { +func parseMountOptions(options []string) (int, []int, string, int) { var ( - flag int - pgflag []int - data []string + flag int + pgflag []int + data []string + extFlags int ) flags := map[string]struct { clear bool @@ -638,6 +640,12 @@ func parseMountOptions(options []string) (int, []int, string) { "rslave": syscall.MS_SLAVE | syscall.MS_REC, "runbindable": syscall.MS_UNBINDABLE | syscall.MS_REC, } + extensionFlags := map[string]struct { + clear bool + flag int + }{ + "tmpcopyup": {false, configs.EXT_COPYUP}, + } for _, o := range options { // If the option does not exist in the flags table or the flag // is not supported on the platform, @@ -650,11 +658,17 @@ func parseMountOptions(options []string) (int, []int, string) { } } else if f, exists := propagationFlags[o]; exists && f != 0 { pgflag = append(pgflag, f) + } else if f, exists := extensionFlags[o]; exists && f.flag != 0 { + if f.clear { + extFlags &= ^f.flag + } else { + extFlags |= f.flag + } } else { data = append(data, o) } } - return flag, pgflag, strings.Join(data, ",") + return flag, pgflag, strings.Join(data, ","), extFlags } func setupSeccomp(config *specs.Seccomp) (*configs.Seccomp, error) {