For the first point, you can try using os.path.realpath
to get a canonical path, check it against /etc/mtab
(I'd actually suggest calling getmntent
, but I can't find a normal way to access it) to find the longest match. (to be sure, you should probably stat
both the file and the presumed mountpoint to verify that they are in fact on the same device)
For the second point, use os.statvfs
to get block size and usage information.
(Disclaimer: I have tested none of this, most of what I know came from the coreutils sources)