<commit_before>with HAL; use HAL;
with HAL.Block_Drivers; use HAL.Block_Drivers;
with Interfaces; use Interfaces;

package Partitions is

   type Partition_Kind is
     (Empty_Partition,
      Fat12_Parition,
      Fat16_Parition,
      Extended_Parition,
      Fat16B_Parition,
      NTFS_Partition,
      Fat32_CHS_Parition,
      Fat32_LBA_Parition,
      Fat16B_LBA_Parition,
      Extended_LBA_Parition,
      Linux_Partition)
     with Size => 8;

   subtype Logical_Block_Address is Unsigned_32;

   type CHS_Address is record
      C : UInt10;
      H : Byte;
      S : UInt6;
   end record with Pack, Size => 24;

   type Partition_Entry is record
      Status            : Byte;
      First_Sector_CHS  : CHS_Address;
      Kind              : Partition_Kind;
      Last_Sector_CHS   : CHS_Address;
      First_Sector_LBA  : Logical_Block_Address;
      Number_Of_Sectors : Unsigned_32;
   end record with Pack, Size => 16 * 8;

   type Status_Code is (Status_Ok, Disk_Error, Invalid_Parition);

   function Get_Partition_Entry (Disk         : not null Block_Driver_Ref;
                                 Entry_Number : Positive;
                                 P_Entry      : out Partition_Entry)
                                 return Status_Code;

   function Number_Of_Partitions (Disk : Block_Driver_Ref) return Natural;

   function Is_Valid (P_Entry : Partition_Entry) return Boolean is
     (P_Entry.Status = 16#00# or else P_Entry.Status = 16#80#);

private

   for Partition_Kind use
     (Empty_Partition       => 16#00#,
      Fat12_Parition        => 16#01#,
      Fat16_Parition        => 16#04#,
      Extended_Parition     => 16#05#,
      Fat16B_Parition       => 16#06#,
      NTFS_Partition        => 16#07#,
      Fat32_CHS_Parition    => 16#0B#,
      Fat32_LBA_Parition    => 16#0C#,
      Fat16B_LBA_Parition   => 16#0E#,
      Extended_LBA_Parition => 16#0F#,
      Linux_Partition       => 16#83#);
end Partitions;<commit_msg>Partitions: Change Parition_Kind to Unsigned_8<commit_after>with HAL; use HAL;
with HAL.Block_Drivers; use HAL.Block_Drivers;
with Interfaces; use Interfaces;

package Partitions is

   type Partition_Kind is new Unsigned_8;

   Empty_Partition       : constant Partition_Kind := 16#00#;
   Fat12_Parition        : constant Partition_Kind := 16#01#;
   Fat16_Parition        : constant Partition_Kind := 16#04#;
   Extended_Parition     : constant Partition_Kind := 16#05#;
   Fat16B_Parition       : constant Partition_Kind := 16#06#;
   NTFS_Partition        : constant Partition_Kind := 16#07#;
   Fat32_CHS_Parition    : constant Partition_Kind := 16#0B#;
   Fat32_LBA_Parition    : constant Partition_Kind := 16#0C#;
   Fat16B_LBA_Parition   : constant Partition_Kind := 16#0E#;
   Extended_LBA_Parition : constant Partition_Kind := 16#0F#;
   Linux_Swap_Partition  : constant Partition_Kind := 16#82#;
   Linux_Partition       : constant Partition_Kind := 16#83#;

   subtype Logical_Block_Address is Unsigned_32;

   type CHS_Address is record
      C : UInt10;
      H : Byte;
      S : UInt6;
   end record with Pack, Size => 24;

   type Partition_Entry is record
      Status            : Byte;
      First_Sector_CHS  : CHS_Address;
      Kind              : Partition_Kind;
      Last_Sector_CHS   : CHS_Address;
      First_Sector_LBA  : Logical_Block_Address;
      Number_Of_Sectors : Unsigned_32;
   end record with Pack, Size => 16 * 8;

   type Status_Code is (Status_Ok, Disk_Error, Invalid_Parition);

   function Get_Partition_Entry (Disk         : not null Block_Driver_Ref;
                                 Entry_Number : Positive;
                                 P_Entry      : out Partition_Entry)
                                 return Status_Code;

   function Number_Of_Partitions (Disk : Block_Driver_Ref) return Natural;

   function Is_Valid (P_Entry : Partition_Entry) return Boolean is
     (P_Entry.Status = 16#00# or else P_Entry.Status = 16#80#);
end Partitions;
{'fraction_non_alphanumeric': 0.07267221801665405, 'fraction_numerical': 0.04113045672470351, 'mean_word_length': 2.4986760812003532, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4655441', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1255, 'n_words': 295}