diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-06-04 14:38:04 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-06-05 13:12:46 +0000 |
commit | 7d56777f02d08f0a2e8e226b25531346e8b7816a (patch) | |
tree | c7010f16aca4a3b897f5b8fb7098cd59e1bdfd34 | |
parent | 5fefb7bce27b7642d4410f2f09c7891ca4378c9e (diff) | |
download | morph-7d56777f02d08f0a2e8e226b25531346e8b7816a.tar.gz |
S7904: method for testing paths are on the same fs
-rw-r--r-- | morphlib/util.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/morphlib/util.py b/morphlib/util.py index 007c7f7c..ffc84d58 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -226,3 +226,13 @@ def get_bytes_free_in_path(path): # pragma: no cover fsinfo = os.statvfs(path) return fsinfo.f_bavail * fsinfo.f_bsize + +def on_same_filesystem(path_a, path_b): # pragma: no cover + """Tests whether both paths are on the same fileystem + + Note behaviour may be unexpected on btrfs, since subvolumes + appear to be on a different device, but share a storage pool. + + """ + # TODO: return true if one path is a subvolume of the other on btrfs? + return os.stat(path_a).st_dev == os.stat(path_b).st_dev |