xref: /haiku/src/add-ons/kernel/partitioning_systems/common/PartitionMapWriter.h (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
1 /*
2  * Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Tomas Kucera, kucerat@centrum.cz
7  *		Bryce Groff, brycegroff@gmail.com
8  */
9 
10 /*!
11 	\file PartitionMapWriter.h
12 	\ingroup intel_module
13 	\brief Implementation of disk writer for "intel" style partitions.
14 
15 	Writer can write \b Master \b Boot \b Record or \b Extended \b Boot
16 	\b Records to the disk according to partitions defined in \c PartitionMap
17 	structure.
18 */
19 
20 
21 #ifndef PARTITION_MAP_WRITER_H
22 #define PARTITION_MAP_WRITER_H
23 
24 
25 #include <SupportDefs.h>
26 
27 
28 class PartitionMap;
29 class LogicalPartition;
30 class PrimaryPartition;
31 struct partition_table;
32 
33 bool check_logical_location(const LogicalPartition* logical,
34 	const PrimaryPartition* primary);
35 
36 /*!
37   \brief Writer for "Intel" style partitions.
38 
39   This class serves for writing \a primary and \a logical \a partitions to disk.
40 */
41 class PartitionMapWriter {
42 public:
43 								PartitionMapWriter(int deviceFD,
44 									uint32 blockSize);
45 								~PartitionMapWriter();
46 
47 			status_t			WriteMBR(const PartitionMap* map,
48 									bool writeBootCode);
49 			status_t			WriteLogical(const LogicalPartition* logical,
50 									const PrimaryPartition* primary,
51 									bool clearCode);
52 			status_t			WriteExtendedHead(
53 									const LogicalPartition* logical,
54 									const PrimaryPartition* primary,
55 									bool clearCode);
56 
57 			status_t			ClearExtendedHead(
58 									const PrimaryPartition* primary);
59 
60 private:
61 			status_t			_ReadBlock(off_t offset,
62 									partition_table& partitionTable);
63 			status_t			_WriteBlock(off_t offset,
64 									const partition_table& partitionTable);
65 
66 private:
67 			int					fDeviceFD;
68 			int32				fBlockSize;
69 
70 };
71 
72 #endif	// PARTITION_MAP_WRITER_H
73