Skip to content

Commit

Permalink
Merge pull request #135 from cyphar/mountinfo-linux-proc-self-fallback
Browse files Browse the repository at this point in the history
mountinfo: linux: add a /proc/self/mountinfo fallback
  • Loading branch information
kolyshkin authored Nov 7, 2023
2 parents a4e0878 + 6c165c1 commit 4950d76
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mountinfo/mountinfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func parseMountTable(filter FilterFunc) (_ []*Info, err error) {
// /proc/thread-self/ so we need to manually construct
// /proc/self/task/<tid>/ as a fallback.
f, err = os.Open("/proc/self/task/" + strconv.Itoa(unix.Gettid()) + "/mountinfo")
if os.IsNotExist(err) {
// If /proc/self/task/... failed, it means that our active pid
// namespace doesn't match the pid namespace of the /proc mount. In
// this case we just have to make do with /proc/self, since there
// is no other way of figuring out our tid in a parent pid
// namespace on pre-3.17 kernels.
f, err = os.Open("/proc/self/mountinfo")
}
}
if err != nil {
return nil, err
Expand Down

0 comments on commit 4950d76

Please sign in to comment.