bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15356: [PATCH 13/19] libparted: Add Intel Rapid Start Technology par


From: Brian C. Lane
Subject: bug#15356: [PATCH 13/19] libparted: Add Intel Rapid Start Technology partition flag.
Date: Wed, 11 Sep 2013 12:25:03 -0700

From: "Brian C. Lane" <address@hidden>

This adds support for the irst partition type flag. Sets the type to
0x84 on MS-DOS and D3BFE2DE-3DAF-11DF-BA-40-E3A556D89593 on GPT.

* NEWS (Changes in behavior): Mention it.
* doc/C/parted.8: Document irst flag.
* doc/parted.texti: Document irst flag.
* include/parted/disk.in.h (_PedPartitionFlag): Add PED_PARTITION_IRST flag
* libparted/disk.c (ped_partition_flag_get_name): Add irst flag
* libparted/labels/dos.c (DosPartitionData): Likewise
(raw_part_parse): Likewise
(msdos_partition_new): Likewise
(msdos_partition_duplicate): Likewise
(msdos_partition_set_system): Likewise
(clear_flags): Likewise
(msdos_partition_set_flag): Likewise
(msdos_partition_get_flag): Likewise
(msdos_partition_is_flag_available): Likewise
* libparted/labels/gpt.c: Add PARTITION_IRST_GUID
(GPTPartitionData): Add irst flag
(_parse_part_entry): Likewise
(gpt_partition_new): Likewise
(gpt_partition_set_system): Likewise
(gpt_partition_set_flag): Likewise
(gpt_partition_get_flag): Likewise
(gpt_partition_is_flag_available): Likewise
---
 NEWS                     |  4 ++++
 doc/C/parted.8           |  2 +-
 doc/parted.texi          |  4 ++++
 include/parted/disk.in.h |  5 +++--
 libparted/disk.c         |  2 ++
 libparted/labels/dos.c   | 21 +++++++++++++++++++++
 libparted/labels/gpt.c   | 39 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 98f7c6e..b53a9d0 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,10 @@ GNU parted NEWS                                    -*- 
outline -*-
 
 ** Changes in behavior
 
+  Added new partition type flag, irst, for use with Intel Rapid Start
+  Technology. On MS-DOS disk labels it sets the type to 0x84 and on GPT
+  it sets the GUID to D3BFE2DE-3DAF-11DF-BA-40-E3A556D89593.
+
   parted -l no longer lists device-mapper devices other than
   dmraid whole disks.
 
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index a9f73f5..2f8e9f5 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -104,7 +104,7 @@ or an LVM logical volume if necessary.
 .B set \fIpartition\fP \fIflag\fP \fIstate\fP
 Change the state of the \fIflag\fP on \fIpartition\fP to \fIstate\fP.
 Supported flags are: "boot", "root", "swap", "hidden", "raid", "lvm", "lba",
-"legacy_boot" and "palo".
+"legacy_boot", "irst" and "palo".
 \fIstate\fP should be either "on" or "off".
 .TP
 .B unit \fIunit\fP
diff --git a/doc/parted.texi b/doc/parted.texi
index 008c383..fd8ccb9 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -836,6 +836,10 @@ used by Windows on GPT disks.  Note that this flag should 
not normally be
 set on Windows filesystem partitions (those that contain NTFS or FAT
 filesystems).
 
address@hidden irst
+(MS-DOS, GPT) - this flag identifies an Intel Rapid Start Technology
+partition.
+
 @item lba
 (MS-DOS) - this flag can be enabled to tell MS DOS, MS Windows 9x and
 MS Windows ME based operating systems to use Linear (LBA) mode.
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index aa905c5..585383d 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -73,10 +73,11 @@ enum _PedPartitionFlag {
         PED_PARTITION_APPLE_TV_RECOVERY=13,
         PED_PARTITION_DIAG=14,
         PED_PARTITION_LEGACY_BOOT=15,
-        PED_PARTITION_MSFT_DATA=16
+        PED_PARTITION_MSFT_DATA=16,
+        PED_PARTITION_IRST=17
 };
 #define PED_PARTITION_FIRST_FLAG        PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG         PED_PARTITION_MSFT_DATA
+#define PED_PARTITION_LAST_FLAG         PED_PARTITION_IRST
 
 enum _PedDiskTypeFeature {
         PED_DISK_TYPE_EXTENDED=1,       /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index d3cd5bb..4ca7255 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2441,6 +2441,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
                 return N_("diag");
         case PED_PARTITION_LEGACY_BOOT:
                 return N_("legacy_boot");
+        case PED_PARTITION_IRST:
+                return N_("irst");
 
        default:
                ped_exception_throw (
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index b8c161f..f8591ff 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -85,6 +85,7 @@ static const char MBR_BOOT_CODE[] = {
 #define PARTITION_LDM          0x42
 #define PARTITION_LINUX_SWAP   0x82
 #define PARTITION_LINUX                0x83
+#define PARTITION_IRST         0x84
 #define PARTITION_LINUX_EXT    0x85
 #define PARTITION_LINUX_LVM    0x8e
 #define PARTITION_HFS          0xaf
@@ -159,6 +160,7 @@ typedef struct {
        int             palo;
        int             prep;
        int             diag;
+       int             irst;
        OrigState*      orig;                   /* used for CHS stuff */
 } DosPartitionData;
 
@@ -924,6 +926,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* 
raw_part,
        dos_data->lba = raw_part_is_lba (raw_part);
        dos_data->palo = raw_part->type == PARTITION_PALO;
        dos_data->prep = raw_part->type == PARTITION_PREP;
+       dos_data->irst = raw_part->type == PARTITION_IRST;
        dos_data->orig = ped_malloc (sizeof (OrigState));
        if (!dos_data->orig) {
                ped_partition_destroy (part);
@@ -1326,6 +1329,7 @@ msdos_partition_new (const PedDisk* disk, 
PedPartitionType part_type,
                dos_data->lba = 0;
                dos_data->palo = 0;
                dos_data->prep = 0;
+               dos_data->irst = 0;
        } else {
                part->disk_specific = NULL;
        }
@@ -1361,6 +1365,7 @@ msdos_partition_duplicate (const PedPartition* part)
        new_dos_data->lba = old_dos_data->lba;
        new_dos_data->palo = old_dos_data->palo;
        new_dos_data->prep = old_dos_data->prep;
+       new_dos_data->irst = old_dos_data->irst;
 
        if (old_dos_data->orig) {
                new_dos_data->orig = ped_malloc (sizeof (OrigState));
@@ -1409,6 +1414,7 @@ msdos_partition_set_system (PedPartition* part,
                dos_data->lvm = 0;
                dos_data->palo = 0;
                dos_data->prep = 0;
+               dos_data->irst = 0;
                if (dos_data->lba)
                        dos_data->system = PARTITION_EXT_LBA;
                else
@@ -1441,6 +1447,10 @@ msdos_partition_set_system (PedPartition* part,
                dos_data->system = PARTITION_PREP;
                return 1;
        }
+       if (dos_data->irst) {
+               dos_data->system = PARTITION_IRST;
+               return 1;
+       }
 
        if (!fs_type)
                dos_data->system = PARTITION_LINUX;
@@ -1477,6 +1487,7 @@ clear_flags (DosPartitionData *dos_data)
   dos_data->lvm = 0;
   dos_data->palo = 0;
   dos_data->prep = 0;
+  dos_data->irst = 0;
   dos_data->raid = 0;
 }
 
@@ -1555,6 +1566,12 @@ msdos_partition_set_flag (PedPartition* part,
                dos_data->prep = state;
                return ped_partition_set_system (part, part->fs_type);
 
+       case PED_PARTITION_IRST:
+               if (state)
+                       clear_flags (dos_data);
+               dos_data->irst = state;
+               return ped_partition_set_system (part, part->fs_type);
+
        default:
                return 0;
        }
@@ -1597,6 +1614,9 @@ msdos_partition_get_flag (const PedPartition* part, 
PedPartitionFlag flag)
        case PED_PARTITION_PREP:
                return dos_data->prep;
 
+       case PED_PARTITION_IRST:
+               return dos_data->irst;
+
        default:
                return 0;
        }
@@ -1619,6 +1639,7 @@ msdos_partition_is_flag_available (const PedPartition* 
part,
        case PED_PARTITION_LBA:
        case PED_PARTITION_PALO:
        case PED_PARTITION_PREP:
+       case PED_PARTITION_IRST:
        case PED_PARTITION_DIAG:
                return 1;
 
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 25490af..0b7d08b 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -146,6 +146,10 @@ typedef struct
     ((efi_guid_t) { PED_CPU_TO_LE32 (0x5265636F), PED_CPU_TO_LE16 (0x7665), \
                     PED_CPU_TO_LE16 (0x11AA), 0xaa, 0x11, \
                     { 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC }})
+#define PARTITION_IRST_GUID \
+    ((efi_guid_t) { PED_CPU_TO_LE32 (0xD3BFE2DE), PED_CPU_TO_LE16 (0x3DAF), \
+                    PED_CPU_TO_LE16 (0x11DF), 0xba, 0x40, \
+                    { 0xE3, 0xA5, 0x56, 0xD8, 0x95, 0x93 }})
 
 struct __attribute__ ((packed)) _GuidPartitionTableHeader_t
 {
@@ -288,6 +292,7 @@ typedef struct _GPTPartitionData
   int atvrecv;
   int msftrecv;
   int legacy_boot;
+  int irst;
 } GPTPartitionData;
 
 static PedDiskType gpt_disk_type;
@@ -797,6 +802,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
     = gpt_part_data->msftdata
     = gpt_part_data->msftrecv
     = gpt_part_data->legacy_boot
+    = gpt_part_data->irst
     = gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
 
   if (pte->Attributes.RequiredToFunction & 0x1)
@@ -822,6 +828,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
     gpt_part_data->msftrecv = 1;
   else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID))
     gpt_part_data->atvrecv = 1;
+  else if (!guid_cmp (gpt_part_data->type, PARTITION_IRST_GUID))
+    gpt_part_data->irst = 1;
 
   return part;
 }
@@ -1339,6 +1347,7 @@ gpt_partition_new (const PedDisk *disk,
   gpt_part_data->msftrecv = 0;
   gpt_part_data->atvrecv = 0;
   gpt_part_data->legacy_boot = 0;
+  gpt_part_data->irst = 0;
   uuid_generate ((unsigned char *) &gpt_part_data->uuid);
   swap_uuid_and_efi_guid ((unsigned char *) (&gpt_part_data->uuid));
   memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
@@ -1447,6 +1456,11 @@ gpt_partition_set_system (PedPartition *part,
       gpt_part_data->type = PARTITION_APPLE_TV_RECOVERY_GUID;
       return 1;
     }
+  if (gpt_part_data->irst)
+    {
+      gpt_part_data->type = PARTITION_IRST_GUID;
+      return 1;
+    }
 
   if (fs_type)
     {
@@ -1588,6 +1602,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->msftres
           = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_BIOS_GRUB:
@@ -1600,6 +1615,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->msftres
           = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_RAID:
@@ -1612,6 +1628,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->msftres
           = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_LVM:
@@ -1624,6 +1641,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->msftres
           = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_HPSERVICE:
@@ -1636,6 +1654,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->msftres
           = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_MSFT_RESERVED:
@@ -1648,6 +1667,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->hp_service
           = gpt_part_data->msftdata
           = gpt_part_data->msftrecv
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_MSFT_DATA:
@@ -1660,6 +1680,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->hp_service
           = gpt_part_data->msftres
           = gpt_part_data->msftrecv
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
         gpt_part_data->msftdata = 1;
       } else {
@@ -1676,6 +1697,7 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->hp_service
           = gpt_part_data->msftdata
           = gpt_part_data->msftres
+          = gpt_part_data->irst
           = gpt_part_data->atvrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_APPLE_TV_RECOVERY:
@@ -1688,8 +1710,22 @@ gpt_partition_set_flag (PedPartition *part, 
PedPartitionFlag flag, int state)
           = gpt_part_data->hp_service
           = gpt_part_data->msftres
           = gpt_part_data->msftdata
+          = gpt_part_data->irst
           = gpt_part_data->msftrecv = 0;
       return gpt_partition_set_system (part, part->fs_type);
+    case PED_PARTITION_IRST:
+      gpt_part_data->irst = 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->msftdata
+          = gpt_part_data->msftrecv
+          = gpt_part_data->atvrecv = 0;
+      return gpt_partition_set_system (part, part->fs_type);
     case PED_PARTITION_HIDDEN:
       gpt_part_data->hidden = state;
       return 1;
@@ -1736,6 +1772,8 @@ gpt_partition_get_flag (const PedPartition *part, 
PedPartitionFlag flag)
       return gpt_part_data->hidden;
     case PED_PARTITION_LEGACY_BOOT:
       return gpt_part_data->legacy_boot;
+    case PED_PARTITION_IRST:
+      return gpt_part_data->irst;
     case PED_PARTITION_SWAP:
     case PED_PARTITION_LBA:
     case PED_PARTITION_ROOT:
@@ -1762,6 +1800,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
     case PED_PARTITION_APPLE_TV_RECOVERY:
     case PED_PARTITION_HIDDEN:
     case PED_PARTITION_LEGACY_BOOT:
+    case PED_PARTITION_IRST:
       return 1;
     case PED_PARTITION_SWAP:
     case PED_PARTITION_ROOT:
-- 
1.8.3.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]