summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diskman/man/Horizon::DiskMan::Partition.310
-rw-r--r--diskman/partition.cc3
-rw-r--r--diskman/partition.hh4
3 files changed, 16 insertions, 1 deletions
diff --git a/diskman/man/Horizon::DiskMan::Partition.3 b/diskman/man/Horizon::DiskMan::Partition.3
index 78d3748..99d1915 100644
--- a/diskman/man/Horizon::DiskMan::Partition.3
+++ b/diskman/man/Horizon::DiskMan::Partition.3
@@ -11,6 +11,9 @@
.Fo Partition::size
.Fc
.Ft const std::string
+.Fo Partition::node
+.Fc
+.Ft const std::string
.Fo Partition::fs_type
.Fc
.Ft const std::string
@@ -26,6 +29,10 @@ The
function provides the size of the partition.
.Pp
The
+.Fn Partition::node
+function provides the device node of the partition.
+.Pp
+The
.Fn Partition::fs_type
and
.Fn Partition::fs_label
@@ -37,7 +44,8 @@ The
function returns the size of the partition in bytes.
.Pp
The
-.Fn Partition::fs_type
+.Fn Partition::node ,
+.Fn Partition::fs_type ,
and
.Fn Partition::fs_label
functions return the requested information as std::string.
diff --git a/diskman/partition.cc b/diskman/partition.cc
index 9aa5d22..323cd30 100644
--- a/diskman/partition.cc
+++ b/diskman/partition.cc
@@ -33,6 +33,7 @@ Partition::Partition(Disk &d, void *creation, int type) {
}
char *name = fdisk_partname(d.node().c_str(),
fdisk_partition_get_partno(part) + 1);
+ this->_node = std::string(name);
char *value;
value = blkid_get_tag_value(nullptr, "TYPE", name);
if(value != nullptr) {
@@ -56,6 +57,8 @@ Partition::Partition(Disk &d, void *creation, int type) {
if(value != nullptr) this->_label = std::string(value);
value = udev_device_get_property_value(dev, "ID_PART_ENTRY_SIZE");
if(value != nullptr) this->_size = strtoull(value, nullptr, 10) * 512;
+ value = udev_device_get_property_value(dev, "DEVNAME");
+ if(value != nullptr) this->_node = std::string(value);
break;
}
default:
diff --git a/diskman/partition.hh b/diskman/partition.hh
index 93090d8..8e6274b 100644
--- a/diskman/partition.hh
+++ b/diskman/partition.hh
@@ -29,6 +29,8 @@ public:
const std::string fstype() const { return this->_fs_type; }
/*! Retrieve the label of the file system on this partition. */
const std::string label() const { return this->_label; }
+ /*! Retrieve the device node of this partition (for example, /dev/sda1). */
+ const std::string node() const { return this->_node; }
private:
/*! The size of the partition, in bytes. */
uint64_t _size;
@@ -36,6 +38,8 @@ private:
std::string _fs_type;
/*! The label of the file system on this partition (if any) */
std::string _label;
+ /*! The device node of this partition. */
+ std::string _node;
Partition(Disk &d, void *creation, int type);
friend class Disk;
};