Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get a meaningful mount point for st_dev on MacOS?

Tags:

python

macos

stat

Note this is a MacOS question not a Linux Question - They are different operating systems

I'd like to get a meaningful mount point out of python's os.stat("foo").st_dev. At the moment this is just a number and I can't find anywhere to cross reference it.

All my searches so far have come up with answers that work on Linux by interrogating /proc/... but /proc doesn't exist in MacOS so any such answer will not work.

like image 494
Philip Couling Avatar asked Nov 19 '25 23:11

Philip Couling


1 Answers

I'm a Linux guy, but if I were not allowed to use /proc, I would search the /dev directory for an entry (i.e. filename) which has following stat data:

  • st_mode indicates that it is a block device (helper: stat.S_ISBLK)
  • st_rdev matches the given st_dev value
like image 183
VPfB Avatar answered Nov 21 '25 12:11

VPfB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!