libstorage-ng
Loading...
Searching...
No Matches
storage::Device Class Referenceabstract

An abstract base class for storage devices. More...

#include <Device.h>

Inheritance diagram for storage::Device:
[legend]
Collaboration diagram for storage::Device:
[legend]

Public Member Functions

sid_t get_sid () const
 Return the storage id (sid) of the device.
bool operator== (const Device &rhs) const
bool operator!= (const Device &rhs) const
Devicecopy_to_devicegraph (Devicegraph *devicegraph) const
 Copies the device to the devicegraph.
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.
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.
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.
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.
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.
Devicegraphget_devicegraph ()
 Return the devicegraph the device belongs to.
const Devicegraphget_devicegraph () const
 Return the devicegraph the device belongs to.
Impl & get_impl ()
const Impl & get_impl () const
virtual Deviceclone () const =0
void save (xmlNode *node) const ST_DEPRECATED

Static Public Member Functions

static std::vector< Device * > get_all (Devicegraph *devicegraph)
 Get all Devices.
static std::vector< const Device * > get_all (const Devicegraph *devicegraph)
 Get all Devices.
static bool compare_by_sid (const Device *lhs, const Device *rhs)
 Compare (less than) two Devices by sid.
static bool compare_by_name (const Device *lhs, const Device *rhs)
 Compare (less than) two Devices by name.

Protected Member Functions

 Device (Impl *impl)
void create (Devicegraph *devicegraph) ST_DEPRECATED
 Create a device in the devicegraph.
void load (Devicegraph *devicegraph) ST_DEPRECATED

Friends

std::ostream & operator<< (std::ostream &out, const Device &device)

Detailed Description

An abstract base class for storage devices.

Storage devices are nodes in the devicegraph.

The Device class does not have a device name since some device types do not have a intrinsic device name, e.g. btrfs. Instead most devices are derived from BlkDevice which has a device name, udev path and udev ids.

See also
Devicegraph

Member Function Documentation

◆ compare_by_name()

bool storage::Device::compare_by_name ( const Device * lhs,
const Device * rhs )
static

Compare (less than) two Devices by name.

So far only available for BlkDevices and LvmVgs.

The comparison sorts to alphabetical order with some exceptions. E.g. The disk /dev/sdz is in front of /dev/sdaa and the partition /dev/sda2 is in front of /dev/sda10.

The comparison fulfills strict weak ordering. The exact ordering may change in future versions.

The comparison is locale unaware.

See also
get_name_sort_key()
Exceptions
Exception

◆ compare_by_sid()

bool storage::Device::compare_by_sid ( const Device * lhs,
const Device * rhs )
static

Compare (less than) two Devices by sid.

See also
get_sid()

◆ copy_to_devicegraph()

Device * storage::Device::copy_to_devicegraph ( Devicegraph * devicegraph) const

Copies the device to the devicegraph.

Does not copy holders. The purpose of the function is to restore parts of the probed devicegraph in the staging devicegraph that were previously deleted.

Device must not exist in devicegraph.

See also
Holder::copy_to_devicegraph()
Exceptions
Exception

◆ create()

void storage::Device::create ( Devicegraph * devicegraph)
protected

Create a device in the devicegraph.

The created device is owned by the devicegraph.

◆ detect_resize_info()

ResizeInfo storage::Device::detect_resize_info ( ) const

Detect the resize info of the device.

If the device holds an NTFS it must not be mounted.

See also
ResizeInfo
Exceptions
Exception

◆ get_all()

std::vector< const Device * > storage::Device::get_all ( const Devicegraph * devicegraph)
static

Get all Devices.

◆ get_children()

std::vector< const Device * > storage::Device::get_children ( View view) const

Get all children of the device.

◆ get_devicegraph()

const Devicegraph * storage::Device::get_devicegraph ( ) const

Return the devicegraph the device belongs to.

◆ get_name_sort_key()

std::string storage::Device::get_name_sort_key ( ) const

Get a sort-key based on the device name.

So far only available for BlkDevices and LvmVgs. For other types the sort-key is empty.

The sorting based on the sort-key sorts to alphabetical order with some exceptions. E.g. The disk /dev/sdz is in front of /dev/sdaa and the partition /dev/sda2 is in front of /dev/sda10.

The sorting based on the sort-key may depend on the used locale.

The sort-key and the exact ordering may change in future versions.

Exceptions
Exception

◆ get_parents()

std::vector< const Device * > storage::Device::get_parents ( View view) const

Get all parents of the device.

◆ get_sid()

sid_t storage::Device::get_sid ( ) const

Return the storage id (sid) of the device.

See also
sid_t

◆ remove_descendants()

void storage::Device::remove_descendants ( View view)

Remove all descendants of the device.

The view should likely always be View::REMOVE.


The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/libstorage-ng-4.5.263-build/libstorage-ng-4.5.263/storage/Devices/Device.h