From a1d9494954bc564d6f910e1748f75ff9f9607ac4 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 15 Jun 2010 15:28:22 +0200 Subject: [PATCH] =?UTF-8?q?Bug=2026258=20=E2=80=94=20initial=20btrfs=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add basic support for creating and checking btrfs. This does not yet support spanning multiple devices, RAID, etc. Also bump the size of the loop devices in the test suite, since btrfs needs at least 256 MB. --- src/daemon.c | 16 ++++++++++++++++ src/helpers/job-mkfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tests/run | 9 +++++++-- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index 87420e1..1f29f82 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -309,6 +309,22 @@ static const Filesystem known_file_systems[] = TRUE, /* supports_online_resize_shrink */ }, { + "btrfs", /* id */ + "BTRFS", /* name */ + TRUE, /* supports_unix_owners */ + TRUE, /* can_mount */ + TRUE, /* can_create */ + 16, /* max_label_len */ + FALSE, /* supports_label_rename; TODO: this still needs a tool */ + FALSE, /* supports_online_label_rename*/ + TRUE, /* supports_fsck */ + TRUE, /* supports_online_fsck */ + TRUE, /* supports_resize_enlarge */ + FALSE, /* supports_online_resize_enlarge */ + TRUE, /* supports_resize_shrink */ + FALSE, /* supports_online_resize_shrink */ + }, + { "xfs", /* id */ "XFS", /* name */ TRUE, /* supports_unix_owners */ diff --git a/src/helpers/job-mkfs.c b/src/helpers/job-mkfs.c index 8e4dce2..bd817ac 100644 --- a/src/helpers/job-mkfs.c +++ b/src/helpers/job-mkfs.c @@ -179,6 +179,52 @@ main (int argc, command_line = g_string_free (s, FALSE); } + else if (strcmp (fstype, "btrfs") == 0) + { + + s = g_string_new ("mkfs.btrfs"); + for (n = 0; options[n] != NULL; n++) + { + if (g_str_has_prefix (options[n], "label=")) + { + label = strdup (options[n] + sizeof("label=") - 1); + if (!validate_and_escape_label (&label, 12)) + { + g_string_free (s, TRUE); + goto out; + } + g_string_append_printf (s, " -L \"%s\"", label); + g_free (label); + label = NULL; + } + else if (g_str_has_prefix (options[n], "take_ownership_uid=")) + { + take_ownership_uid = strtol (options[n] + sizeof("take_ownership_uid=") - 1, &endp, 10); + if (endp == NULL || *endp != '\0') + { + g_printerr ("option %s is malformed\n", options[n]); + goto out; + } + } + else if (g_str_has_prefix (options[n], "take_ownership_gid=")) + { + take_ownership_gid = strtol (options[n] + sizeof("take_ownership_gid=") - 1, &endp, 10); + if (endp == NULL || *endp != '\0') + { + g_printerr ("option %s is malformed\n", options[n]); + goto out; + } + } + else + { + g_printerr ("option %s not supported\n", options[n]); + goto out; + } + } + g_string_append_printf (s, " %s", device); + command_line = g_string_free (s, FALSE); + + } else if (strcmp (fstype, "xfs") == 0) { diff --git a/tests/run b/tests/run index 420d39e..dc1b780 100755 --- a/tests/run +++ b/tests/run @@ -46,7 +46,7 @@ import optparse import re NUM_VDEV = 3 # number of virtual test devices that we need -VDEV_SIZE = 60000000 # size of virtual test devices +VDEV_SIZE = 300000000 # size of virtual test devices test_md_dev = '/dev/md125' # Those file systems are known to have a broken handling of permissions, in @@ -441,6 +441,10 @@ class FS(UDisksTestCase): '''fs: ext4''' self._do_fs_check('ext4') + def test_btrfs(self): + '''fs: btrfs''' + self._do_fs_check('btrfs') + def test_minix(self): '''fs: minix''' self._do_fs_check('minix') @@ -568,7 +572,8 @@ class FS(UDisksTestCase): self.assert_(fs[4]) # can_create supports_label_rename = fs[6] # minix does not support labels; EXFAIL: swap doesn't have a program for it - self.assertEqual(supports_label_rename, type not in ('minix', 'swap')) + # EXFAIL: btrfs does not seem to have a label change program yet + self.assertEqual(supports_label_rename, type not in ('minix', 'swap', 'btrfs')) break else: self.fail('KnownFilesystems does not contain ' + type) -- 1.7.0.4