Add fallback for missing /proc/1/mounts (#1172)
* Add fallback for missing /proc/1/mounts On some systems, `/proc/1/mounts` is hidden from non-root users due to the `hidepid` procfs feature. Attempt to fallback to `/proc/mounts` if `/proc/1/mounts` is not found. Signed-off-by: Ben Kochie <superq@gmail.com> * Add tests. Signed-off-by: Ben Kochie <superq@gmail.com> * Add CHANGELOG entry. Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
0cb0c4d911
commit
4abc6fba7d
4 changed files with 28 additions and 0 deletions
|
|
@ -135,6 +135,11 @@ func stuckMountWatcher(mountPoint string, success chan struct{}) {
|
|||
|
||||
func mountPointDetails() ([]filesystemLabels, error) {
|
||||
file, err := os.Open(procFilePath("1/mounts"))
|
||||
if os.IsNotExist(err) {
|
||||
// Fallback to `/proc/mounts` if `/proc/1/mounts` is missing due hidepid.
|
||||
log.Debugf("Got %q reading root mounts, falling back to system mounts", err)
|
||||
file, err = os.Open(procFilePath("mounts"))
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue