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 #ifndef PARTITION_MAP_PARSER_H 9 #define PARTITION_MAP_PARSER_H 10 11 12 #include <SupportDefs.h> 13 14 15 class Partition; 16 class PartitionMap; 17 class PrimaryPartition; 18 struct partition_table_sector; 19 20 class PartitionMapParser { 21 public: 22 PartitionMapParser(int deviceFD, off_t sessionOffset, off_t sessionSize, 23 int32 blockSize); 24 ~PartitionMapParser(); 25 26 status_t Parse(const uint8 *block, PartitionMap *map); 27 28 int32 CountPartitions() const; 29 const Partition *PartitionAt(int32 index) const; 30 31 private: 32 status_t _ParsePrimary(const partition_table_sector *pts); 33 status_t _ParseExtended(PrimaryPartition *primary, off_t offset); 34 status_t _ReadPTS(off_t offset, partition_table_sector *pts = NULL); 35 36 private: 37 int fDeviceFD; 38 off_t fSessionOffset; 39 off_t fSessionSize; 40 int32 fBlockSize; 41 partition_table_sector *fPTS; // while parsing 42 PartitionMap *fMap; 43 }; 44 45 #endif // PARTITION_MAP_PARSER_H 46