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 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 13 | using namespace std; |
| 14 | |
| 15 | // A partition type |
| 16 | struct AType { |
| 17 | // I'm using a custom 16-bit extension of the original MBR 8-bit |
| 18 | // type codes, so as to permit disambiguation and use of new |
| 19 | // codes required by GPT |
| 20 | uint16_t MBRType; |
| 21 | struct GUIDData GUIDType; |
srs5694 | e321d44 | 2010-01-29 17:44:04 -0500 | [diff] [blame] | 22 | string name; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 23 | int display; // 1 to show to users as available type, 0 not to |
| 24 | AType* next; |
| 25 | }; // struct AType |
| 26 | |
| 27 | class PartTypes { |
| 28 | protected: |
| 29 | static int numInstances; |
| 30 | static AType* allTypes; // Linked list holding all the data |
| 31 | static AType* lastType; // Pointer to last entry in the list |
| 32 | public: |
| 33 | PartTypes(void); |
| 34 | ~PartTypes(void); |
| 35 | int AddType(uint16_t mbrType, uint64_t guidData1, uint64_t guidData2, |
srs5694 | e321d44 | 2010-01-29 17:44:04 -0500 | [diff] [blame] | 36 | const char * name, int toDisplay = 1); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 37 | void ShowTypes(void); |
| 38 | int Valid(uint16_t); |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 39 | string GUIDToName(struct GUIDData typeCode); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 40 | struct GUIDData IDToGUID(uint16_t ID); |
| 41 | uint16_t GUIDToID(struct GUIDData); |
| 42 | }; |
| 43 | |
| 44 | #endif |