xref: /haiku/src/add-ons/kernel/partitioning_systems/intel/PartitionMapParser.h (revision f75a7bf508f3156d63a14f8fd77c5e0ca4d08c42)
1 /*
2  * Copyright 2003-2006, 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 /*!
10 	\file PartitionMapParser.h
11 	\brief Implementation of disk parser for "intel" style partitions.
12 
13 	Parser reads primary and logical partitions from the disk (according to
14 	Master Boot and Extended Boot Records) and fills \c PartitionMap structure
15 	with partition representation.
16 */
17 #ifndef PARTITION_MAP_PARSER_H
18 #define PARTITION_MAP_PARSER_H
19 
20 
21 #include <SupportDefs.h>
22 
23 
24 class Partition;
25 class PartitionMap;
26 class PrimaryPartition;
27 struct partition_table_sector;
28 
29 class PartitionMapParser {
30 	public:
31 		PartitionMapParser(int deviceFD, off_t sessionOffset,
32 			off_t sessionSize);
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_sector *pts);
42 		status_t _ParseExtended(PrimaryPartition *primary, off_t offset);
43 		status_t _ReadPTS(off_t offset, partition_table_sector *pts = NULL);
44 
45 	private:
46 		int						fDeviceFD;
47 		off_t					fSessionOffset;
48 		off_t					fSessionSize;
49 		partition_table_sector	*fPTS;	// while parsing
50 		PartitionMap			*fMap;
51 };
52 
53 #endif	// PARTITION_MAP_PARSER_H
54