From d72ef990a3a417e4f9062517313afe325e7035e6 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 12 Feb 2020 10:13:23 -0600 Subject: DiskMan: Add partition support, codify the source of creation objects --- diskman/disk.hh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'diskman/disk.hh') diff --git a/diskman/disk.hh b/diskman/disk.hh index dcb9793..dc149e7 100644 --- a/diskman/disk.hh +++ b/diskman/disk.hh @@ -13,8 +13,10 @@ #ifndef DISKMAN__DISK_HH #define DISKMAN__DISK_HH -#include #include +#include + +#include "partition.hh" namespace Horizon { namespace DiskMan { @@ -62,6 +64,22 @@ public: /*! Retrieve the label of the file system written on this disk. * Only valid if has_fs() is true. */ const std::string fs_label() const { return this->_fs_label; } + + /*! Retrieve the total size of the disk. + * @returns The size of the disk, in mebibytes (MiB). */ + uint32_t total_size() const { return this->total_mb; } + /*! Retrieve the amount of free space available on the disk. + * @returns The size of free space on the disk, in mebibytes (MiB). */ + uint32_t free_space() const { return this->free_mb; } + /*! Retrieve the size of the largest contiguous block of free space on + * the disk. + * @returns The size of the largest contiguous free space block on the + * disk, in mebibytes (MiB). */ + uint32_t contiguous_block() const { return this->contiguous_mb; } + + /*! Retrieve the partitions contained in the label, if any. + * @note You may only call this method if *has_label* is true. */ + const std::vector partitions() const; private: /*! The name of the disk ("sda") */ std::string _name; @@ -78,6 +96,8 @@ private: bool _has_label; /*! The type of disk label used, if +has_label+ is true */ enum Label _label; + /*! Partitions inside the disklabel */ + std::vector _partitions; /*! Whether this disk has a direct filesystem (non-labelled) */ bool _has_fs; @@ -86,7 +106,14 @@ private: /*! The label of the file system, if +has_fs+ is true */ std::string _fs_label; - Disk(void *creation, bool partition); + /*! Total size of this disk, in mebibytes */ + uint32_t total_mb; + /*! Free space on this disk, in mebibytes */ + uint32_t free_mb; + /*! Largest contiguous block of free space on this disk, in mebibytes */ + uint32_t contiguous_mb; + + Disk(void *creation, int type, bool partition); friend class DiskMan; }; -- cgit v1.2.3-70-g09d2