Add support for creating exFAT filesystems and changing exFAT labels
authorDavid Zeuthen <zeuthen@gmail.com>
Thu, 23 Aug 2012 20:27:33 +0000 (16:27 -0400)
committerDavid Zeuthen <zeuthen@gmail.com>
Thu, 23 Aug 2012 20:29:51 +0000 (16:29 -0400)
Tested with the exFAT userspace utilities available from

 http://code.google.com/p/exfat/

Signed-off-by: David Zeuthen <zeuthen@gmail.com>
src/udiskslinuxblock.c
src/udiskslinuxfsinfo.c
src/udiskslinuxfsinfo.h
udisks/udisksclient.c

index 0db40cd..18402b5 100644 (file)
@@ -2239,8 +2239,8 @@ handle_format (UDisksBlock           *block,
       goto out;
     }
 
-  /* Change overship, if requested */
-  if (take_ownership)
+  /* Change overship, if requested and supported */
+  if (take_ownership && fs_info->supports_owners)
     {
       gchar tos_dir[256] = PACKAGE_LOCALSTATE_DIR "/run/udisks2/block-format-tos-XXXXXX";
 
index 430f2a9..28b1ae5 100644 (file)
@@ -31,70 +31,88 @@ const FSInfo _fs_info[] =
       "ext2",
       "e2label $DEVICE $LABEL",
       NULL,
-      TRUE,
+      TRUE,  /* supports_online_label_rename */
+      TRUE,  /* supports_owners */
       "mkfs.ext2 -F -L $LABEL $DEVICE",
     },
     {
       "ext3",
       "e2label $DEVICE $LABEL",
       NULL,
-      TRUE,
+      TRUE,  /* supports_online_label_rename */
+      TRUE,  /* supports_owners */
       "mkfs.ext3 -F -L $LABEL $DEVICE",
     },
     {
       "ext4",
       "e2label $DEVICE $LABEL",
       NULL,
-      TRUE,
+      TRUE,  /* supports_online_label_rename */
+      TRUE,  /* supports_owners */
       "mkfs.ext4 -F -L $LABEL $DEVICE",
     },
     {
       "vfat",
       "mlabel -i $DEVICE ::$LABEL",
       "mlabel -i $DEVICE -c ::",
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
       "mkfs.vfat -I -n $LABEL $DEVICE",
     },
     {
       "ntfs",
       "ntfslabel $DEVICE $LABEL",
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
       "mkntfs -f -F -L $LABEL $DEVICE",
     },
     {
+      "exfat",
+      "exfatlabel $DEVICE $LABEL",
+      NULL,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
+      "mkexfatfs -n $LABEL $DEVICE",
+    },
+    {
       "xfs",
       "xfs_admin -L $LABEL $DEVICE",
       "xfs_admin -L -- $DEVICE",
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      TRUE,  /* supports_owners */
       "mkfs.xfs -f -L $LABEL $DEVICE",
     },
     {
       "reiserfs",
       "reiserfstune -l $LABEL $DEVICE",
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      TRUE,  /* supports_owners */
       "mkfs.reiserfs -q -l $LABEL $DEVICE",
     },
     {
       "nilfs2",
       "nilfs-tune -L $LABEL $DEVICE",
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      TRUE,  /* supports_owners */
       "mkfs.nilfs2 -L $LABEL $DEVICE",
     },
     {
       "btrfs",
       NULL,
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      TRUE,  /* supports_owners */
       "mkfs.btrfs -L $LABEL $DEVICE",
     },
     {
       "minix",
       NULL,
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
       "mkfs.minix $DEVICE",
     },
     /* swap space */
@@ -102,7 +120,8 @@ const FSInfo _fs_info[] =
       "swap",
       NULL,
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
       "mkswap -L $LABEL $DEVICE",
     },
     /* partition tables */
@@ -110,14 +129,16 @@ const FSInfo _fs_info[] =
       "dos",
       NULL,
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
       "parted --script $DEVICE mktable msdos",
     },
     {
       "gpt",
       NULL,
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
       "parted --script $DEVICE mktable gpt",
     },
     /* empty */
@@ -125,7 +146,8 @@ const FSInfo _fs_info[] =
       "empty",
       NULL,
       NULL,
-      FALSE,
+      FALSE, /* supports_online_label_rename */
+      FALSE, /* supports_owners */
       "wipefs --all $DEVICE",
     },
   };
index 70bba1e..9f4b272 100644 (file)
@@ -30,7 +30,9 @@ typedef struct
   const gchar *fstype;
   const gchar *command_change_label; /* should have $DEVICE and $LABEL */
   const gchar *command_clear_label; /* should have $DEVICE; if NULL, call command_change_label with $LABEL == '' */
+  /* TODO: use flags or bitfields */
   gboolean     supports_online_label_rename;
+  gboolean     supports_owners;
   const gchar *command_create_fs;  /* should have $DEVICE and $LABEL */
 } FSInfo;
 
index 7edec8d..4877d66 100644 (file)
@@ -2158,6 +2158,8 @@ static const struct
   {"filesystem", "iso9660",           NULL,    NC_("fs-type", "ISO 9660"),                          NC_("fs-type", "ISO9660")},
   {"filesystem", "udf",               "*",     NC_("fs-type", "UDF (version %s)"),                  NC_("fs-type", "UDF")},
   {"filesystem", "udf",               NULL,    NC_("fs-type", "UDF"),                               NC_("fs-type", "UDF")},
+  {"filesystem", "exfat",             NULL,    NC_("fs-type", "exFAT"),                             NC_("fs-type", "exFAT")},
+  {"filesystem", "exfat",             "*",     NC_("fs-type", "exFAT (version %s)"),                NC_("fs-type", "exFAT")},
   {"other",      "swap",              "*",     NC_("fs-type", "Swap (version %s)"),                 NC_("fs-type", "Swap")},
   {"other",      "swap",              NULL,    NC_("fs-type", "Swap"),                              NC_("fs-type", "Swap")},
   {"raid",       "LVM2_member",       "*",     NC_("fs-type", "LVM2 Physical Volume (%s)"),         NC_("fs-type", "LVM2 PV")},