srs5694 | 221e087 | 2009-08-29 15:00:31 -0400 | [diff] [blame] | 1 | /* This program is copyright (c) 2009 by Roderick W. Smith. It is distributed |
| 2 | under the terms of the GNU GPL version 2, as detailed in the COPYING file. */ |
| 3 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | #include <unistd.h> |
| 6 | #include <stdlib.h> |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 7 | #include <string> |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 8 | #include "support.h" |
| 9 | |
| 10 | #ifndef __PARTITION_TYPES |
| 11 | #define __PARTITION_TYPES |
| 12 | |
| 13 | // Set the size of the name string |
| 14 | #define PNAME_SIZE 80 |
| 15 | |
| 16 | using namespace std; |
| 17 | |
| 18 | // A partition type |
| 19 | struct AType { |
| 20 | // I'm using a custom 16-bit extension of the original MBR 8-bit |
| 21 | // type codes, so as to permit disambiguation and use of new |
| 22 | // codes required by GPT |
| 23 | uint16_t MBRType; |
| 24 | struct GUIDData GUIDType; |
| 25 | char name[PNAME_SIZE]; |
| 26 | int display; // 1 to show to users as available type, 0 not to |
| 27 | AType* next; |
| 28 | }; // struct AType |
| 29 | |
| 30 | class PartTypes { |
| 31 | protected: |
| 32 | static int numInstances; |
| 33 | static AType* allTypes; // Linked list holding all the data |
| 34 | static AType* lastType; // Pointer to last entry in the list |
| 35 | public: |
| 36 | PartTypes(void); |
| 37 | ~PartTypes(void); |
| 38 | int AddType(uint16_t mbrType, uint64_t guidData1, uint64_t guidData2, |
| 39 | const char* name, int toDisplay = 1); |
| 40 | void ShowTypes(void); |
| 41 | int Valid(uint16_t); |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 42 | string GUIDToName(struct GUIDData typeCode); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 43 | struct GUIDData IDToGUID(uint16_t ID); |
| 44 | uint16_t GUIDToID(struct GUIDData); |
| 45 | }; |
| 46 | |
| 47 | #endif |