libstorage-ng
|
A partition of a Partitionable, e.g. More...
#include <Partition.h>
Public Member Functions | |
unsigned int | get_number () const |
Get the partition number. | |
PartitionType | get_type () const |
Get the partition type. More... | |
void | set_type (PartitionType type) |
Set the partition type. More... | |
unsigned int | get_id () const |
Get the partition id. More... | |
void | set_id (unsigned int id) |
Set the partition id. More... | |
bool | is_boot () const |
Query the boot flag of the partition. | |
void | set_boot (bool boot) |
Set the boot flag of the partition. More... | |
bool | is_legacy_boot () const |
Query the legacy boot flag of the partition. | |
void | set_legacy_boot (bool legacy_boot) |
Set the legacy boot flag of the partition. More... | |
bool | is_no_automount () const |
Query the no-automount flag of the partition. | |
void | set_no_automount (bool no_automount) |
Set the no-automount flag of the partition. More... | |
const std::string & | get_label () const |
Get the partition label. More... | |
void | set_label (const std::string &label) |
Set the partition label. More... | |
const std::string & | get_uuid () const |
Get the partition UUID. More... | |
PartitionTable * | get_partition_table () |
Return the partition table the partition belongs to. More... | |
const PartitionTable * | get_partition_table () const |
Return the partition table the partition belongs to. More... | |
Partitionable * | get_partitionable () |
Return the partitionable the partition belongs to. More... | |
const Partitionable * | get_partitionable () const |
Return the partitionable the partition belongs to. More... | |
Region | get_unused_surrounding_region () const |
Returns the unused region surrounding the partition (including the partition itself). More... | |
Impl & | get_impl () |
const Impl & | get_impl () const |
virtual Partition * | clone () const override |
Partition (Impl *impl) | |
![]() | |
const std::string & | get_name () const |
void | set_name (const std::string &name) |
const Region & | get_region () const |
void | set_region (const Region ®ion) |
unsigned long long | get_size () const |
Returns the size of the block device. | |
void | set_size (unsigned long long size) |
Set the size of the block device. More... | |
std::string | get_size_string () const |
Returns the size of the block device as a localised string. More... | |
const Topology & | get_topology () const |
Get the topology. | |
void | set_topology (const Topology &topology) |
Set the topology. More... | |
bool | is_active () const |
bool | is_read_only () const |
Return whether the block device is read-only. More... | |
const std::string & | get_sysfs_name () const |
const std::string & | get_sysfs_path () const |
const std::vector< std::string > & | get_udev_paths () const |
Return the names of the udev by-path links of the blk device. More... | |
const std::vector< std::string > & | get_udev_ids () const |
Return the names of the udev by-id links of the blk device. More... | |
bool | is_usable_as_blk_device () const |
Checks whether the blk device is in general usable as a blk device. More... | |
RemoveInfo | detect_remove_info () const |
Check whether the device can be removed. More... | |
const std::string & | get_dm_table_name () const |
Return device-mapper table name (dm-table-name for short). More... | |
void | set_dm_table_name (const std::string &dm_table_name) |
Set the device-mapper table name (dm-table-name for short). More... | |
BlkFilesystem * | create_blk_filesystem (FsType fs_type) |
Creates a block filesystem on the block device. More... | |
bool | has_blk_filesystem () const |
Return whether the block device has a block filesystem. | |
BlkFilesystem * | get_blk_filesystem () |
Return the block filesystem of the block device. More... | |
const BlkFilesystem * | get_blk_filesystem () const |
Return the block filesystem of the block device. More... | |
BlkFilesystem * | create_filesystem (FsType fs_type) ST_DEPRECATED |
Creates a block filesystem on the block device. More... | |
bool | has_filesystem () const ST_DEPRECATED |
Return whether the block device has a block filesystem. More... | |
BlkFilesystem * | get_filesystem () ST_DEPRECATED |
Return the block filesystem of the block device. More... | |
const BlkFilesystem * | get_filesystem () const ST_DEPRECATED |
Return the block filesystem of the block device. More... | |
Encryption * | create_encryption (const std::string &dm_table_name) ST_DEPRECATED |
Creates an encryption device on the blk device. More... | |
Encryption * | create_encryption (const std::string &dm_table_name, EncryptionType type) |
Creates an encryption device on the blk device. More... | |
void | remove_encryption () |
Removes an encryption device on the blk device. More... | |
bool | has_encryption () const |
Return whether the block device has an Encryption. | |
Encryption * | get_encryption () |
Return the Encryption of the block device. More... | |
const Encryption * | get_encryption () const |
Return the Encryption of the block device. More... | |
Bcache * | create_bcache (const std::string &name) |
Creates a Bcache on the blk device. More... | |
bool | has_bcache () const |
Return whether the block device has a BCache. | |
Bcache * | get_bcache () |
Return the Bcache of the block device. More... | |
const Bcache * | get_bcache () const |
Return the Bcache of the block device. More... | |
BcacheCset * | create_bcache_cset () |
Creates a BcacheCset on the blk device. More... | |
bool | has_bcache_cset () const |
Return whether the block device has a BcacheCset. | |
BcacheCset * | get_bcache_cset () |
Return the BcacheCset of the block device. More... | |
const BcacheCset * | get_bcache_cset () const |
Return the BcacheCset of the block device. More... | |
std::vector< MountByType > | possible_mount_bys () const |
Returns the possible mount-by methods to reference the block device. More... | |
Impl & | get_impl () |
const Impl & | get_impl () const |
![]() | |
sid_t | get_sid () const |
Return the storage id (sid) of the device. More... | |
bool | operator== (const Device &rhs) const |
bool | operator!= (const Device &rhs) const |
Device * | copy_to_devicegraph (Devicegraph *devicegraph) const |
Copies the device to the devicegraph. More... | |
bool | exists_in_devicegraph (const Devicegraph *devicegraph) const |
Checks if the device exists in the devicegraph. | |
bool | exists_in_probed () const |
Checks if the device exists in the probed devicegraph. | |
bool | exists_in_staging () const |
Checks if the device exists in the staging devicegraph. | |
bool | exists_in_system () const |
Checks if the device exists in the system devicegraph. | |
std::string | get_displayname () const |
ResizeInfo | detect_resize_info () const |
Detect the resize info of the device. More... | |
bool | has_children () const |
size_t | num_children () const |
bool | has_parents () const |
size_t | num_parents () const |
std::vector< Device * > | get_children () |
std::vector< const Device * > | get_children () const |
std::vector< Device * > | get_children (View view) |
Get all children of the device. | |
std::vector< const Device * > | get_children (View view) const |
Get all children of the device. More... | |
std::vector< Device * > | get_parents () |
std::vector< const Device * > | get_parents () const |
std::vector< Device * > | get_parents (View view) |
Get all parents of the device. | |
std::vector< const Device * > | get_parents (View view) const |
Get all parents of the device. More... | |
std::vector< Device * > | get_siblings (bool itself) |
std::vector< const Device * > | get_siblings (bool itself) const |
std::vector< Device * > | get_descendants (bool itself) |
std::vector< const Device * > | get_descendants (bool itself) const |
std::vector< Device * > | get_descendants (bool itself, View view) |
std::vector< const Device * > | get_descendants (bool itself, View view) const |
std::vector< Device * > | get_ancestors (bool itself) |
std::vector< const Device * > | get_ancestors (bool itself) const |
std::vector< Device * > | get_leaves (bool itself) |
std::vector< const Device * > | get_leaves (bool itself) const |
std::vector< Device * > | get_roots (bool itself) |
std::vector< const Device * > | get_roots (bool itself) const |
std::vector< Holder * > | get_in_holders () |
std::vector< const Holder * > | get_in_holders () const |
std::vector< Holder * > | get_out_holders () |
std::vector< const Holder * > | get_out_holders () const |
void | remove_descendants () ST_DEPRECATED |
void | remove_descendants (View view) |
Remove all descendants of the device. More... | |
const std::map< std::string, std::string > & | get_userdata () const |
Return the userdata of the device. | |
void | set_userdata (const std::map< std::string, std::string > &userdata) |
Set the userdata of the device. | |
std::string | get_name_sort_key () const |
Get a sort-key based on the device name. More... | |
Devicegraph * | get_devicegraph () |
Return the devicegraph the device belongs to. | |
const Devicegraph * | get_devicegraph () const |
Return the devicegraph the device belongs to. More... | |
Impl & | get_impl () |
const Impl & | get_impl () const |
void | save (xmlNode *node) const ST_DEPRECATED |
Static Public Member Functions | |
static Partition * | create (Devicegraph *devicegraph, const std::string &name, const Region ®ion, PartitionType type) |
Create a device of type Partition. More... | |
static Partition * | load (Devicegraph *devicegraph, const xmlNode *node) |
static Partition * | find_by_name (Devicegraph *devicegraph, const std::string &name) |
Find a Partition by its name. More... | |
static const Partition * | find_by_name (const Devicegraph *devicegraph, const std::string &name) |
Find a Partition by its name. More... | |
static bool | compare_by_number (const Partition *lhs, const Partition *rhs) |
Compare (less than) two Partitions by number. More... | |
![]() | |
static std::vector< BlkDevice * > | get_all (Devicegraph *devicegraph) |
Get all BlkDevices. | |
static std::vector< const BlkDevice * > | get_all (const Devicegraph *devicegraph) |
Get all BlkDevices. More... | |
static BlkDevice * | find_by_name (Devicegraph *devicegraph, const std::string &name) |
Find a block device by its name. More... | |
static const BlkDevice * | find_by_name (const Devicegraph *devicegraph, const std::string &name) |
Find a block device by its name. More... | |
static bool | exists_by_any_name (const Devicegraph *devicegraph, const std::string &name, SystemInfo &system_info) |
Check if a block device by any name including any symbolic links in /dev. More... | |
static BlkDevice * | find_by_any_name (Devicegraph *devicegraph, const std::string &name) ST_DEPRECATED |
Find a block device by any name including any symbolic links in /dev. More... | |
static BlkDevice * | find_by_any_name (Devicegraph *devicegraph, const std::string &name, SystemInfo &system_info) |
Find a block device by any name including any symbolic links in /dev. More... | |
static const BlkDevice * | find_by_any_name (const Devicegraph *devicegraph, const std::string &name) ST_DEPRECATED |
Find a block device by any name including any symbolic links in /dev. More... | |
static const BlkDevice * | find_by_any_name (const Devicegraph *devicegraph, const std::string &name, SystemInfo &system_info) |
Find a block device by any name including any symbolic links in /dev. More... | |
static bool | compare_by_dm_table_name (const BlkDevice *lhs, const BlkDevice *rhs) |
Compare (less than) two BlkDevices by DM table name. More... | |
![]() | |
static std::vector< Device * > | get_all (Devicegraph *devicegraph) |
Get all Devices. | |
static std::vector< const Device * > | get_all (const Devicegraph *devicegraph) |
Get all Devices. More... | |
static bool | compare_by_sid (const Device *lhs, const Device *rhs) |
Compare (less than) two Devices by sid. More... | |
static bool | compare_by_name (const Device *lhs, const Device *rhs) |
Compare (less than) two Devices by name. More... | |
Additional Inherited Members | |
![]() | |
BlkDevice (Impl *impl) | |
![]() | |
Device (Impl *impl) | |
void | create (Devicegraph *devicegraph) ST_DEPRECATED |
Create a device in the devicegraph. More... | |
void | load (Devicegraph *devicegraph) ST_DEPRECATED |
A partition of a Partitionable, e.g.
|
static |
Compare (less than) two Partitions by number.
|
static |
Create a device of type Partition.
Region is sector-based. Usually this function is not called directly. Instead PartitionTable::create_partition() is called.
|
static |
Find a Partition by its name.
Only the name returned by get_name() is considered.
DeviceNotFound,DeviceHasWrongType |
|
static |
Find a Partition by its name.
Only the name returned by get_name() is considered.
DeviceNotFound,DeviceHasWrongType |
unsigned int storage::Partition::get_id | ( | ) | const |
Get the partition id.
const std::string& storage::Partition::get_label | ( | ) | const |
Get the partition label.
Can be empty. Only available for partitions on GPT.
In the UEFI spec this is called name instead of label. But many tools, e.g. udev and blkid, use label. Also in fstab PARTLABEL= is used.
PartitionTable* storage::Partition::get_partition_table | ( | ) |
Return the partition table the partition belongs to.
WrongNumberOfChildren,DeviceHasWrongType |
const PartitionTable* storage::Partition::get_partition_table | ( | ) | const |
Return the partition table the partition belongs to.
WrongNumberOfChildren,DeviceHasWrongType |
Partitionable* storage::Partition::get_partitionable | ( | ) |
Return the partitionable the partition belongs to.
WrongNumberOfChildren,DeviceHasWrongType |
const Partitionable* storage::Partition::get_partitionable | ( | ) | const |
Return the partitionable the partition belongs to.
WrongNumberOfChildren,DeviceHasWrongType |
PartitionType storage::Partition::get_type | ( | ) | const |
Get the partition type.
Region storage::Partition::get_unused_surrounding_region | ( | ) | const |
Returns the unused region surrounding the partition (including the partition itself).
The returned region is not aligned.
Exception |
const std::string& storage::Partition::get_uuid | ( | ) | const |
Get the partition UUID.
Only available for partitions on GPT. Experimental.
void storage::Partition::set_boot | ( | bool | boot | ) |
Set the boot flag of the partition.
Only supported on MS-DOS.
Notes:
Exception |
void storage::Partition::set_id | ( | unsigned int | id | ) |
Set the partition id.
Exception |
void storage::Partition::set_label | ( | const std::string & | label | ) |
Set the partition label.
void storage::Partition::set_legacy_boot | ( | bool | legacy_boot | ) |
void storage::Partition::set_no_automount | ( | bool | no_automount | ) |
Set the no-automount flag of the partition.
Only supported on GPT. Requires parted 3.6.
The flag is called "no_automount" by parted and "no-auto" by systemd, see https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/.
Exception |
void storage::Partition::set_type | ( | PartitionType | type | ) |