Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corner case when /etc/mtab doesn't exist and procfs=/proc #1470

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions psutil/_pslinux.py
Expand Up @@ -1169,13 +1169,13 @@ def disk_partitions(all=False):
fstypes.add("zfs")

# See: https://github.com/giampaolo/psutil/issues/1307
if procfs_path == "/proc":
mtab_path = os.path.realpath("/etc/mtab")
if procfs_path == "/proc" and os.path.isfile('/etc/mtab'):
mounts_path = os.path.realpath("/etc/mtab")
else:
mtab_path = os.path.realpath("%s/self/mounts" % procfs_path)
mounts_path = os.path.realpath("%s/self/mounts" % procfs_path)

retlist = []
partitions = cext.disk_partitions(mtab_path)
partitions = cext.disk_partitions(mounts_path)
for partition in partitions:
device, mountpoint, fstype, opts = partition
if device == 'none':
Expand Down