Add Partition{,Table} interfaces and rely on blkid(8) partition properties
authorDavid Zeuthen <davidz@redhat.com>
Fri, 21 Oct 2011 19:12:23 +0000 (15:12 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Fri, 21 Oct 2011 19:12:23 +0000 (15:12 -0400)
Signed-off-by: David Zeuthen <davidz@redhat.com>
16 files changed:
data/org.freedesktop.UDisks2.xml
doc/udisks2-docs.xml
doc/udisks2-sections.txt
doc/udisks2.types
src/Makefile.am
src/udisksdaemontypes.h
src/udiskslinuxblock.c
src/udiskslinuxblockobject.c
src/udiskslinuxpartition.c [new file with mode: 0644]
src/udiskslinuxpartition.h [new file with mode: 0644]
src/udiskslinuxpartitiontable.c [new file with mode: 0644]
src/udiskslinuxpartitiontable.h [new file with mode: 0644]
tools/udisksctl.c
udisks/udisksclient.c
udisks/udisksclient.h
udisks/udisksutil.c

index a93b669..51b4790 100644 (file)
     -->
     <property name="HintIconName" type="s" access="read"/>
 
-    <!-- PartTable: Set to %TRUE if a partition table signature was detected on the device. -->
-    <property name="PartTable" type="b" access="read"/>
-    <!-- PartTableScheme: The type of partition table detected.
-         Known values include <literal>mbr</literal> (for <ulink
-         url="http://en.wikipedia.org/wiki/Master_Boot_Record">Master
-         Boot Record</ulink>), <literal>gpt</literal> (for <ulink
-         url="http://en.wikipedia.org/wiki/GUID_Partition_Table">GUID
-         Partition Table</ulink>) and <literal>apm</literal> (for
-         <ulink
-         url="http://en.wikipedia.org/wiki/Apple_Partition_Map">Apple
-         Partition Map</ulink>). If blank, and
-         #org.freedesktop.UDisks2.Block:PartTable is %TRUE, a
-         partition table was detected but its scheme is unknown.
-    -->
-    <property name="PartTableScheme" type="s" access="read"/>
-
-    <!-- PartEntry: Set to %TRUE if the block device represents a partition. -->
-    <property name="PartEntry" type="b" access="read"/>
-    <!-- PartEntryNumber: The number of the partition in the partition table. -->
-    <property name="PartEntryNumber" type="u" access="read"/>
-    <!-- PartEntryScheme: The partition table scheme or blank if unknown.
-         See the #org.freedesktop.UDisks2.Block:PartTable property for known schemes.
-    -->
-    <property name="PartEntryScheme" type="s" access="read"/>
-    <!-- PartEntryType: The type of the partition. -->
-    <property name="PartEntryType" type="s" access="read"/>
-    <!-- PartEntryFlags: Partition flags, e.g. <literal>boot</literal>. -->
-    <property name="PartEntryFlags" type="s" access="read"/>
-    <!-- PartEntryOffset: Offset of partition. -->
-    <property name="PartEntryOffset" type="t" access="read"/>
-    <!-- PartEntrySize: Size of partition. -->
-    <property name="PartEntrySize" type="t" access="read"/>
-    <!-- PartEntryLabel: Label of partition or blank if not supported or unknown. -->
-    <property name="PartEntryLabel" type="ay" access="read"/>
-    <!-- PartEntryUUID: The UUID of the partition or blank if not supported or unknown. -->
-    <property name="PartEntryUUID" type="ay" access="read"/>
-    <!-- PartEntryTable:
-         The object path of the #org.freedesktop.UDisks2.Block
-         partition table that the partition entry belongs to or
-         <literal>/</literal> if the device is not a partition.
-    -->
-    <property name="PartEntryTable" type="o" access="read"/>
-
     <!--
         AddConfigurationItem:
         @item: The configuration item to add.
   <!-- ********************************************************************** -->
 
   <!--
+      org.freedesktop.UDisks2.PartitionTable:
+      @short_description: Block device containing a partition table
+
+      This interface is used for #org.freedesktop.UDisks2.Block
+      devices that contain a partition table.
+  -->
+  <interface name="org.freedesktop.UDisks2.PartitionTable">
+    <!-- prereq: org.freedesktop.UDisks2.Block -->
+
+    <!-- Type: The type of partition table detected.
+         Known values include:
+         <variablelist>
+           <varlistentry><term>dos</term><listitem><para><ulink url="http://en.wikipedia.org/wiki/Master_Boot_Record">Master Boot Record</ulink></para></listitem></varlistentry>
+           <varlistentry><term>gpt</term><listitem><para><ulink url="http://en.wikipedia.org/wiki/GUID_Partition_Table">GUID Partition Table</ulink></para></listitem></varlistentry>
+         </variablelist>
+         If blank it means that a partition table was detected but its
+         scheme is unknown.
+    -->
+    <property name="Type" type="s" access="read"/>
+  </interface>
+
+  <!-- ********************************************************************** -->
+
+  <!--
+      org.freedesktop.UDisks2.Partition:
+      @short_description: Block device representing a partition
+
+      This interface is used for #org.freedesktop.UDisks2.Block
+      devices that represent entries in a partition table.
+  -->
+  <interface name="org.freedesktop.UDisks2.Partition">
+    <!-- prereq: org.freedesktop.UDisks2.Block -->
+
+    <!-- Number: The number of the partition in the partition table. -->
+    <property name="Number" type="u" access="read"/>
+
+    <!-- Type: The type of the partition. -->
+    <property name="Type" type="s" access="read"/>
+
+    <!-- Flags: Partition flags, e.g. <literal>boot</literal>. -->
+    <property name="Flags" type="s" access="read"/>
+
+    <!-- Offset: Offset of partition. -->
+    <property name="Offset" type="t" access="read"/>
+
+    <!-- Size: Size of partition. -->
+    <property name="Size" type="t" access="read"/>
+
+    <!-- Name: Label of partition or blank if not supported or unknown. -->
+    <property name="Name" type="ay" access="read"/>
+
+    <!-- UUID: The UUID of the partition or blank if not supported or unknown. -->
+    <property name="UUID" type="ay" access="read"/>
+
+    <!-- Table:
+         The object path of the #org.freedesktop.UDisks2.PartitionTable
+         object that the partition entry belongs to.
+    -->
+    <property name="Table" type="o" access="read"/>
+  </interface>
+
+  <!-- ********************************************************************** -->
+
+  <!--
       org.freedesktop.UDisks2.Filesystem:
       @short_description: Block device containing a mountable filesystem
 
index 863c448..519d34d 100644 (file)
       <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.Drive.xml"/>
       <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.Drive.Ata.xml"/>
       <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.Block.xml"/>
+      <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.Partition.xml"/>
+      <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.PartitionTable.xml"/>
       <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.Filesystem.xml"/>
       <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.Swapspace.xml"/>
       <xi:include href="../udisks/udisks-generated-doc-org.freedesktop.UDisks2.Encrypted.xml"/>
       <xi:include href="xml/UDisksDriveAta.xml"/>
       <xi:include href="xml/UDisksJob.xml"/>
       <xi:include href="xml/UDisksBlock.xml"/>
+      <xi:include href="xml/UDisksPartition.xml"/>
+      <xi:include href="xml/UDisksPartitionTable.xml"/>
       <xi:include href="xml/UDisksFilesystem.xml"/>
       <xi:include href="xml/UDisksSwapspace.xml"/>
       <xi:include href="xml/UDisksEncrypted.xml"/>
     <chapter id="ref-daemon-block-devices">
       <title>Block devices on Linux</title>
       <xi:include href="xml/udiskslinuxblock.xml"/>
+      <xi:include href="xml/udiskslinuxpartition.xml"/>
+      <xi:include href="xml/udiskslinuxpartitiontable.xml"/>
       <xi:include href="xml/udiskslinuxfilesystem.xml"/>
       <xi:include href="xml/udiskslinuxencrypted.xml"/>
       <xi:include href="xml/udiskslinuxswapspace.xml"/>
index f41da3a..ecd08bb 100644 (file)
@@ -48,6 +48,7 @@ udisks_client_get_block_for_dev
 udisks_client_get_block_for_drive
 udisks_client_get_drive_for_block
 udisks_client_get_cleartext_block
+udisks_client_get_partition_table
 <SUBSECTION Standard>
 UDISKS_TYPE_CLIENT
 UDISKS_CLIENT
@@ -415,6 +416,8 @@ udisks_object_get_swapspace
 udisks_object_get_encrypted
 udisks_object_get_loop
 udisks_object_get_manager
+udisks_object_get_partition
+udisks_object_get_partition_table
 udisks_object_peek_block
 udisks_object_peek_drive
 udisks_object_peek_drive_ata
@@ -424,6 +427,8 @@ udisks_object_peek_swapspace
 udisks_object_peek_encrypted
 udisks_object_peek_loop
 udisks_object_peek_manager
+udisks_object_peek_partition
+udisks_object_peek_partition_table
 UDisksObjectProxy
 UDisksObjectProxyClass
 udisks_object_proxy_new
@@ -439,6 +444,8 @@ udisks_object_skeleton_set_swapspace
 udisks_object_skeleton_set_encrypted
 udisks_object_skeleton_set_loop
 udisks_object_skeleton_set_manager
+udisks_object_skeleton_set_partition
+udisks_object_skeleton_set_partition_table
 <SUBSECTION Standard>
 udisks_object_get_type
 udisks_object_proxy_get_type
@@ -1169,3 +1176,135 @@ UDISKS_IS_CRYPTTAB_MONITOR
 udisks_crypttab_entry_get_type
 udisks_crypttab_monitor_get_type
 </SECTION>
+
+<SECTION>
+<FILE>UDisksPartition</FILE>
+UDisksPartition
+UDisksPartitionIface
+udisks_partition_interface_info
+udisks_partition_override_properties
+udisks_partition_get_number
+udisks_partition_get_type_
+udisks_partition_get_offset
+udisks_partition_get_size
+udisks_partition_get_flags
+udisks_partition_get_name
+udisks_partition_get_uuid
+udisks_partition_get_table
+udisks_partition_dup_type_
+udisks_partition_dup_flags
+udisks_partition_dup_name
+udisks_partition_dup_uuid
+udisks_partition_dup_table
+udisks_partition_set_flags
+udisks_partition_set_name
+udisks_partition_set_number
+udisks_partition_set_offset
+udisks_partition_set_size
+udisks_partition_set_table
+udisks_partition_set_type_
+udisks_partition_set_uuid
+UDisksPartitionProxy
+UDisksPartitionProxyClass
+udisks_partition_proxy_new
+udisks_partition_proxy_new_finish
+udisks_partition_proxy_new_sync
+udisks_partition_proxy_new_for_bus
+udisks_partition_proxy_new_for_bus_finish
+udisks_partition_proxy_new_for_bus_sync
+UDisksPartitionSkeleton
+UDisksPartitionSkeletonClass
+udisks_partition_skeleton_new
+<SUBSECTION Standard>
+UDISKS_TYPE_PARTITION
+UDISKS_IS_PARTITION
+UDISKS_PARTITION
+UDISKS_PARTITION_GET_IFACE
+UDISKS_TYPE_PARTITION_PROXY
+UDISKS_IS_PARTITION_PROXY
+UDISKS_IS_PARTITION_PROXY_CLASS
+UDISKS_PARTITION_PROXY
+UDISKS_PARTITION_PROXY_CLASS
+UDISKS_PARTITION_PROXY_GET_CLASS
+UDISKS_TYPE_PARTITION_SKELETON
+UDISKS_IS_PARTITION_SKELETON
+UDISKS_IS_PARTITION_SKELETON_CLASS
+UDISKS_PARTITION_SKELETON
+UDISKS_PARTITION_SKELETON_CLASS
+UDISKS_PARTITION_SKELETON_GET_CLASS
+UDisksPartitionProxyPrivate
+UDisksPartitionSkeletonPrivate
+udisks_partition_get_type
+udisks_partition_proxy_get_type
+udisks_partition_skeleton_get_type
+</SECTION>
+
+<SECTION>
+<FILE>UDisksPartitionTable</FILE>
+UDisksPartitionTable
+UDisksPartitionTableIface
+udisks_partition_table_interface_info
+udisks_partition_table_override_properties
+udisks_partition_table_get_type_
+udisks_partition_table_dup_type_
+udisks_partition_table_set_type_
+UDisksPartitionTableProxy
+UDisksPartitionTableProxyClass
+udisks_partition_table_proxy_new
+udisks_partition_table_proxy_new_finish
+udisks_partition_table_proxy_new_sync
+udisks_partition_table_proxy_new_for_bus
+udisks_partition_table_proxy_new_for_bus_finish
+udisks_partition_table_proxy_new_for_bus_sync
+UDisksPartitionTableSkeleton
+UDisksPartitionTableSkeletonClass
+udisks_partition_table_skeleton_new
+<SUBSECTION Standard>
+UDISKS_TYPE_PARTITION_TABLE
+UDISKS_IS_PARTITION_TABLE
+UDISKS_PARTITION_TABLE
+UDISKS_PARTITION_TABLE_GET_IFACE
+UDISKS_TYPE_PARTITION_TABLE_PROXY
+UDISKS_IS_PARTITION_TABLE_PROXY
+UDISKS_IS_PARTITION_TABLE_PROXY_CLASS
+UDISKS_PARTITION_TABLE_PROXY
+UDISKS_PARTITION_TABLE_PROXY_CLASS
+UDISKS_PARTITION_TABLE_PROXY_GET_CLASS
+UDISKS_TYPE_PARTITION_TABLE_SKELETON
+UDISKS_IS_PARTITION_TABLE_SKELETON
+UDISKS_IS_PARTITION_TABLE_SKELETON_CLASS
+UDISKS_PARTITION_TABLE_SKELETON
+UDISKS_PARTITION_TABLE_SKELETON_CLASS
+UDISKS_PARTITION_TABLE_SKELETON_GET_CLASS
+UDisksPartitionTableProxyPrivate
+UDisksPartitionTableSkeletonPrivate
+udisks_partition_table_get_type
+udisks_partition_table_proxy_get_type
+udisks_partition_table_skeleton_get_type
+</SECTION>
+
+<SECTION>
+<FILE>udiskslinuxpartition</FILE>
+UDisksLinuxPartition
+udisks_linux_partition_new
+udisks_linux_partition_update
+<SUBSECTION Standard>
+UDISKS_LINUX_PARTITION
+UDISKS_IS_LINUX_PARTITION
+UDISKS_TYPE_LINUX_PARTITION
+<SUBSECTION Private>
+udisks_linux_partition_get_type
+</SECTION>
+
+<SECTION>
+<FILE>udiskslinuxpartitiontable</FILE>
+UDisksLinuxPartitionTable
+udisks_linux_partition_table_new
+udisks_linux_partition_table_update
+<SUBSECTION Standard>
+UDISKS_LINUX_PARTITION_TABLE
+UDISKS_IS_LINUX_PARTITION_TABLE
+UDISKS_TYPE_LINUX_PARTITION_TABLE
+<SUBSECTION Private>
+udisks_linux_partition_table_get_type
+</SECTION>
index 403b631..03fb89f 100644 (file)
@@ -16,6 +16,8 @@ udisks_provider_get_type
 udisks_linux_provider_get_type
 udisks_persistent_store_get_type
 udisks_linux_filesystem_get_type
+udisks_linux_partition_get_type
+udisks_linux_partition_table_get_type
 udisks_linux_encrypted_get_type
 udisks_linux_swapspace_get_type
 udisks_linux_loop_get_type
index 01faace..2b57111 100644 (file)
@@ -49,6 +49,8 @@ libudisks_daemon_la_SOURCES =                                         \
        udiskslinuxprovider.h           udiskslinuxprovider.c           \
        udiskslinuxblockobject.h        udiskslinuxblockobject.c        \
        udiskslinuxblock.h              udiskslinuxblock.c              \
+       udiskslinuxpartition.h          udiskslinuxpartition.c          \
+       udiskslinuxpartitiontable.h     udiskslinuxpartitiontable.c     \
        udiskslinuxfilesystem.h         udiskslinuxfilesystem.c         \
        udiskslinuxencrypted.h          udiskslinuxencrypted.c          \
        udiskslinuxswapspace.h          udiskslinuxswapspace.c          \
index 86238a9..a00e343 100644 (file)
@@ -97,6 +97,12 @@ typedef struct _UDisksCrypttabMonitor UDisksCrypttabMonitor;
 struct _UDisksCrypttabEntry;
 typedef struct _UDisksCrypttabEntry UDisksCrypttabEntry;
 
+struct _UDisksLinuxPartition;
+typedef struct _UDisksLinuxPartition UDisksLinuxPartition;
+
+struct _UDisksLinuxPartitionTable;
+typedef struct _UDisksLinuxPartitionTable UDisksLinuxPartitionTable;
+
 /**
  * UDisksThreadedJobFunc:
  * @job: A #UDisksThreadedJob.
index e3f3128..2535d71 100644 (file)
@@ -590,8 +590,6 @@ udisks_linux_block_update (UDisksLinuxBlock        *block,
   gchar *drive_object_path;
   UDisksDrive *drive;
   gchar *s;
-  gboolean is_partition_table;
-  gboolean is_partition_entry;
   const gchar *device_file;
   const gchar *const *symlinks;
   const gchar *preferred_device_file;
@@ -721,107 +719,6 @@ udisks_linux_block_update (UDisksLinuxBlock        *block,
   udisks_block_set_id_uuid (iface, s);
   g_free (s);
 
-  /* TODO: port this to blkid properties */
-
-  /* Update the partition table and partition entry properties */
-  is_partition_table = FALSE;
-  is_partition_entry = FALSE;
-  if (g_strcmp0 (g_udev_device_get_devtype (device), "partition") == 0 ||
-      g_udev_device_get_property_as_boolean (device, "UDISKS_PARTITION"))
-    {
-      is_partition_entry = TRUE;
-    }
-  else if (g_udev_device_get_property_as_boolean (device, "UDISKS_PARTITION_TABLE"))
-    {
-      is_partition_table = TRUE;
-    }
-
-  /* partition table */
-  if (is_partition_table)
-    {
-      udisks_block_set_part_table (iface, TRUE);
-      udisks_block_set_part_table_scheme (iface,
-                                          g_udev_device_get_property (device,
-                                                                      "UDISKS_PARTITION_TABLE_SCHEME"));
-    }
-  else
-    {
-      udisks_block_set_part_table (iface, FALSE);
-      udisks_block_set_part_table_scheme (iface, "");
-    }
-
-  /* partition entry */
-  if (is_partition_entry)
-    {
-      gchar *slave_sysfs_path;
-      udisks_block_set_part_entry (iface, TRUE);
-      udisks_block_set_part_entry_scheme (iface,
-                                          g_udev_device_get_property (device,
-                                                                      "UDISKS_PARTITION_SCHEME"));
-      udisks_block_set_part_entry_number (iface,
-                                          g_udev_device_get_property_as_int (device,
-                                                                             "UDISKS_PARTITION_NUMBER"));
-      udisks_block_set_part_entry_type (iface,
-                                        g_udev_device_get_property (device,
-                                                                    "UDISKS_PARTITION_TYPE"));
-      udisks_block_set_part_entry_flags (iface,
-                                         g_udev_device_get_property (device,
-                                                                     "UDISKS_PARTITION_FLAGS"));
-      udisks_block_set_part_entry_label (iface,
-                                         g_udev_device_get_property (device,
-                                                                     "UDISKS_PARTITION_LABEL"));
-      udisks_block_set_part_entry_uuid (iface,
-                                        g_udev_device_get_property (device,
-                                                                    "UDISKS_PARTITION_UUID"));
-      slave_sysfs_path = g_strdup (g_udev_device_get_property (device, "UDISKS_PARTITION_SLAVE"));
-      if (slave_sysfs_path == NULL)
-        {
-          if (g_strcmp0 (g_udev_device_get_devtype (device), "partition") == 0)
-            {
-              GUdevDevice *parent;
-              parent = g_udev_device_get_parent (device);
-              slave_sysfs_path = g_strdup (g_udev_device_get_sysfs_path (parent));
-              g_object_unref (parent);
-            }
-          else
-            {
-              g_warning ("No UDISKS_PARTITION_SLAVE property and DEVTYPE is not partition for block device %s",
-                         g_udev_device_get_sysfs_path (device));
-            }
-        }
-      if (slave_sysfs_path != NULL)
-        {
-          gchar *slave_object_path;
-          slave_object_path = find_block_device_by_sysfs_path (object_manager, slave_sysfs_path);
-          if (slave_object_path != NULL)
-            udisks_block_set_part_entry_table (iface, slave_object_path);
-          else
-            udisks_block_set_part_entry_table (iface, "/");
-          g_free (slave_object_path);
-          g_free (slave_sysfs_path);
-        }
-      else
-        {
-          udisks_block_set_part_entry_table (iface, "/");
-        }
-      udisks_block_set_part_entry_offset (iface,
-                                          g_udev_device_get_property_as_uint64 (device,
-                                                                                "UDISKS_PARTITION_OFFSET"));
-      udisks_block_set_part_entry_size (iface,
-                                        g_udev_device_get_property_as_uint64 (device,
-                                                                              "UDISKS_PARTITION_SIZE"));
-    }
-  else
-    {
-      udisks_block_set_part_entry (iface, FALSE);
-      udisks_block_set_part_entry_scheme (iface, "");
-      udisks_block_set_part_entry_type (iface, "");
-      udisks_block_set_part_entry_flags (iface, "");
-      udisks_block_set_part_entry_table (iface, "/");
-      udisks_block_set_part_entry_offset (iface, 0);
-      udisks_block_set_part_entry_size (iface, 0);
-    }
-
   update_hints (block, device, drive);
   update_configuration (block, daemon);
 
index b173045..b786688 100644 (file)
@@ -43,6 +43,8 @@
 #include "udisksmountmonitor.h"
 #include "udiskslinuxdriveobject.h"
 #include "udiskslinuxdrive.h"
+#include "udiskslinuxpartitiontable.h"
+#include "udiskslinuxpartition.h"
 #include "udiskslinuxfilesystem.h"
 #include "udiskslinuxencrypted.h"
 #include "udiskslinuxswapspace.h"
@@ -81,6 +83,8 @@ struct _UDisksLinuxBlockObject
 
   /* interface */
   UDisksBlock *iface_block_device;
+  UDisksPartition *iface_partition;
+  UDisksPartitionTable *iface_partition_table;
   UDisksFilesystem *iface_filesystem;
   UDisksSwapspace *iface_swapspace;
   UDisksEncrypted *iface_encrypted;
@@ -121,6 +125,10 @@ udisks_linux_block_object_finalize (GObject *_object)
 
   if (object->iface_block_device != NULL)
     g_object_unref (object->iface_block_device);
+  if (object->iface_partition != NULL)
+    g_object_unref (object->iface_partition);
+  if (object->iface_partition_table != NULL)
+    g_object_unref (object->iface_partition_table);
   if (object->iface_filesystem != NULL)
     g_object_unref (object->iface_filesystem);
   if (object->iface_swapspace != NULL)
@@ -402,6 +410,114 @@ block_device_update (UDisksLinuxBlockObject *object,
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
+/* org.freedesktop.UDisks.PartitionTable */
+
+static gboolean
+partition_table_check (UDisksLinuxBlockObject *object)
+{
+  gboolean ret = FALSE;
+  GDir *dir = NULL;
+  const gchar *name;
+  const gchar *device_name;
+
+  /* only consider whole disks, never partitions */
+  if (g_strcmp0 (g_udev_device_get_devtype (object->device), "disk") != 0)
+    goto out;
+
+  /* if blkid(8) already identified the device as a partition table, it's all good */
+  if (g_udev_device_has_property (object->device, "ID_PART_TABLE_TYPE"))
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  /* Note that blkid(8) might not detect all partition table
+   * formats that the kernel knows about.... so we need to
+   * double check...
+   *
+   * Fortunately, note that the kernel guarantees that all children
+   * block devices that are partitions are created before the uevent
+   * for the parent block device.... so if the parent block device has
+   * children... then it must be partitioned by the kernel, hence it
+   * must contain a partition table.
+   */
+  dir = g_dir_open (g_udev_device_get_sysfs_path (object->device), 0 /* flags */, NULL /* GError */);
+  if (dir == NULL)
+    goto out;
+
+  device_name = g_udev_device_get_name (object->device);
+  while ((name = g_dir_read_name (dir)) != NULL)
+    {
+      /* TODO: could check that it's a block device - for now, just
+       * checking the name suffices
+       */
+      if (g_str_has_prefix (name, device_name))
+        {
+          ret = TRUE;
+          goto out;
+        }
+    }
+
+ out:
+  if (dir != NULL)
+    g_dir_close (dir);
+
+  return ret;
+}
+
+static void
+partition_table_connect (UDisksLinuxBlockObject *object)
+{
+}
+
+static void
+partition_table_update (UDisksLinuxBlockObject *object,
+                        const gchar            *uevent_action,
+                        GDBusInterface         *_iface)
+{
+  udisks_linux_partition_table_update (UDISKS_LINUX_PARTITION_TABLE (_iface), object);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+/* org.freedesktop.UDisks.Partition */
+
+static gboolean
+partition_check (UDisksLinuxBlockObject *object)
+{
+  gboolean ret = FALSE;
+
+  /* could be partitioned by the kernel */
+  if (g_strcmp0 (g_udev_device_get_devtype (object->device), "partition") == 0)
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  /* if blkid(8) already identified the device as a partition, it's all good */
+  if (g_udev_device_has_property (object->device, "ID_PART_ENTRY_SCHEME"))
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+ out:
+  return ret;
+}
+
+static void
+partition_connect (UDisksLinuxBlockObject *object)
+{
+}
+
+static void
+partition_update (UDisksLinuxBlockObject *object,
+                  const gchar            *uevent_action,
+                  GDBusInterface         *_iface)
+{
+  udisks_linux_partition_update (UDISKS_LINUX_PARTITION (_iface), object);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
 /* org.freedesktop.UDisks.Filesystem */
 
 static gboolean
@@ -580,6 +696,10 @@ udisks_linux_block_object_uevent (UDisksLinuxBlockObject *object,
                 UDISKS_TYPE_LINUX_ENCRYPTED, &object->iface_encrypted);
   update_iface (object, action, loop_check, loop_connect, loop_update,
                 UDISKS_TYPE_LINUX_LOOP, &object->iface_loop);
+  update_iface (object, action, partition_table_check, partition_table_connect, partition_table_update,
+                UDISKS_TYPE_LINUX_PARTITION_TABLE, &object->iface_partition_table);
+  update_iface (object, action, partition_check, partition_connect, partition_update,
+                UDISKS_TYPE_LINUX_PARTITION, &object->iface_partition);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/udiskslinuxpartition.c b/src/udiskslinuxpartition.c
new file mode 100644 (file)
index 0000000..fc9a699
--- /dev/null
@@ -0,0 +1,183 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2007-2010 David Zeuthen <zeuthen@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib/gstdio.h>
+
+#include "udiskslogging.h"
+#include "udiskslinuxpartition.h"
+#include "udiskslinuxblockobject.h"
+#include "udisksdaemon.h"
+#include "udiskscleanup.h"
+#include "udisksdaemonutil.h"
+
+/**
+ * SECTION:udiskslinuxpartition
+ * @title: UDisksLinuxPartition
+ * @short_description: Linux implementation of #UDisksPartition
+ *
+ * This type provides an implementation of the #UDisksPartition
+ * interface on Linux.
+ */
+
+typedef struct _UDisksLinuxPartitionClass   UDisksLinuxPartitionClass;
+
+/**
+ * UDisksLinuxPartition:
+ *
+ * The #UDisksLinuxPartition structure contains only private data and should
+ * only be accessed using the provided API.
+ */
+struct _UDisksLinuxPartition
+{
+  UDisksPartitionSkeleton parent_instance;
+};
+
+struct _UDisksLinuxPartitionClass
+{
+  UDisksPartitionSkeletonClass parent_class;
+};
+
+static void partition_iface_init (UDisksPartitionIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (UDisksLinuxPartition, udisks_linux_partition, UDISKS_TYPE_PARTITION_SKELETON,
+                         G_IMPLEMENT_INTERFACE (UDISKS_TYPE_PARTITION, partition_iface_init));
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+udisks_linux_partition_init (UDisksLinuxPartition *partition)
+{
+  g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (partition),
+                                       G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
+}
+
+static void
+udisks_linux_partition_class_init (UDisksLinuxPartitionClass *klass)
+{
+}
+
+/**
+ * udisks_linux_partition_new:
+ *
+ * Creates a new #UDisksLinuxPartition instance.
+ *
+ * Returns: A new #UDisksLinuxPartition. Free with g_object_unref().
+ */
+UDisksPartition *
+udisks_linux_partition_new (void)
+{
+  return UDISKS_PARTITION (g_object_new (UDISKS_TYPE_LINUX_PARTITION,
+                                         NULL));
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+/**
+ * udisks_linux_partition_update:
+ * @partition: A #UDisksLinuxPartition.
+ * @object: The enclosing #UDisksLinuxBlockObject instance.
+ *
+ * Updates the interface.
+ */
+void
+udisks_linux_partition_update (UDisksLinuxPartition  *partition,
+                               UDisksLinuxBlockObject     *object)
+{
+  UDisksObject *disk_block_object = NULL;
+  GUdevDevice *device = NULL;
+  guint number = 0;
+  const gchar *type = NULL;
+  guint64 offset = 0;
+  guint64 size = 0;
+  gchar *name = NULL;
+  const gchar *uuid = NULL;
+  const gchar *flags = NULL;
+  const gchar *table_object_path = "/";
+
+  device = udisks_linux_block_object_get_device (object);
+  if (g_udev_device_has_property (device, "ID_PART_ENTRY_TYPE"))
+    {
+      const gchar *disk_string;
+      number = g_udev_device_get_property_as_int (device, "ID_PART_ENTRY_NUMBER");
+      type = g_udev_device_get_property (device, "ID_PART_ENTRY_TYPE");
+      offset = g_udev_device_get_property_as_uint64 (device, "ID_PART_ENTRY_OFFSET") * G_GUINT64_CONSTANT (512);
+      size = g_udev_device_get_property_as_uint64 (device, "ID_PART_ENTRY_SIZE") * G_GUINT64_CONSTANT (512);
+      name = udisks_decode_udev_string (g_udev_device_get_property (device, "ID_PART_ENTRY_NAME"));
+      uuid = g_udev_device_get_property (device, "ID_PART_ENTRY_UUID");
+      flags = g_udev_device_get_property (device, "ID_PART_ENTRY_FLAGS");
+
+      disk_string = g_udev_device_get_property (device, "ID_PART_ENTRY_DISK");
+      if (disk_string != NULL)
+        {
+          gint disk_major, disk_minor;
+          if (sscanf (disk_string, "%d:%d", &disk_major, &disk_minor) == 2)
+            {
+              disk_block_object = udisks_daemon_find_block (udisks_linux_block_object_get_daemon (object),
+                                                            makedev (disk_major, disk_minor));
+            }
+        }
+    }
+  else
+    {
+      GUdevDevice *parent_device;
+      number = g_udev_device_get_sysfs_attr_as_int (device, "partition");
+      offset = g_udev_device_get_sysfs_attr_as_uint64 (device, "start") * G_GUINT64_CONSTANT (512);
+      size = g_udev_device_get_sysfs_attr_as_uint64 (device, "size") * G_GUINT64_CONSTANT (512);
+      parent_device = g_udev_device_get_parent_with_subsystem (device, "block", "disk");
+      if (parent_device != NULL)
+        {
+          disk_block_object = udisks_daemon_find_block (udisks_linux_block_object_get_daemon (object),
+                                                        g_udev_device_get_device_number (parent_device));
+          g_object_unref (parent_device);
+        }
+    }
+
+  if (disk_block_object != NULL)
+    table_object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (disk_block_object));
+
+  udisks_partition_set_number (UDISKS_PARTITION (partition), number);
+  udisks_partition_set_type_ (UDISKS_PARTITION (partition), type);
+  udisks_partition_set_flags (UDISKS_PARTITION (partition), flags);
+  udisks_partition_set_offset (UDISKS_PARTITION (partition), offset);
+  udisks_partition_set_size (UDISKS_PARTITION (partition), size);
+  udisks_partition_set_name (UDISKS_PARTITION (partition), name);
+  udisks_partition_set_uuid (UDISKS_PARTITION (partition), uuid);
+  udisks_partition_set_table (UDISKS_PARTITION (partition), table_object_path);
+
+  g_free (name);
+  g_clear_object (&device);
+  g_clear_object (&disk_block_object);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+partition_iface_init (UDisksPartitionIface *iface)
+{
+}
diff --git a/src/udiskslinuxpartition.h b/src/udiskslinuxpartition.h
new file mode 100644 (file)
index 0000000..fdb4e52
--- /dev/null
@@ -0,0 +1,39 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2007-2010 David Zeuthen <zeuthen@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __UDISKS_LINUX_PARTITION_H__
+#define __UDISKS_LINUX_PARTITION_H__
+
+#include "udisksdaemontypes.h"
+
+G_BEGIN_DECLS
+
+#define UDISKS_TYPE_LINUX_PARTITION  (udisks_linux_partition_get_type ())
+#define UDISKS_LINUX_PARTITION(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), UDISKS_TYPE_LINUX_PARTITION, UDisksLinuxPartition))
+#define UDISKS_IS_LINUX_PARTITION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UDISKS_TYPE_LINUX_PARTITION))
+
+GType            udisks_linux_partition_get_type (void) G_GNUC_CONST;
+UDisksPartition *udisks_linux_partition_new      (void);
+void             udisks_linux_partition_update   (UDisksLinuxPartition   *partition,
+                                                  UDisksLinuxBlockObject *object);
+
+G_END_DECLS
+
+#endif /* __UDISKS_LINUX_PARTITION_H__ */
diff --git a/src/udiskslinuxpartitiontable.c b/src/udiskslinuxpartitiontable.c
new file mode 100644 (file)
index 0000000..f52d2f2
--- /dev/null
@@ -0,0 +1,129 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2007-2010 David Zeuthen <zeuthen@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib/gstdio.h>
+
+#include "udiskslogging.h"
+#include "udiskslinuxpartitiontable.h"
+#include "udiskslinuxblockobject.h"
+#include "udisksdaemon.h"
+#include "udiskscleanup.h"
+#include "udisksdaemonutil.h"
+
+/**
+ * SECTION:udiskslinuxpartitiontable
+ * @title: UDisksLinuxPartitionTable
+ * @short_description: Linux implementation of #UDisksPartitionTable
+ *
+ * This type provides an implementation of the #UDisksPartitionTable
+ * interface on Linux.
+ */
+
+typedef struct _UDisksLinuxPartitionTableClass   UDisksLinuxPartitionTableClass;
+
+/**
+ * UDisksLinuxPartitionTable:
+ *
+ * The #UDisksLinuxPartitionTable structure contains only private data and should
+ * only be accessed using the provided API.
+ */
+struct _UDisksLinuxPartitionTable
+{
+  UDisksPartitionTableSkeleton parent_instance;
+};
+
+struct _UDisksLinuxPartitionTableClass
+{
+  UDisksPartitionTableSkeletonClass parent_class;
+};
+
+static void partition_table_iface_init (UDisksPartitionTableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (UDisksLinuxPartitionTable, udisks_linux_partition_table, UDISKS_TYPE_PARTITION_TABLE_SKELETON,
+                         G_IMPLEMENT_INTERFACE (UDISKS_TYPE_PARTITION_TABLE, partition_table_iface_init));
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+udisks_linux_partition_table_init (UDisksLinuxPartitionTable *partition_table)
+{
+  g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (partition_table),
+                                       G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
+}
+
+static void
+udisks_linux_partition_table_class_init (UDisksLinuxPartitionTableClass *klass)
+{
+}
+
+/**
+ * udisks_linux_partition_table_new:
+ *
+ * Creates a new #UDisksLinuxPartitionTable instance.
+ *
+ * Returns: A new #UDisksLinuxPartitionTable. Free with g_object_unref().
+ */
+UDisksPartitionTable *
+udisks_linux_partition_table_new (void)
+{
+  return UDISKS_PARTITION_TABLE (g_object_new (UDISKS_TYPE_LINUX_PARTITION_TABLE,
+                                               NULL));
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+/**
+ * udisks_linux_partition_table_update:
+ * @table: A #UDisksLinuxPartitionTable.
+ * @object: The enclosing #UDisksLinuxBlockObject instance.
+ *
+ * Updates the interface.
+ */
+void
+udisks_linux_partition_table_update (UDisksLinuxPartitionTable  *table,
+                                     UDisksLinuxBlockObject     *object)
+{
+  const gchar *type = NULL;
+  GUdevDevice *device = NULL;;
+
+  device = udisks_linux_block_object_get_device (object);
+  if (device != NULL)
+    type = g_udev_device_get_property (device, "ID_PART_TABLE_TYPE");
+
+  udisks_partition_table_set_type_ (UDISKS_PARTITION_TABLE (table), type);
+
+  g_clear_object (&device);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+partition_table_iface_init (UDisksPartitionTableIface *iface)
+{
+}
diff --git a/src/udiskslinuxpartitiontable.h b/src/udiskslinuxpartitiontable.h
new file mode 100644 (file)
index 0000000..e63900b
--- /dev/null
@@ -0,0 +1,39 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2007-2010 David Zeuthen <zeuthen@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __UDISKS_LINUX_PARTITION_TABLE_H__
+#define __UDISKS_LINUX_PARTITION_TABLE_H__
+
+#include "udisksdaemontypes.h"
+
+G_BEGIN_DECLS
+
+#define UDISKS_TYPE_LINUX_PARTITION_TABLE         (udisks_linux_partition_table_get_type ())
+#define UDISKS_LINUX_PARTITION_TABLE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), UDISKS_TYPE_LINUX_PARTITION_TABLE, UDisksLinuxPartitionTable))
+#define UDISKS_IS_LINUX_PARTITION_TABLE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), UDISKS_TYPE_LINUX_PARTITION_TABLE))
+
+GType                 udisks_linux_partition_table_get_type (void) G_GNUC_CONST;
+UDisksPartitionTable *udisks_linux_partition_table_new      (void);
+void                  udisks_linux_partition_table_update   (UDisksLinuxPartitionTable *table,
+                                                             UDisksLinuxBlockObject    *object);
+
+G_END_DECLS
+
+#endif /* __UDISKS_LINUX_PARTITION_TABLE_H__ */
index c9abdce..05492f5 100644 (file)
@@ -2475,7 +2475,11 @@ handle_command_status (gint        *argc,
       for (j = blocks; j != NULL; j = j->next)
         {
           UDisksBlock *block = UDISKS_BLOCK (j->data);
-          if (!udisks_block_get_part_entry (block))
+          GDBusObject *block_object;
+          UDisksPartition *partition;
+          block_object = g_dbus_interface_get_object (G_DBUS_INTERFACE (block));
+          partition = block_object == NULL ? NULL : udisks_object_peek_partition (UDISKS_OBJECT (block_object));
+          if (partition == NULL)
             {
               const gchar *device_file;
               if (str->len > 0)
index 708cf00..ed50a7e 100644 (file)
@@ -597,13 +597,15 @@ get_top_level_blocks_for_drive (UDisksClient *client,
     {
       UDisksObject *object = UDISKS_OBJECT (l->data);
       UDisksBlock *block;
+      UDisksPartition *partition;
 
       block = udisks_object_get_block (object);
+      partition = udisks_object_peek_partition (object);
       if (block == NULL)
         continue;
 
       if (g_strcmp0 (udisks_block_get_drive (block), drive_object_path) == 0 &&
-          !udisks_block_get_part_entry (block))
+          partition == NULL)
         {
           ret = g_list_append (ret, g_object_ref (object));
         }
@@ -1221,6 +1223,38 @@ udisks_client_get_cleartext_block (UDisksClient  *client,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+/**
+ * udisks_client_get_partition_table:
+ * @client: A #UDisksClient.
+ * @partition: A #UDisksPartition.
+ *
+ * Gets the #UDisksPartitionTable corresponding to @partition.
+ *
+ * Returns: (transfer full): A #UDisksPartitionTable. Free with g_object_unref().
+ */
+UDisksPartitionTable *
+udisks_client_get_partition_table (UDisksClient     *client,
+                                   UDisksPartition  *partition)
+{
+  UDisksPartitionTable *ret = NULL;
+  UDisksObject *object;
+
+  g_return_val_if_fail (UDISKS_IS_CLIENT (client), NULL);
+  g_return_val_if_fail (UDISKS_IS_PARTITION (partition), NULL);
+
+  object = udisks_client_get_object (client, udisks_partition_get_table (partition));
+  if (object == NULL)
+    goto out;
+
+  ret = udisks_object_get_partition_table (object);
+  g_object_unref (object);
+
+ out:
+  return ret;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 static gboolean
 on_changed_timeout (gpointer user_data)
 {
index a412611..ee8c3da 100644 (file)
@@ -63,6 +63,9 @@ UDisksDrive        *udisks_client_get_drive_for_block (UDisksClient        *clie
 UDisksBlock        *udisks_client_get_cleartext_block (UDisksClient        *client,
                                                        UDisksBlock         *block);
 
+UDisksPartitionTable *udisks_client_get_partition_table (UDisksClient        *client,
+                                                         UDisksPartition     *partition);
+
 void                udisks_client_get_drive_info      (UDisksClient        *client,
                                                        UDisksDrive         *drive,
                                                        gchar              **out_name,
index 67b524e..eeb1461 100644 (file)
@@ -187,7 +187,7 @@ const static struct
   const gchar *name;
 } part_scheme[] =
 {
-  {"mbr", N_("Master Boot Record")},
+  {"dos", N_("Master Boot Record")},
   {"gpt", N_("GUID Partition Table")},
   {"apm", N_("Apple Partition Map")},
   {NULL, NULL}
@@ -237,63 +237,63 @@ const static struct
   /* see http://en.wikipedia.org/wiki/GUID_Partition_Table */
 
   /* Linux */
-  {"gpt", "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7", N_("Basic Data")}, /* Same as MS BDP */
-  {"gpt", "A19D880F-05FC-4D3B-A006-743F0F84911E", N_("Linux RAID")},
-  {"gpt", "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F", N_("Linux Swap")},
-  {"gpt", "E6D6D379-F507-44C2-A23C-238F2A3DF928", N_("Linux LVM")},
-  {"gpt", "8DA63339-0007-60C0-C436-083AC8230908", N_("Linux Reserved")},
+  {"gpt", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7", N_("Basic Data")}, /* same as ms bdp */
+  {"gpt", "a19d880f-05fc-4d3b-a006-743f0f84911e", N_("Linux RAID")},
+  {"gpt", "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f", N_("Linux Swap")},
+  {"gpt", "e6d6d379-f507-44c2-a23c-238f2a3df928", N_("Linux LVM")},
+  {"gpt", "8da63339-0007-60c0-c436-083ac8230908", N_("Linux Reserved")},
   /* Not associated with any OS */
-  {"gpt", "024DEE41-33E7-11D3-9D69-0008C781F39F", N_("MBR Partition Scheme")},
-  {"gpt", "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", N_("EFI System")},
-  {"gpt", "21686148-6449-6E6F-744E-656564454649", N_("BIOS Boot")},
+  {"gpt", "024dee41-33e7-11d3-9d69-0008c781f39f", N_("MBR Partition Scheme")},
+  {"gpt", "c12a7328-f81f-11d2-ba4b-00a0c93ec93b", N_("EFI System")},
+  {"gpt", "21686148-6449-6e6f-744e-656564454649", N_("BIOS Boot")},
   /* Microsoft */
-  {"gpt", "E3C9E316-0B5C-4DB8-817D-F92DF00215AE", N_("Microsoft Reserved")},
-  {"gpt", "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7", N_("Microsoft Basic Data")}, /* Same as Linux BDP */
-  {"gpt", "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3", N_("Microsoft LDM Metadata")},
-  {"gpt", "AF9B60A0-1431-4F62-BC68-3311714A69AD", N_("Microsoft LDM Data")},
-  {"gpt", "DE94BBA4-06D1-4D40-A16A-BFD50179D6AC", N_("Microsoft Windows Recovery Environment")},
+  {"gpt", "e3c9e316-0b5c-4db8-817d-f92df00215ae", N_("Microsoft Reserved")},
+  {"gpt", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7", N_("Microsoft Basic Data")}, /* same as Linux Basic Data */
+  {"gpt", "5808c8aa-7e8f-42e0-85d2-e1e90434cfb3", N_("Microsoft LDM metadata")},
+  {"gpt", "af9b60a0-1431-4f62-bc68-3311714a69ad", N_("Microsoft LDM data")},
+  {"gpt", "de94bba4-06d1-4d40-a16a-bfd50179d6ac", N_("Microsoft Windows Recovery Environment")},
   /* HP-UX */
-  {"gpt", "75894C1E-3AEB-11D3-B7C1-7B03A0000000", N_("HP-UX Data")},
-  {"gpt", "E2A1E728-32E3-11D6-A682-7B03A0000000", N_("HP-UX Service")},
+  {"gpt", "75894c1e-3aeb-11d3-b7c1-7b03a0000000", N_("HP-UX Data")},
+  {"gpt", "e2a1e728-32e3-11d6-a682-7b03a0000000", N_("HP-UX Service")},
   /* FreeBSD */
-  {"gpt", "83BD6B9D-7F41-11DC-BE0B-001560B84F0F", N_("FreeBSD Boot")},
-  {"gpt", "516E7CB4-6ECF-11D6-8FF8-00022D09712B", N_("FreeBSD Data")},
-  {"gpt", "516E7CB5-6ECF-11D6-8FF8-00022D09712B", N_("FreeBSD Swap")},
-  {"gpt", "516E7CB6-6ECF-11D6-8FF8-00022D09712B", N_("FreeBSD UFS")},
-  {"gpt", "516E7CB8-6ECF-11D6-8FF8-00022D09712B", N_("FreeBSD Vinum")},
-  {"gpt", "516E7CBA-6ECF-11D6-8FF8-00022D09712B", N_("FreeBSD ZFS")},
+  {"gpt", "83bd6b9d-7f41-11dc-be0b-001560b84f0f", N_("FreeBSD Boot")},
+  {"gpt", "516e7cb4-6ecf-11d6-8ff8-00022d09712b", N_("FreeBSD Data")},
+  {"gpt", "516e7cb5-6ecf-11d6-8ff8-00022d09712b", N_("FreeBSD Swap")},
+  {"gpt", "516e7cb6-6ecf-11d6-8ff8-00022d09712b", N_("FreeBSD UFS")},
+  {"gpt", "516e7cb8-6ecf-11d6-8ff8-00022d09712b", N_("FreeBSD Vinum")},
+  {"gpt", "516e7cba-6ecf-11d6-8ff8-00022d09712b", N_("FreeBSD ZFS")},
   /* Solaris */
-  {"gpt", "6A82CB45-1DD2-11B2-99A6-080020736631", N_("Solaris Boot")},
-  {"gpt", "6A85CF4D-1DD2-11B2-99A6-080020736631", N_("Solaris Root")},
-  {"gpt", "6A87C46F-1DD2-11B2-99A6-080020736631", N_("Solaris Swap")},
-  {"gpt", "6A8B642B-1DD2-11B2-99A6-080020736631", N_("Solaris Backup")},
-  {"gpt", "6A898CC3-1DD2-11B2-99A6-080020736631", N_("Solaris /usr")}, /* Same as Apple ZFS */
-  {"gpt", "6A8EF2E9-1DD2-11B2-99A6-080020736631", N_("Solaris /var")},
-  {"gpt", "6A90BA39-1DD2-11B2-99A6-080020736631", N_("Solaris /home")},
-  {"gpt", "6A9283A5-1DD2-11B2-99A6-080020736631", N_("Solaris Alternate Sector")},
-  {"gpt", "6A945A3B-1DD2-11B2-99A6-080020736631", N_("Solaris Reserved")},
-  {"gpt", "6A9630D1-1DD2-11B2-99A6-080020736631", N_("Solaris Reserved (2)")},
-  {"gpt", "6A980767-1DD2-11B2-99A6-080020736631", N_("Solaris Reserved (3)")},
-  {"gpt", "6A96237F-1DD2-11B2-99A6-080020736631", N_("Solaris Reserved (4)")},
-  {"gpt", "6A8D2AC7-1DD2-11B2-99A6-080020736631", N_("Solaris Reserved (5)")},
-  /* Mac OS X */
-  {"gpt", "48465300-0000-11AA-AA11-00306543ECAC", N_("Apple HFS/HFS+")},
-  {"gpt", "55465300-0000-11AA-AA11-00306543ECAC", N_("Apple UFS")},
-  {"gpt", "6A898CC3-1DD2-11B2-99A6-080020736631", N_("Apple ZFS")}, /* Same as Solaris /usr */
-  {"gpt", "52414944-0000-11AA-AA11-00306543ECAC", N_("Apple RAID")},
-  {"gpt", "52414944-5F4F-11AA-AA11-00306543ECAC", N_("Apple RAID (Offline)")},
-  {"gpt", "426F6F74-0000-11AA-AA11-00306543ECAC", N_("Apple Boot")},
-  {"gpt", "4C616265-6C00-11AA-AA11-00306543ECAC", N_("Apple Label")},
-  {"gpt", "5265636F-7665-11AA-AA11-00306543ECAC", N_("Apple TV Recovery")},
+  {"gpt", "6a82cb45-1dd2-11b2-99a6-080020736631", N_("Solaris Boot")},
+  {"gpt", "6a85cf4d-1dd2-11b2-99a6-080020736631", N_("Solaris Root")},
+  {"gpt", "6a87c46f-1dd2-11b2-99a6-080020736631", N_("Solaris Swap")},
+  {"gpt", "6a8b642b-1dd2-11b2-99a6-080020736631", N_("Solaris Backup")},
+  {"gpt", "6a898cc3-1dd2-11b2-99a6-080020736631", N_("Solaris /usr")}, /* same as Apple ZFS */
+  {"gpt", "6a8ef2e9-1dd2-11b2-99a6-080020736631", N_("Solaris /var")},
+  {"gpt", "6a90ba39-1dd2-11b2-99a6-080020736631", N_("Solaris /home")},
+  {"gpt", "6a9283a5-1dd2-11b2-99a6-080020736631", N_("Solaris Alternate Sector")},
+  {"gpt", "6a945a3b-1dd2-11b2-99a6-080020736631", N_("Solaris Reserved")},
+  {"gpt", "6a9630d1-1dd2-11b2-99a6-080020736631", N_("Solaris Reserved (2)")},
+  {"gpt", "6a980767-1dd2-11b2-99a6-080020736631", N_("Solaris Reserved (3)")},
+  {"gpt", "6a96237f-1dd2-11b2-99a6-080020736631", N_("Solaris Reserved (4)")},
+  {"gpt", "6a8d2ac7-1dd2-11b2-99a6-080020736631", N_("Solaris Reserved (5)")},
+  /* Apple OS X */
+  {"gpt", "48465300-0000-11aa-aa11-00306543ecac", N_("Apple HFS/HFS+")},
+  {"gpt", "55465300-0000-11aa-aa11-00306543ecac", N_("Apple UFS")},
+  {"gpt", "6a898cc3-1dd2-11b2-99a6-080020736631", N_("Apple ZFS")}, /* same as Solaris /usr */
+  {"gpt", "52414944-0000-11aa-aa11-00306543ecac", N_("Apple RAID")},
+  {"gpt", "52414944-5f4f-11aa-aa11-00306543ecac", N_("Apple RAID (offline)")},
+  {"gpt", "426f6f74-0000-11aa-aa11-00306543ecac", N_("Apple Boot")},
+  {"gpt", "4c616265-6c00-11aa-aa11-00306543ecac", N_("Apple Label")},
+  {"gpt", "5265636f-7665-11aa-aa11-00306543ecac", N_("Apple TV Recovery")},
   /* NetBSD */
-  {"gpt", "49F48D32-B10E-11DC-B99B-0019D1879648", N_("NetBSD Swap")},
-  {"gpt", "49F48D5A-B10E-11DC-B99B-0019D1879648", N_("NetBSD FFS")},
-  {"gpt", "49F48D82-B10E-11DC-B99B-0019D1879648", N_("NetBSD LFS")},
-  {"gpt", "49F48DAA-B10E-11DC-B99B-0019D1879648", N_("NetBSD RAID")},
-  {"gpt", "2DB519C4-B10F-11DC-B99B-0019D1879648", N_("NetBSD Concatenated")},
-  {"gpt", "2DB519EC-B10F-11DC-B99B-0019D1879648", N_("NetBSD Encrypted")},
-
-  /* see http://developer.apple.com/documentation/mac/Devices/Devices-126.html
+  {"gpt", "49f48d32-b10e-11dc-b99b-0019d1879648", N_("NetBSD Swap")},
+  {"gpt", "49f48d5a-b10e-11dc-b99b-0019d1879648", N_("NetBSD FFS")},
+  {"gpt", "49f48d82-b10e-11dc-b99b-0019d1879648", N_("NetBSD LFS")},
+  {"gpt", "49f48daa-b10e-11dc-b99b-0019d1879648", N_("NetBSD RAID")},
+  {"gpt", "2db519c4-b10f-11dc-b99b-0019d1879648", N_("NetBSD Concatenated")},
+  {"gpt", "2db519ec-b10f-11dc-b99b-0019d1879648", N_("NetBSD Encrypted")},
+
+  /* see http://developer.apple.com/documentation/mac/devices/devices-126.html
    *     http://lists.apple.com/archives/Darwin-drivers/2003/May/msg00021.html */
   {"apm", "Apple_Unix_SVR2", N_("Apple UFS")},
   {"apm", "Apple_HFS", N_("Apple HFS/HFS")},
@@ -310,44 +310,44 @@ const static struct
   {"apm", "Windows_FAT_32", N_("FAT 32 (Windows)")},
 
   /* see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */
-  {"mbr", "0x00",  N_("Empty")},
-  {"mbr", "0x01",  N_("FAT12")},
-  {"mbr", "0x04",  N_("FAT16 <32M")},
-  {"mbr", "0x05",  N_("Extended")},
-  {"mbr", "0x06",  N_("FAT16")},
-  {"mbr", "0x07",  N_("HPFS/NTFS")},
-  {"mbr", "0x0b",  N_("W95 FAT32")},
-  {"mbr", "0x0c",  N_("W95 FAT32 (LBA)")},
-  {"mbr", "0x0e",  N_("W95 FAT16 (LBA)")},
-  {"mbr", "0x0f",  N_("W95 Ext d (LBA)")},
-  {"mbr", "0x10",  N_("OPUS")},
-  {"mbr", "0x11",  N_("Hidden FAT12")},
-  {"mbr", "0x12",  N_("Compaq diagnostics")},
-  {"mbr", "0x14",  N_("Hidden FAT16 <32M")},
-  {"mbr", "0x16",  N_("Hidden FAT16")},
-  {"mbr", "0x17",  N_("Hidden HPFS/NTFS")},
-  {"mbr", "0x1b",  N_("Hidden W95 FAT32")},
-  {"mbr", "0x1c",  N_("Hidden W95 FAT32 (LBA)")},
-  {"mbr", "0x1e",  N_("Hidden W95 FAT16 (LBA)")},
-  {"mbr", "0x3c",  N_("PartitionMagic")},
-  {"mbr", "0x81",  N_("Minix")}, /* cf. http://en.wikipedia.org/wiki/MINIX_file_system */
-  {"mbr", "0x82",  N_("Linux swap")},
-  {"mbr", "0x83",  N_("Linux")},
-  {"mbr", "0x84",  N_("Hibernation")},
-  {"mbr", "0x85",  N_("Linux Extended")},
-  {"mbr", "0x8e",  N_("Linux LVM")},
-  {"mbr", "0xa0",  N_("Hibernation")},
-  {"mbr", "0xa5",  N_("FreeBSD")},
-  {"mbr", "0xa6",  N_("OpenBSD")},
-  {"mbr", "0xa8",  N_("Mac OS X")},
-  {"mbr", "0xaf",  N_("Mac OS X")},
-  {"mbr", "0xbe",  N_("Solaris boot")},
-  {"mbr", "0xbf",  N_("Solaris")},
-  {"mbr", "0xeb",  N_("BeOS BFS")},
-  {"mbr", "0xec",  N_("SkyOS SkyFS")},
-  {"mbr", "0xee",  N_("EFI GPT")},
-  {"mbr", "0xef",  N_("EFI (FAT-12/16/32)")},
-  {"mbr", "0xfd",  N_("Linux RAID auto")},
+  {"dos", "0x00",  N_("Empty")},
+  {"dos", "0x01",  N_("FAT12")},
+  {"dos", "0x04",  N_("FAT16 <32M")},
+  {"dos", "0x05",  N_("Extended")},
+  {"dos", "0x06",  N_("FAT16")},
+  {"dos", "0x07",  N_("HPFS/NTFS")},
+  {"dos", "0x0b",  N_("W95 FAT32")},
+  {"dos", "0x0c",  N_("W95 FAT32 (LBA)")},
+  {"dos", "0x0e",  N_("W95 FAT16 (LBA)")},
+  {"dos", "0x0f",  N_("W95 Ext d (LBA)")},
+  {"dos", "0x10",  N_("OPUS")},
+  {"dos", "0x11",  N_("Hidden FAT12")},
+  {"dos", "0x12",  N_("Compaq diagnostics")},
+  {"dos", "0x14",  N_("Hidden FAT16 <32M")},
+  {"dos", "0x16",  N_("Hidden FAT16")},
+  {"dos", "0x17",  N_("Hidden HPFS/NTFS")},
+  {"dos", "0x1b",  N_("Hidden W95 FAT32")},
+  {"dos", "0x1c",  N_("Hidden W95 FAT32 (LBA)")},
+  {"dos", "0x1e",  N_("Hidden W95 FAT16 (LBA)")},
+  {"dos", "0x3c",  N_("PartitionMagic")},
+  {"dos", "0x81",  N_("Minix")}, /* cf. http://en.wikipedia.org/wiki/MINIX_file_system */
+  {"dos", "0x82",  N_("Linux swap")},
+  {"dos", "0x83",  N_("Linux")},
+  {"dos", "0x84",  N_("Hibernation")},
+  {"dos", "0x85",  N_("Linux Extended")},
+  {"dos", "0x8e",  N_("Linux LVM")},
+  {"dos", "0xa0",  N_("Hibernation")},
+  {"dos", "0xa5",  N_("FreeBSD")},
+  {"dos", "0xa6",  N_("OpenBSD")},
+  {"dos", "0xa8",  N_("Mac OS X")},
+  {"dos", "0xaf",  N_("Mac OS X")},
+  {"dos", "0xbe",  N_("Solaris boot")},
+  {"dos", "0xbf",  N_("Solaris")},
+  {"dos", "0xeb",  N_("BeOS BFS")},
+  {"dos", "0xec",  N_("SkyOS SkyFS")},
+  {"dos", "0xee",  N_("EFI GPT")},
+  {"dos", "0xef",  N_("EFI (FAT-12/16/32)")},
+  {"dos", "0xfd",  N_("Linux RAID auto")},
   {NULL,  NULL, NULL}
 };