xref: /haiku/src/add-ons/kernel/partitioning_systems/intel/PartitionMapParser.h (revision 3904a8dba0df1065db019e58a491c712cdf9cd83)
1 /*
2  * Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ingo Weinhold, bonefish@cs.tu-berlin.de
7  */
8 
9 /*!	\file PartitionMapParser.h
10 	\brief Implementation of disk parser for "intel" style partitions.
11 
12 	Parser reads primary and logical partitions from the disk (according to
13 	Master Boot and Extended Boot Records) and fills \c PartitionMap structure
14 	with partition representation.
15 */
16 #ifndef PARTITION_MAP_PARSER_H
17 #define PARTITION_MAP_PARSER_H
18 
19 
20 #include <SupportDefs.h>
21 
22 
23 class Partition;
24 class PartitionMap;
25 class PrimaryPartition;
26 struct partition_table;
27 
28 class PartitionMapParser {
29 public:
30 								PartitionMapParser(int deviceFD,
31 									off_t sessionOffset, off_t sessionSize,
32 									uint32 blockSize);
33 								~PartitionMapParser();
34 
35 			status_t			Parse(const uint8* block, PartitionMap* map);
36 
37 			int32				CountPartitions() const;
38 			const Partition*	PartitionAt(int32 index) const;
39 
40 private:
41 			status_t			_ParsePrimary(const partition_table* table,
42 									bool& hadToReFitSize);
43 			status_t			_ParseExtended(PrimaryPartition* primary,
44 									off_t offset);
45 			status_t			_ReadPartitionTable(off_t offset,
46 									partition_table* table = NULL);
47 
48 private:
49 			int					fDeviceFD;
50 			uint32				fBlockSize;
51 			off_t				fSessionOffset;
52 			off_t				fSessionSize;
53 			partition_table*	fPartitionTable;	// while parsing
54 			PartitionMap*		fMap;
55 };
56 
57 #endif	// PARTITION_MAP_PARSER_H
58