MCPcopy
hub / github.com/opencontainers/runc / stringifyMountFlags

Function stringifyMountFlags

libcontainer/mount_linux.go:56–105  ·  view source on GitHub ↗

stringifyMountFlags converts mount(2) flags to a string that you can use in error messages.

(flags Int)

Source from the content-addressed store, hash-verified

54// stringifyMountFlags converts mount(2) flags to a string that you can use in
55// error messages.
56func stringifyMountFlags[Int int32plus](flags Int) string {
57 flagNames := []struct {
58 name string
59 bits Int
60 }{
61 {"MS_RDONLY", unix.MS_RDONLY},
62 {"MS_NOSUID", unix.MS_NOSUID},
63 {"MS_NODEV", unix.MS_NODEV},
64 {"MS_NOEXEC", unix.MS_NOEXEC},
65 {"MS_SYNCHRONOUS", unix.MS_SYNCHRONOUS},
66 {"MS_REMOUNT", unix.MS_REMOUNT},
67 {"MS_MANDLOCK", unix.MS_MANDLOCK},
68 {"MS_DIRSYNC", unix.MS_DIRSYNC},
69 {"MS_NOSYMFOLLOW", unix.MS_NOSYMFOLLOW},
70 // No (1 << 9) flag.
71 {"MS_NOATIME", unix.MS_NOATIME},
72 {"MS_NODIRATIME", unix.MS_NODIRATIME},
73 {"MS_BIND", unix.MS_BIND},
74 {"MS_MOVE", unix.MS_MOVE},
75 {"MS_REC", unix.MS_REC},
76 // MS_VERBOSE was deprecated and swapped to MS_SILENT.
77 {"MS_SILENT", unix.MS_SILENT},
78 {"MS_POSIXACL", unix.MS_POSIXACL},
79 {"MS_UNBINDABLE", unix.MS_UNBINDABLE},
80 {"MS_PRIVATE", unix.MS_PRIVATE},
81 {"MS_SLAVE", unix.MS_SLAVE},
82 {"MS_SHARED", unix.MS_SHARED},
83 {"MS_RELATIME", unix.MS_RELATIME},
84 // MS_KERNMOUNT (1 << 22) is internal to the kernel.
85 {"MS_I_VERSION", unix.MS_I_VERSION},
86 {"MS_STRICTATIME", unix.MS_STRICTATIME},
87 {"MS_LAZYTIME", unix.MS_LAZYTIME},
88 }
89 var (
90 flagSet []string
91 seenBits Int
92 )
93 for _, flag := range flagNames {
94 if flags&flag.bits == flag.bits {
95 seenBits |= flag.bits
96 flagSet = append(flagSet, flag.name)
97 }
98 }
99 // If there were any remaining flags specified we don't know the name of,
100 // just add them in an 0x... format.
101 if remaining := flags &^ seenBits; remaining != 0 {
102 flagSet = append(flagSet, "0x"+strconv.FormatUint(uint64(remaining), 16))
103 }
104 return strings.Join(flagSet, "|")
105}
106
107// Error provides a string error representation.
108func (e *mountError) Error() string {

Callers 3

TestStringifyMountFlagsFunction · 0.85
ErrorMethod · 0.85
mountToRootfsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestStringifyMountFlagsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…