libstorage-ng
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
storage::BlkDevice Class Reference

An abstract Block Device. More...

#include <BlkDevice.h>

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

Public Member Functions

const std::string & get_name () const
 
void set_name (const std::string &name)
 
const Regionget_region () const
 
void set_region (const Region &region)
 
unsigned long long get_size () const
 
void set_size (unsigned long long size)
 
std::string get_size_string () const
 Returns the size of the block device as a localised string. More...
 
const Topologyget_topology () const
 Get the topology.
 
void set_topology (const Topology &topology)
 Set the topology. More...
 
bool is_active () const
 
const std::string & get_sysfs_name () const
 
const std::string & get_sysfs_path () const
 
const std::vector< std::string > & get_udev_paths () const
 
const std::vector< std::string > & get_udev_ids () const
 
bool is_usable_as_blk_device () const
 Checks whether the blk device is in general usable as a blk device. 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)
 
BlkFilesystemcreate_blk_filesystem (FsType fs_type)
 Creates a block filesystem on the block device. More...
 
bool has_blk_filesystem () const
 
BlkFilesystemget_blk_filesystem ()
 
const BlkFilesystemget_blk_filesystem () const
 
BlkFilesystemcreate_filesystem (FsType fs_type) ST_DEPRECATED
 Creates a block filesystem on the block device. More...
 
bool has_filesystem () const ST_DEPRECATED
 
BlkFilesystemget_filesystem () ST_DEPRECATED
 
const BlkFilesystemget_filesystem () const ST_DEPRECATED
 
Encryptioncreate_encryption (const std::string &dm_name) ST_DEPRECATED
 Creates an encryption device on the blk device. More...
 
Encryptioncreate_encryption (const std::string &dm_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
 
Encryptionget_encryption ()
 
const Encryptionget_encryption () const
 
Bcachecreate_bcache (const std::string &name)
 Creates a Bcache on the blk device. More...
 
bool has_bcache () const
 
Bcacheget_bcache ()
 
const Bcacheget_bcache () const
 
BcacheCsetcreate_bcache_cset ()
 Creates an BcacheCset on the blk device. More...
 
bool has_bcache_cset () const
 
BcacheCsetget_bcache_cset ()
 
const BcacheCsetget_bcache_cset () const
 
std::vector< MountByTypepossible_mount_bys () const
 Returns the possible mount-by methods to reference the block device.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
- Public Member Functions inherited from storage::Device
sid_t get_sid () const
 
bool operator== (const Device &rhs) const
 
bool operator!= (const Device &rhs) const
 
Devicecopy_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_parents ()
 
std::vector< const Device * > get_parents () const
 
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_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 ()
 
const std::map< std::string, std::string > & get_userdata () const
 
void set_userdata (const std::map< std::string, std::string > &userdata)
 
std::string get_name_sort_key () const
 Get a sort-key based on the device name. More...
 
Devicegraphget_devicegraph ()
 
const Devicegraphget_devicegraph () const
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
virtual Deviceclone () const =0
 
void save (xmlNode *node) const
 

Static Public Member Functions

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 BlkDevicefind_by_name (Devicegraph *devicegraph, const std::string &name)
 Find a block device by its name. More...
 
static const BlkDevicefind_by_name (const Devicegraph *devicegraph, const std::string &name)
 Find a block device by its name. More...
 
static BlkDevicefind_by_any_name (Devicegraph *devicegraph, const std::string &name)
 Find a block device by any name including any symbolic links in /dev. More...
 
static const BlkDevicefind_by_any_name (const Devicegraph *devicegraph, const std::string &name)
 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 Public Member Functions inherited from storage::Device
static std::vector< Device * > get_all (Devicegraph *devicegraph)
 
static std::vector< const Device * > get_all (const Devicegraph *devicegraph)
 
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. More...
 

Protected Member Functions

 BlkDevice (Impl *impl)
 
- Protected Member Functions inherited from storage::Device
 Device (Impl *impl)
 
void create (Devicegraph *devicegraph)
 
void load (Devicegraph *devicegraph)
 

Detailed Description

An abstract Block Device.

Member Function Documentation

◆ compare_by_dm_table_name()

static bool storage::BlkDevice::compare_by_dm_table_name ( const BlkDevice lhs,
const BlkDevice rhs 
)
static

Compare (less than) two BlkDevices by DM table name.

The comparison is locale unaware.

◆ create_bcache()

Bcache* storage::BlkDevice::create_bcache ( const std::string &  name)

Creates a Bcache on the blk device.

If the blk device has children the children will become children of the bcache device.

◆ create_bcache_cset()

BcacheCset* storage::BlkDevice::create_bcache_cset ( )

Creates an BcacheCset on the blk device.

Exceptions
WrongNumberOfChildren

◆ create_blk_filesystem()

BlkFilesystem* storage::BlkDevice::create_blk_filesystem ( FsType  fs_type)

Creates a block filesystem on the block device.

Exceptions
WrongNumberOfChildren,UnsupportedException

◆ create_encryption() [1/2]

Encryption* storage::BlkDevice::create_encryption ( const std::string &  dm_name)

Creates an encryption device on the blk device.

If the blk device has children the children will become children of the encryption device.

It will also set the mount-by method of the encryption to the storage default mount-by method.

◆ create_encryption() [2/2]

Encryption* storage::BlkDevice::create_encryption ( const std::string &  dm_name,
EncryptionType  type 
)

Creates an encryption device on the blk device.

If the blk device has children the children will become children of the encryption device.

Allowed encryption types are LUKS1, LUKS2 and PLAIN.

It will also set the mount-by method of the encryption to the storage default mount-by method.

◆ create_filesystem()

BlkFilesystem* storage::BlkDevice::create_filesystem ( FsType  fs_type)
inline

Creates a block filesystem on the block device.

Exceptions
WrongNumberOfChildren,UnsupportedException

◆ find_by_any_name() [1/2]

static BlkDevice* storage::BlkDevice::find_by_any_name ( Devicegraph devicegraph,
const std::string &  name 
)
static

Find a block device by any name including any symbolic links in /dev.

Function might require a system lookup and is therefore slow. Only works on the probed devicegraph.

Exceptions
DeviceNotFoundByName,DeviceHasWrongType,Exception

◆ find_by_any_name() [2/2]

static const BlkDevice* storage::BlkDevice::find_by_any_name ( const Devicegraph devicegraph,
const std::string &  name 
)
static

Find a block device by any name including any symbolic links in /dev.

Function might require a system lookup and is therefore slow. Only works on the probed devicegraph.

Exceptions
DeviceNotFoundByName,DeviceHasWrongType,Exception

◆ find_by_name() [1/2]

static BlkDevice* storage::BlkDevice::find_by_name ( Devicegraph devicegraph,
const std::string &  name 
)
static

Find a block device by its name.

Only the name returned by get_name() is considered.

Exceptions
DeviceNotFoundByName,DeviceHasWrongType

◆ find_by_name() [2/2]

static const BlkDevice* storage::BlkDevice::find_by_name ( const Devicegraph devicegraph,
const std::string &  name 
)
static

Find a block device by its name.

Only the name returned by get_name() is considered.

Exceptions
DeviceNotFoundByName,DeviceHasWrongType

◆ get_all()

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

Get all BlkDevices.

◆ get_bcache() [1/2]

Bcache* storage::BlkDevice::get_bcache ( )

◆ get_bcache() [2/2]

const Bcache* storage::BlkDevice::get_bcache ( ) const

◆ get_bcache_cset() [1/2]

BcacheCset* storage::BlkDevice::get_bcache_cset ( )

◆ get_bcache_cset() [2/2]

const BcacheCset* storage::BlkDevice::get_bcache_cset ( ) const

◆ get_blk_filesystem() [1/2]

BlkFilesystem* storage::BlkDevice::get_blk_filesystem ( )

◆ get_blk_filesystem() [2/2]

const BlkFilesystem* storage::BlkDevice::get_blk_filesystem ( ) const

◆ get_dm_table_name()

const std::string& storage::BlkDevice::get_dm_table_name ( ) const

Return device-mapper table name (dm-table-name for short).

Empty if this is not a device-mapper device.

◆ get_encryption() [1/2]

Encryption* storage::BlkDevice::get_encryption ( )

◆ get_encryption() [2/2]

const Encryption* storage::BlkDevice::get_encryption ( ) const

◆ get_filesystem() [1/2]

BlkFilesystem* storage::BlkDevice::get_filesystem ( )
inline

◆ get_filesystem() [2/2]

const BlkFilesystem* storage::BlkDevice::get_filesystem ( ) const
inline

◆ get_size_string()

std::string storage::BlkDevice::get_size_string ( ) const

Returns the size of the block device as a localised string.

Returns
size as string

◆ is_usable_as_blk_device()

bool storage::BlkDevice::is_usable_as_blk_device ( ) const

Checks whether the blk device is in general usable as a blk device.

This is not the case for some DASDs, see doc/dasd.md, extended partitions, LVM thin pools, MD RAID containers, see doc/md-raid.md and host-managed zoned disks.

Does not consider if the blk device is already in use.

◆ remove_encryption()

void storage::BlkDevice::remove_encryption ( )

Removes an encryption device on the blk device.

If the encryption device has children the children will become children of the blk device.

Exceptions
WrongNumberOfChildren,DeviceHasWrongType

◆ set_region()

void storage::BlkDevice::set_region ( const Region region)
Exceptions
Exception

◆ set_size()

void storage::BlkDevice::set_size ( unsigned long long  size)
Exceptions
Exception

◆ set_topology()

void storage::BlkDevice::set_topology ( const Topology topology)

Set the topology.

Only useful for testsuites.


The documentation for this class was generated from the following file: