Hi,

I'm attaching another patch that should be applied INSTEAD OF my earlier patch in order to support a new Linux-only GUID type code. The new patch is intended to address concerns about breaking programs that might assume the Microsoft Basic Data partition type code on Linux partitions by giving the option of setting that type code on Linux partitions. What this patch does is:

- It creates a new Linux-only filesystem type code
  (0FC63DAF-8483-4772-8E79-3D69D8477DE4)

- It sets the new Linux type code on new partitions by default.

- As in the current 3.0 code, non-Linux filesystems (FAT, NTFS,
  HFS+, etc.), and some other partition types (Linux swap, LVM,
  etc.) get codes that override the default.

These three features are as in my earlier patch. The new changes are:

- My patch creates a new flag, "msftdata", to explicitly represent the
  Microsoft Basic Data type code. This flag is automatically set
  on new FAT and NTFS partitions.

- The msftdata flag may be added to any partition, thus changing
  its type code GUID.

- The msftdata flag may be removed from any partition (via "set
  # msftdata off") EXCEPT for those with NTFS or FAT filesystems.
  This limitation is a consequence of the way the current code
  handles flags; it auto-detects their filesystem types when flags
  are removed and uses that auto-detection to set the type code.
  Thus, removing the msftdata flag from an NTFS or FAT partition
  results in the filesystem type being auto-detected and the flag
  re-set. I don't see an easy way to change this, and trying to
  do so would leave the question of what filesystem type code to
  set on the partition.

- The msftdata flag may be removed from NTFS or FAT partitions by
  setting a competing flag (bios_grub, boot, lvm, msftres, etc.).
  This moderates the above limitation; essentially, you just can't
  set an NTFS or FAT partition to use the new Linux type code, the
  HFS+ type code, or other filesystem type codes that are NOT
  associated with flags. You CAN set them to other type codes --
  most importantly, "boot" (for an EFI System Partition).

Assuming this patch is accepted into the program, the effect will be a rapid use of the new Linux-specific type code in NEW GPT installations as the new version is adopted downstream. Existing installations will be unaffected unless users notice the "msftdata" flag and decide to remove it. If the new type code causes problems, users can add the msftdata flag to their partitions until whatever program makes assumptions about Linux filesystems being on Microsoft Basic Data partitions is updated.

I considered implementing these changes the other way -- that is, to create a flag for the new type code. This would have resulted in slower adoption of the new code, which would minimize the risk of unknown problems showing up in large numbers but would maximize the risk of users trashing their Linux installations in Windows. Doing it this way seems backwards on a Linux system, too, and the limitation in the current patch of being unable to remove an msftdata flag from NTFS or FAT partitions would instead apply to the hypothetical linux flag on partitions with Linux filesystems, which would defeat the goal of enabling users to switch from the new Linux type code to the Microsoft Basic Data type code if the new code causes problems. Thus, it just doesn't make sense to implement it that way, at least not without addressing this limitation.

The fact that a partition with an NTFS or FAT filesystem must always have some sort of flag in my patched version of parted is weird and might confuse some users, but I don't see any way out of that problem except by either using my original patch, which doesn't give users the option of backing out of the new type code, or completely rewriting the way parted handles partition type codes. The latter would be a huge undertaking, but if the parted Powers That Be choose to use my simpler earlier patch, that's fine by me.

--
Rod Smith
rodsm...@rodsbooks.com
http://www.rodsbooks.com
diff -Naur parted-3.0/include/parted/disk.h parted-3.0b/include/parted/disk.h
--- parted-3.0/include/parted/disk.h    2011-05-10 11:19:09.000000000 -0400
+++ parted-3.0b/include/parted/disk.h   2011-06-25 15:23:24.000000000 -0400
@@ -70,10 +70,11 @@
         PED_PARTITION_BIOS_GRUB=12,
         PED_PARTITION_APPLE_TV_RECOVERY=13,
         PED_PARTITION_DIAG=14,
-        PED_PARTITION_LEGACY_BOOT=15
+        PED_PARTITION_LEGACY_BOOT=15,
+        PED_PARTITION_MSFT_DATA=16
 };
 #define PED_PARTITION_FIRST_FLAG        PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG         PED_PARTITION_LEGACY_BOOT
+#define PED_PARTITION_LAST_FLAG         PED_PARTITION_MSFT_DATA
 
 enum _PedDiskTypeFeature {
         PED_DISK_TYPE_EXTENDED=1,       /**< supports extended partitions */
diff -Naur parted-3.0/libparted/disk.c parted-3.0b/libparted/disk.c
--- parted-3.0/libparted/disk.c 2011-05-10 11:19:09.000000000 -0400
+++ parted-3.0b/libparted/disk.c        2011-06-25 14:24:35.000000000 -0400
@@ -2431,6 +2431,8 @@
                return N_("prep");
        case PED_PARTITION_MSFT_RESERVED:
                return N_("msftres");
+       case PED_PARTITION_MSFT_DATA:
+               return N_("msftdata");
         case PED_PARTITION_APPLE_TV_RECOVERY:
                 return N_("atvrecv");
         case PED_PARTITION_DIAG:
diff -Naur parted-3.0/libparted/labels/gpt.c parted-3.0b/libparted/labels/gpt.c
--- parted-3.0/libparted/labels/gpt.c   2011-05-10 11:19:09.000000000 -0400
+++ parted-3.0b/libparted/labels/gpt.c  2011-06-25 15:01:49.000000000 -0400
@@ -122,6 +122,10 @@
     ((efi_guid_t) { PED_CPU_TO_LE32 (0x0657fd6d), PED_CPU_TO_LE16 (0xa4ab), \
                     PED_CPU_TO_LE16 (0x43c4), 0x84, 0xe5, \
                     { 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f }})
+#define PARTITION_LINUX_DATA_GUID \
+    ((efi_guid_t) { PED_CPU_TO_LE32 (0x0FC63DAF), PED_CPU_TO_LE16 (0x8483), \
+                    PED_CPU_TO_LE16 (0x4772), 0x8E, 0x79, \
+                    { 0x3D, 0x69, 0xD8, 0x47, 0x7D, 0xE4 }})
 #define PARTITION_LVM_GUID \
     ((efi_guid_t) { PED_CPU_TO_LE32 (0xe6d6d379), PED_CPU_TO_LE16 (0xf507), \
                     PED_CPU_TO_LE16 (0x44c2), 0xa2, 0x3c, \
@@ -279,6 +283,7 @@
   int hp_service;
   int hidden;
   int msftres;
+  int msftdata;
   int atvrecv;
   int msftrecv;
   int legacy_boot;
@@ -791,6 +796,7 @@
   gpt_part_data->lvm = gpt_part_data->raid
     = gpt_part_data->boot = gpt_part_data->hp_service
     = gpt_part_data->hidden = gpt_part_data->msftres
+    = gpt_part_data->msftdata
     = gpt_part_data->msftrecv
     = gpt_part_data->legacy_boot
     = gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
@@ -812,6 +818,8 @@
     gpt_part_data->hp_service = 1;
   else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
     gpt_part_data->msftres = 1;
+  else if (!guid_cmp (gpt_part_data->type, PARTITION_BASIC_DATA_GUID))
+    gpt_part_data->msftdata = 1;
   else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RECOVERY))
     gpt_part_data->msftrecv = 1;
   else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID))
@@ -1309,7 +1317,7 @@
   if (!gpt_part_data)
     goto error_free_part;
 
-  gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
+  gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
   gpt_part_data->lvm = 0;
   gpt_part_data->raid = 0;
   gpt_part_data->boot = 0;
@@ -1317,6 +1325,7 @@
   gpt_part_data->hp_service = 0;
   gpt_part_data->hidden = 0;
   gpt_part_data->msftres = 0;
+  gpt_part_data->msftdata = 0;
   gpt_part_data->msftrecv = 0;
   gpt_part_data->atvrecv = 0;
   gpt_part_data->legacy_boot = 0;
@@ -1415,6 +1424,11 @@
       gpt_part_data->type = PARTITION_MSFT_RESERVED_GUID;
       return 1;
     }
+  if (gpt_part_data->msftdata)
+    {
+      gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
+      return 1;
+    }
   if (gpt_part_data->msftrecv)
     {
       gpt_part_data->type = PARTITION_MSFT_RECOVERY;
@@ -1446,7 +1460,7 @@
         }
     }
 
-  gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
+  gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
   return 1;
 }
 
@@ -1524,6 +1538,7 @@
           = gpt_part_data->bios_grub
           = gpt_part_data->hp_service
           = gpt_part_data->msftres
+         = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
@@ -1535,6 +1550,7 @@
           = gpt_part_data->boot
           = gpt_part_data->hp_service
           = gpt_part_data->msftres
+         = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
@@ -1546,6 +1562,7 @@
           = gpt_part_data->bios_grub
           = gpt_part_data->hp_service
           = gpt_part_data->msftres
+         = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
@@ -1557,6 +1574,7 @@
           = gpt_part_data->bios_grub
           = gpt_part_data->hp_service
           = gpt_part_data->msftres
+         = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
@@ -1568,6 +1586,7 @@
           = gpt_part_data->lvm
           = gpt_part_data->bios_grub
           = gpt_part_data->msftres
+         = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
@@ -1579,8 +1598,25 @@
           = gpt_part_data->lvm
           = gpt_part_data->bios_grub
           = gpt_part_data->hp_service
+         = gpt_part_data->msftdata
+          = gpt_part_data->msftrecv
+          = gpt_part_data->atvrecv = 0;
+      return gpt_partition_set_system (part, part->fs_type);
+    case PED_PARTITION_MSFT_DATA:
+      gpt_part_data->msftres = state;
+      if (state) {
+        gpt_part_data->boot
+          = gpt_part_data->raid
+          = gpt_part_data->lvm
+          = gpt_part_data->bios_grub
+          = gpt_part_data->hp_service
+         = gpt_part_data->msftres
           = gpt_part_data->msftrecv
           = gpt_part_data->atvrecv = 0;
+        gpt_part_data->msftdata = 1;
+      } else {
+        gpt_part_data->msftdata = 0;
+      }
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_DIAG:
       gpt_part_data->msftrecv = state;
@@ -1590,6 +1626,7 @@
           = gpt_part_data->lvm
           = gpt_part_data->bios_grub
           = gpt_part_data->hp_service
+         = gpt_part_data->msftdata
           = gpt_part_data->msftres
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
@@ -1602,6 +1639,7 @@
           = gpt_part_data->bios_grub
           = gpt_part_data->hp_service
           = gpt_part_data->msftres
+         = gpt_part_data->msftdata
           = gpt_part_data->msftrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_HIDDEN:
@@ -1640,6 +1678,8 @@
       return gpt_part_data->hp_service;
     case PED_PARTITION_MSFT_RESERVED:
       return gpt_part_data->msftres;
+    case PED_PARTITION_MSFT_DATA:
+      return gpt_part_data->msftdata;
     case PED_PARTITION_DIAG:
       return gpt_part_data->msftrecv;
     case PED_PARTITION_APPLE_TV_RECOVERY:
@@ -1669,6 +1709,7 @@
     case PED_PARTITION_BIOS_GRUB:
     case PED_PARTITION_HPSERVICE:
     case PED_PARTITION_MSFT_RESERVED:
+    case PED_PARTITION_MSFT_DATA:
     case PED_PARTITION_DIAG:
     case PED_PARTITION_APPLE_TV_RECOVERY:
     case PED_PARTITION_HIDDEN:
_______________________________________________
bug-parted mailing list
bug-parted@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-parted

Reply via email to