First, sorry for my bad English.
I'm writing a python script, which compares the files in two different directories. But for performance, I want to know that: "Are the directories on the same physical disk or not?", so I can read them simultaneously for performance gain.
My current idea is getting "mount" commands output, and getting the /dev/sd* directories path and use them for identify the disks. But sometimes you can mount an already mounted directory on somewhere else(or something like that, i'm not so sure), so things get complicated.
Is there a better way to do that, like a library?
(If there is a cross-platform way, I will be more appreciated, but it seems it's hard to find a cross-platform library like this.)
An easier alternative to using mount might be to invoke df <directory>.
This prints out the filesystem. Also, on my Ubuntu box, passing -P to df makes the output a little bit easier to parse.
Learning the directory's physical disk on Linux with Python