blob: 5777f9c6670378c4416dfe54402023f524911019 [file] [log] [blame]
srs5694221e0872009-08-29 15:00:31 -04001/* 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
srs5694e7b4ff92009-08-18 13:16:10 -04004#include <stdint.h>
5#include <unistd.h>
6#include <stdlib.h>
srs5694fed16d02010-01-27 23:03:40 -05007#include <string>
srs5694e7b4ff92009-08-18 13:16:10 -04008#include "support.h"
srs56946699b012010-02-04 00:55:30 -05009#include "guid.h"
srs5694e7b4ff92009-08-18 13:16:10 -040010
11#ifndef __PARTITION_TYPES
12#define __PARTITION_TYPES
13
srs5694e7b4ff92009-08-18 13:16:10 -040014using namespace std;
15
16// A partition type
17struct AType {
18 // I'm using a custom 16-bit extension of the original MBR 8-bit
19 // type codes, so as to permit disambiguation and use of new
20 // codes required by GPT
21 uint16_t MBRType;
srs56946699b012010-02-04 00:55:30 -050022 GUIDData GUIDType;
srs5694e321d442010-01-29 17:44:04 -050023 string name;
srs5694e7b4ff92009-08-18 13:16:10 -040024 int display; // 1 to show to users as available type, 0 not to
25 AType* next;
26}; // struct AType
27
srs56946699b012010-02-04 00:55:30 -050028class PartType : public GUIDData {
srs5694e7b4ff92009-08-18 13:16:10 -040029protected:
30 static int numInstances;
31 static AType* allTypes; // Linked list holding all the data
32 static AType* lastType; // Pointer to last entry in the list
srs56946699b012010-02-04 00:55:30 -050033 void AddAllTypes(void);
srs5694e7b4ff92009-08-18 13:16:10 -040034public:
srs56946699b012010-02-04 00:55:30 -050035 PartType(void);
36 PartType(const PartType & orig);
37 PartType(const GUIDData & orig);
38 ~PartType(void);
39
40 // Set up type information
41 int AddType(uint16_t mbrType, const char * guidData, const char * name, int toDisplay = 1);
42
43 // Assignment operators based on base class....
44 GUIDData & operator=(const GUIDData & orig) {return GUIDData::operator=(orig);}
45 GUIDData & operator=(const string & orig) {return GUIDData::operator=(orig);}
46 GUIDData & operator=(const char * orig) {return GUIDData::operator=(orig);}
47
48 // New data assignment
srs5694cb76c672010-02-11 22:22:22 -050049 PartType & operator=(uint16_t ID); // Use MBR type code times 0x0100 to assign GUID
srs56946699b012010-02-04 00:55:30 -050050
51 // Retrieve transformed GUID data based on type code matches
52 string TypeName(void);
53 uint16_t GetHexType();
54
55 // Information relating to all type data
56 void ShowAllTypes(void);
srs5694e7b4ff92009-08-18 13:16:10 -040057 int Valid(uint16_t);
srs5694e7b4ff92009-08-18 13:16:10 -040058};
59
60#endif