PartitionEditor: Add the beginnings of a partition editor :^)
This adds a new application PartitionEditor which will eventually be
used to create and edit partition tables. Since LibPartition does not
know how to write partition tables yet, it is currently read-only.
Devices are discovered by scanning /dev for block device files.
Since block devices are chmod 600, PartitionEditor be must run as root.
By default Serenity uses the entire disk for the ext2 filesystem
without a partition table. This isn't useful for testing as the
partition list for the default disk will be empty. To test properly,
I created a few disk images using various partitioning schemes
(MBR, EBR, and GPT) and attached them using the following command:
export SERENITY_EXTRA_QEMU_ARGS="
-drive file=/path/to/mbr.img,format=raw,index=1,media=disk
-drive file=/path/to/ebr.img,format=raw,index=2,media=disk
-drive file=/path/to/gpt.img,format=raw,index=3,media=disk"
2022-06-27 23:48:30 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2022, Samuel Bowman <sam@sambowman.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibGUI/Model.h>
|
|
|
|
|
#include <LibPartition/PartitionTable.h>
|
|
|
|
|
|
|
|
|
|
namespace PartitionEditor {
|
|
|
|
|
|
|
|
|
|
class PartitionModel final : public GUI::Model {
|
|
|
|
|
public:
|
|
|
|
|
enum Column {
|
|
|
|
|
Partition,
|
|
|
|
|
StartBlock,
|
|
|
|
|
EndBlock,
|
2022-06-28 20:15:35 -03:00
|
|
|
TotalBlocks,
|
2022-06-29 20:21:21 -03:00
|
|
|
Size,
|
PartitionEditor: Add the beginnings of a partition editor :^)
This adds a new application PartitionEditor which will eventually be
used to create and edit partition tables. Since LibPartition does not
know how to write partition tables yet, it is currently read-only.
Devices are discovered by scanning /dev for block device files.
Since block devices are chmod 600, PartitionEditor be must run as root.
By default Serenity uses the entire disk for the ext2 filesystem
without a partition table. This isn't useful for testing as the
partition list for the default disk will be empty. To test properly,
I created a few disk images using various partitioning schemes
(MBR, EBR, and GPT) and attached them using the following command:
export SERENITY_EXTRA_QEMU_ARGS="
-drive file=/path/to/mbr.img,format=raw,index=1,media=disk
-drive file=/path/to/ebr.img,format=raw,index=2,media=disk
-drive file=/path/to/gpt.img,format=raw,index=3,media=disk"
2022-06-27 23:48:30 -03:00
|
|
|
__Count,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static NonnullRefPtr<PartitionModel> create() { return adopt_ref(*new PartitionModel()); }
|
|
|
|
|
virtual ~PartitionModel() override = default;
|
|
|
|
|
|
|
|
|
|
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return m_partition_table->partitions_count(); }
|
|
|
|
|
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
|
|
|
|
|
virtual String column_name(int) const override;
|
|
|
|
|
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
|
|
|
|
|
|
|
|
|
|
ErrorOr<void> set_device_path(String const&);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
PartitionModel() = default;
|
|
|
|
|
|
|
|
|
|
OwnPtr<Partition::PartitionTable> m_partition_table;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|