vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / partitioning_systems / intel / PartitionMapParser.h
blob7034bacdd90123f7e104b74e1a980b894ddfccf8
1 /*
2 * Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ingo Weinhold, bonefish@cs.tu-berlin.de
7 */
9 /*! \file PartitionMapParser.h
10 \brief Implementation of disk parser for "intel" style partitions.
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.
16 #ifndef PARTITION_MAP_PARSER_H
17 #define PARTITION_MAP_PARSER_H
20 #include <SupportDefs.h>
23 class Partition;
24 class PartitionMap;
25 class PrimaryPartition;
26 struct partition_table;
28 class PartitionMapParser {
29 public:
30 PartitionMapParser(int deviceFD,
31 off_t sessionOffset, off_t sessionSize,
32 uint32 blockSize);
33 ~PartitionMapParser();
35 status_t Parse(const uint8* block, PartitionMap* map);
37 int32 CountPartitions() const;
38 const Partition* PartitionAt(int32 index) const;
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);
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;
57 #endif // PARTITION_MAP_PARSER_H