mirror of
https://github.com/opencontainers/runc.git
synced 2026-11-06 05:17:05 +00:00
Merge pull request #5602 from kolyshkin/1.5-5520
[1.5] libct/specconv: do not pass "defaults" as mount data
This commit is contained in:
2 files changed
+43
-3
No files matched your search
@@ -78,7 +78,7 @@ func initMaps() {
|
||||
"async": {true, unix.MS_SYNCHRONOUS},
|
||||
"atime": {true, unix.MS_NOATIME},
|
||||
"bind": {false, unix.MS_BIND},
|
||||
"defaults": {false, 0},
|
||||
"defaults": {false, 0}, // no-op, must not be passed as data
|
||||
"dev": {true, unix.MS_NODEV},
|
||||
"diratime": {true, unix.MS_NODIRATIME},
|
||||
"dirsync": {false, unix.MS_DIRSYNC},
|
||||
@@ -1142,9 +1142,8 @@ func parseMountOptions(options []string) *configs.Mount {
|
||||
initMaps()
|
||||
for _, o := range options {
|
||||
// If the option does not exist in the mountFlags table,
|
||||
// or the flag is not supported on the platform,
|
||||
// then it is a data value for a specific fs type.
|
||||
if f, exists := mountFlags[o]; exists && f.flag != 0 {
|
||||
if f, exists := mountFlags[o]; exists {
|
||||
// FIXME: The *atime flags are special (they are more of an enum
|
||||
// with quite hairy semantics) and thus arguably setting some of
|
||||
// them should clear unrelated flags.
|
||||
|
||||
@@ -1026,3 +1026,44 @@ func TestCreateNetDevices(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseMountOptions(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
options []string
|
||||
flags int
|
||||
cleared int
|
||||
data string
|
||||
}{
|
||||
{
|
||||
name: "defaults is not data",
|
||||
options: []string{"defaults", "size=1m", "mode=777"},
|
||||
data: "size=1m,mode=777",
|
||||
},
|
||||
{
|
||||
name: "unknown options are data",
|
||||
options: []string{"defaults", "notarealoption", "size=1m"},
|
||||
data: "notarealoption,size=1m",
|
||||
},
|
||||
{
|
||||
name: "flags are set and cleared",
|
||||
options: []string{"ro", "nodev", "rw"},
|
||||
flags: unix.MS_NODEV,
|
||||
cleared: unix.MS_RDONLY,
|
||||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
m := parseMountOptions(tc.options)
|
||||
if m.Flags != tc.flags {
|
||||
t.Errorf("expected flags %#x, got %#x", tc.flags, m.Flags)
|
||||
}
|
||||
if m.ClearedFlags != tc.cleared {
|
||||
t.Errorf("expected cleared flags %#x, got %#x", tc.cleared, m.ClearedFlags)
|
||||
}
|
||||
if m.Data != tc.data {
|
||||
t.Errorf("expected data %q, got %q", tc.data, m.Data)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user