Skip to content

Commit 4950d76

Browse files
authored
Merge pull request #135 from cyphar/mountinfo-linux-proc-self-fallback
mountinfo: linux: add a /proc/self/mountinfo fallback
2 parents a4e0878 + 6c165c1 commit 4950d76

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: mountinfo/mountinfo_linux.go

+8
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ func parseMountTable(filter FilterFunc) (_ []*Info, err error) {
156156
// /proc/thread-self/ so we need to manually construct
157157
// /proc/self/task/<tid>/ as a fallback.
158158
f, err = os.Open("/proc/self/task/" + strconv.Itoa(unix.Gettid()) + "/mountinfo")
159+
if os.IsNotExist(err) {
160+
// If /proc/self/task/... failed, it means that our active pid
161+
// namespace doesn't match the pid namespace of the /proc mount. In
162+
// this case we just have to make do with /proc/self, since there
163+
// is no other way of figuring out our tid in a parent pid
164+
// namespace on pre-3.17 kernels.
165+
f, err = os.Open("/proc/self/mountinfo")
166+
}
159167
}
160168
if err != nil {
161169
return nil, err

0 commit comments

Comments
 (0)