summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2014-12-18 11:50:07 +0100
committerMartin Pitt <martin.pitt@ubuntu.com>2014-12-18 11:51:38 +0100
commit3c259bd00e4118d45c40fad25df710c2a66f60d9 (patch)
treef5bf298771425ee0413186a41161b19154a197ac
parent153c05f7cb4984c5616ca0ead12911479ad61f7b (diff)
Fix sorting of mount points
Fix udisks_mount_compare() to compare mounts in the expected and documented ascending order. Adjust FS integration test cases to mount a device on two mountpoints, to reproduce this bug. https://bugs.freedesktop.org/show_bug.cgi?id=78649
-rwxr-xr-xsrc/tests/integration-test17
-rw-r--r--src/udisksmount.c6
2 files changed, 16 insertions, 7 deletions
diff --git a/src/tests/integration-test b/src/tests/integration-test
index 6aeebf8..e8a67b9 100755
--- a/src/tests/integration-test
+++ b/src/tests/integration-test
@@ -32,6 +32,7 @@
import sys
import os
+import contextlib
srcdir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
libdir = os.path.join(srcdir, 'udisks', '.libs')
@@ -862,7 +863,7 @@ class FS(UDisksTestCase):
if type == 'swap':
return
- # mount it
+ # mount it on two points
if type == 'ntfs' and subprocess.call(['which', 'mount.ntfs-3g'],
stdout=subprocess.PIPE) == 0:
# prefer mount.ntfs-3g if we have it (on Debian; Ubuntu
@@ -870,17 +871,25 @@ class FS(UDisksTestCase):
mount_prog = 'mount.ntfs-3g'
else:
mount_prog = 'mount'
- ret = subprocess.call([mount_prog, self.device, self.workdir])
+ mount_a = os.path.join(self.workdir, 'mp_a')
+ mount_b = os.path.join(self.workdir, 'mp_b')
+ with contextlib.suppress(FileExistsError):
+ os.mkdir(mount_a)
+ os.mkdir(mount_b)
+
+ ret = subprocess.call([mount_prog, self.device, mount_a])
if ret == 32:
# missing fs driver
sys.stderr.write('[missing kernel driver, skip] ')
return
self.assertEqual(ret, 0)
- self.assertProperty(fs, 'mount-points', [self.workdir])
+ subprocess.check_call([mount_prog, self.device, mount_b])
+
+ self.assertProperty(fs, 'mount-points', [mount_a, mount_b])
# unmount it
- subprocess.call(['umount', self.workdir])
+ subprocess.call(['umount', mount_a, mount_b])
self.assertProperty(fs, 'mount-points', [])
def _do_udisks_check(self, type, label=None):
diff --git a/src/udisksmount.c b/src/udisksmount.c
index b45df41..b91cc2e 100644
--- a/src/udisksmount.c
+++ b/src/udisksmount.c
@@ -151,15 +151,15 @@ udisks_mount_compare (UDisksMount *mount,
g_return_val_if_fail (UDISKS_IS_MOUNT (mount), 0);
g_return_val_if_fail (UDISKS_IS_MOUNT (other_mount), 0);
- ret = g_strcmp0 (other_mount->mount_path, mount->mount_path);
+ ret = g_strcmp0 (mount->mount_path, other_mount->mount_path);
if (ret != 0)
goto out;
- ret = (mount->dev - other_mount->dev);
+ ret = (other_mount->dev - mount->dev);
if (ret != 0)
goto out;
- ret = mount->type - other_mount->type;
+ ret = other_mount->type - mount->type;
out:
return ret;