Skip to content

Fix parsing subvolumes with spaces in name #1116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboole
gchar const * const pattern = "ID\\s+(?P<id>\\d+)\\s+gen\\s+\\d+\\s+(cgen\\s+\\d+\\s+)?" \
"parent\\s+(?P<parent_id>\\d+)\\s+top\\s+level\\s+\\d+\\s+" \
"(otime\\s+(\\d{4}-\\d{2}-\\d{2}\\s+\\d\\d:\\d\\d:\\d\\d|-)\\s+)?"\
"path\\s+(<FS_TREE>/)?(?P<path>\\S+)";
"path\\s+(<FS_TREE>/)?(?P<path>.+)";
GRegex *regex = NULL;
GMatchInfo *match_info = NULL;
guint64 i = 0;
Expand Down
7 changes: 7 additions & 0 deletions tests/btrfs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ def test_list_subvolumes(self):
self.assertEqual(subvols[0].path, "subvol1")
self.assertEqual(subvols[1].path, "subvol1/bar")

# test also subvolumes with spaces in name
succ = BlockDev.btrfs_create_subvolume(TEST_MNT, "subvol with spaces", None)
self.assertTrue(succ)

subvols = BlockDev.btrfs_list_subvolumes(TEST_MNT, False)
self.assertTrue(any(subvol.path == "subvol with spaces" for subvol in subvols))

@tag_test(TestTags.CORE)
def test_list_subvolumes_different_mount(self):
"""Verify that it is possible get to info about subvolumes with subvol= mount option"""
Expand Down