You can loop over local disks, and compare the disk's st_rdev
to the st_dev
you got earlier.
for mnt in glob.glob("/dev/disk?s*"):
t = os.stat(mnt)
if t.st_rdev == s.st_dev:
print(mnt)
Get device filesystem path from dev_t on macOS basically confirms this information, but of course, isn't strictly a duplicate.
For what it's worth, diskutil list -plist
prints a machine-readable XML property list of all disk identifiers, and diskutil info -plist disk1s1
(for example) prints information for a particular disk; but this does not include the dev_t
information that you get from os.stat().st_rdev
Annoyingly, diskutil
does not have a manual page on my system, but here is a (possibly old) on-line version.
The getdevinfo package on PyPI appears to provide a Python binding to most of this information, though https://www.hamishmb.com/html/Docs/developer/getdevinfo/macos.html looks rather spare.