summaryrefslogtreecommitdiff
path: root/libbtrfsutil
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2018-11-13 23:46:56 -0800
committerDavid Sterba <dsterba@suse.com>2018-11-26 16:45:11 +0100
commit563affcd42d4575d477e0f7fe067e1259dfb3687 (patch)
tree39d76c8c910c0f16312f03875193e78329ebb667 /libbtrfsutil
parent5d64c40240135cc22f4ba2b902bfe20418a599ea (diff)
libbtrfsutil: use top=0 as default for SubvolumeIterator()
Right now, we're defaulting to top=5 (i.e, all subvolumes). The documented default is top=0 (i.e, only beneath the given path). This is the expected behavior. Fix it and make the test cases cover it. Reported-by: Jonathan Lemon <bsd@fb.com> Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'libbtrfsutil')
-rw-r--r--libbtrfsutil/python/subvolume.c2
-rw-r--r--libbtrfsutil/python/tests/test_subvolume.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/libbtrfsutil/python/subvolume.c b/libbtrfsutil/python/subvolume.c
index 069e606..6ecde1f 100644
--- a/libbtrfsutil/python/subvolume.c
+++ b/libbtrfsutil/python/subvolume.c
@@ -525,7 +525,7 @@ static int SubvolumeIterator_init(SubvolumeIterator *self, PyObject *args,
static char *keywords[] = {"path", "top", "info", "post_order", NULL};
struct path_arg path = {.allow_fd = true};
enum btrfs_util_error err;
- unsigned long long top = 5;
+ unsigned long long top = 0;
int info = 0;
int post_order = 0;
int flags = 0;
diff --git a/libbtrfsutil/python/tests/test_subvolume.py b/libbtrfsutil/python/tests/test_subvolume.py
index 93396cb..0788a56 100644
--- a/libbtrfsutil/python/tests/test_subvolume.py
+++ b/libbtrfsutil/python/tests/test_subvolume.py
@@ -353,6 +353,7 @@ class TestSubvolume(BtrfsTestCase):
with self.subTest(type=type(arg)):
self.assertEqual(list(btrfsutil.SubvolumeIterator(arg)), subvols)
self.assertEqual(list(btrfsutil.SubvolumeIterator('.', top=0)), subvols)
+ self.assertEqual(list(btrfsutil.SubvolumeIterator('foo', top=5)), subvols)
self.assertEqual(list(btrfsutil.SubvolumeIterator('.', post_order=True)),
[('foo/bar/baz', 258),
@@ -365,6 +366,7 @@ class TestSubvolume(BtrfsTestCase):
]
self.assertEqual(list(btrfsutil.SubvolumeIterator('.', top=256)), subvols)
+ self.assertEqual(list(btrfsutil.SubvolumeIterator('foo')), subvols)
self.assertEqual(list(btrfsutil.SubvolumeIterator('foo', top=0)), subvols)
os.rename('foo/bar/baz', 'baz')