@@ -35,29 +35,57 @@ struct __attribute__((packed)) mbrTable {
35
35
class Partitioning {
36
36
public:
37
37
/* *
38
- * This method erases the first block (4096 bytes) of the BlockDevice to delete any already existing MBR partition table
38
+ * Erases the first block (4096 bytes) of the BlockDevice to delete any already existing MBR partition table
39
39
* @param The BlockDevice on which the MBR sector is situated.
40
40
* @returns True upon success, False on failure
41
41
*/
42
42
static bool eraseMBRSector (BlockDeviceType * blockDevice);
43
43
44
44
/* *
45
- * This method partitions the BlockDevice according to the partitioning schemme given by the vector of Partition structs
45
+ * Partitions the BlockDevice according to the partitioning schemme given by the vector of Partition structs
46
46
* @param blockDevice - the BlockDevice which we would like to partition.
47
47
* @param partitions - a vector of Partition structs that represents the partitioning scheme
48
48
* @returns True upon success, False on failure
49
49
*/
50
50
static bool partitionDrive (BlockDeviceType * blockDevice, std::vector<Partition> partitions);
51
51
52
52
/* *
53
- * This method reads and unpacks the MBR partition information and returns a list of partitions it can find on the drive
53
+ * Reads and unpacks the MBR partition information and returns a list of partitions it can find on the drive
54
54
* @param blockDevice on which the MBR sector is situated.
55
55
* @returns std::vector of Partition containing size and filesystem information about each partition
56
56
*/
57
57
static std::vector<Partition> readPartitions (BlockDeviceType * blockDevice);
58
58
private:
59
+ /* *
60
+ * Checks if the given partition scheme is valid for the specified block device.
61
+ * It does that by checking if the sum of the partition sizes is equal to the size of the block device and
62
+ * by ensuring that there are a maximum of 4 partitions.
63
+ *
64
+ * @param blockDevice The block device to check the partition scheme against.
65
+ * @param partitions The partition scheme to check for validity.
66
+ * @return True if the partition scheme is valid for the block device, false otherwise.
67
+ */
59
68
static bool isPartitionSchemeValid (BlockDeviceType * blockDevice, std::vector<Partition> partitions);
69
+
70
+
71
+ /* *
72
+ * Formats the specified partition of the given block device with the specified file system type.
73
+ *
74
+ * @param blockDevice The block device to format the partition on.
75
+ * @param partitionNumber The number of the partition to format.
76
+ * @param fileSystemType The file system type to format the partition with.
77
+ * @return True if the partition was formatted successfully, false otherwise.
78
+ */
60
79
static bool formatPartition (BlockDeviceType * blockDevice, int partitionNumber, FileSystems fileSystemType);
80
+
81
+ /* *
82
+ * Creates and formats partitions on the specified block device.
83
+ * The partitioning splits the block device into partitions of the specified sizes and formats them with the specified file system types.
84
+ *
85
+ * @param blockDevice Pointer to the block device to partition and format.
86
+ * @param partitions Vector of Partition objects representing the partitions to create and format.
87
+ * @return True if all partitions were successfully created and formatted, false otherwise.
88
+ */
61
89
static bool createAndFormatPartitions (BlockDeviceType * blockDevice, std::vector<Partition> partitions);
62
90
63
91
};
0 commit comments