MBR.h
Go to the documentation of this file.
1 /****
2  * MBR.h
3  *
4  * Copyright 2022 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the DiskStorage Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
22 #include "PartInfo.h"
23 #include "Error.h"
24 #include "BlockDevice.h"
25 
26 namespace Storage::Disk
27 {
28 namespace MBR
29 {
30 class PartitionTable : public BasePartitionTable
31 {
32 public:
43  bool add(SysType sysType, SysIndicator sysIndicator, storage_size_t offset, storage_size_t size,
44  Partition::Flags flags = 0)
45  {
46  auto part =
47  new PartInfo(nullptr, fatTypes[sysType] ? Partition::SubType::Data::fat : Partition::SubType::Data::any,
48  offset, size, 0);
49  if(part == nullptr) {
50  return false;
51  }
52  part->systype = sysType;
53  part->sysind = sysIndicator;
54  return BasePartitionTable::add(part);
55  }
56 };
57 
58 } // namespace MBR
59 
66 Error formatDisk(BlockDevice& device, MBR::PartitionTable& table);
67 
68 } // namespace Storage::Disk
Error
Definition: Libraries/DiskStorage/src/include/Storage/Disk/Error.h:54
Error formatDisk(BlockDevice &device, GPT::PartitionTable &table, const Uuid &diskGuid={})
Partition a device using the GPT scheme.
BitSet< uint32_t, Flag > Flags
Definition: Partition.h:134
bool add(SysType sysType, SysIndicator sysIndicator, storage_size_t offset, storage_size_t size, Partition::Flags flags=0)
Add a new MBR partition definition.
Definition: MBR.h:94
bool add(ObjectType *object)
Definition: LinkedObjectList.h:134
Definition: Partition.h:77
SysType
Identifies exact disk volume type.
Definition: PartInfo.h:57
static constexpr SysTypes fatTypes
Definition: PartInfo.h:67
In-memory partition information.
Definition: PartInfo.h:119
uint32_t storage_size_t
Definition: Components/Storage/src/include/Storage/Types.h:19
SysIndicator
MBR partition system type indicator values.
Definition: PartInfo.h:73