From 4ef51d4e34d151de56d18cf3f67cb3429d063835 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Thu, 23 Aug 2012 16:27:33 -0400 Subject: [PATCH] Add support for creating exFAT filesystems and changing exFAT labels Tested with the exFAT userspace utilities available from http://code.google.com/p/exfat/ Signed-off-by: David Zeuthen --- src/udiskslinuxblock.c | 4 ++-- src/udiskslinuxfsinfo.c | 50 +++++++++++++++++++++++++++++++++++-------------- src/udiskslinuxfsinfo.h | 2 ++ udisks/udisksclient.c | 2 ++ 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c index 0db40cd..18402b5 100644 --- a/src/udiskslinuxblock.c +++ b/src/udiskslinuxblock.c @@ -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"; diff --git a/src/udiskslinuxfsinfo.c b/src/udiskslinuxfsinfo.c index 430f2a9..28b1ae5 100644 --- a/src/udiskslinuxfsinfo.c +++ b/src/udiskslinuxfsinfo.c @@ -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", }, }; diff --git a/src/udiskslinuxfsinfo.h b/src/udiskslinuxfsinfo.h index 70bba1e..9f4b272 100644 --- a/src/udiskslinuxfsinfo.h +++ b/src/udiskslinuxfsinfo.h @@ -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; diff --git a/udisks/udisksclient.c b/udisks/udisksclient.c index 7edec8d..4877d66 100644 --- a/udisks/udisksclient.c +++ b/udisks/udisksclient.c @@ -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")}, -- 2.7.4