Bug 26258 — initial btrfs support
authorMartin Pitt <martin.pitt@ubuntu.com>
Sun, 15 Aug 2010 15:34:34 +0000 (17:34 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Sun, 15 Aug 2010 15:34:34 +0000 (17:34 +0200)
Add basic support for creating and checking btrfs. This does not yet support
spanning multiple devices, RAID, etc.

We disable online fsck for now. It works, but is said to be too unstable still.

Also bump the size of the loop devices in the test suite, since btrfs needs at
least 256 MB.

src/daemon.c
src/helpers/job-mkfs.c
tests/run

index a5f34ee..dbd55b6 100644 (file)
@@ -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 */
+      FALSE, /* 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 */
index 62cdfff..e363484 100644 (file)
@@ -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)
     {
 
index 780fd2c..57121b0 100755 (executable)
--- 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 = 160000000 # 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')
@@ -571,8 +575,8 @@ class FS(UDisksTestCase):
                 self.assertEqual(fs[3], type != 'swap') # can_mount
                 self.assert_(fs[4]) # can_create
                 supports_label_rename = fs[6]
-                # minix does not support labels; EXFAIL: swap and nilfs2 don't have a program for it
-                self.assertEqual(supports_label_rename, type not in ('nilfs2', 'minix', 'swap'))
+                # minix does not support labels; EXFAIL: swap, btrfs, nilfs2 don't have a program for it
+                self.assertEqual(supports_label_rename, type not in ('nilfs2', 'btrfs', 'minix', 'swap'))
                 break
         else:
             self.fail('KnownFilesystems does not contain ' + type)