libstorage-ng
Classes | Typedefs | Enumerations | Functions | Variables
storage Namespace Reference

The storage namespace. More...

Classes

class  Actiongraph
 
class  AlignError
 
class  Bcache
 A bcache device. More...
 
class  BcacheCset
 A bcache cache set. More...
 
class  BlkDevice
 An abstract Block Device. More...
 
class  Btrfs
 
class  CodeLocation
 Helper class for UI exceptions: Store BASE_FILE, FUNCTION and LINE. More...
 
class  CommitCallbacks
 
class  Device
 An abstract base class of storage devices, and a vertex in the Devicegraph. More...
 
class  Devicegraph
 The master container of the libstorage. More...
 
struct  DeviceHasWrongType
 
struct  DeviceNotFound
 
struct  DeviceNotFoundByName
 
struct  DeviceNotFoundBySid
 
struct  DeviceNotFoundByUuid
 
class  DifferentBlockSizes
 
class  Disk
 A physical disk device. More...
 
class  Encryption
 An encryption layer on a blk device. More...
 
class  Environment
 
class  Exception
 Base class for storage exceptions. More...
 
class  Ext4
 
class  Filesystem
 
class  Gpt
 
class  Holder
 
struct  HolderAlreadyExists
 
struct  HolderHasWrongType
 
struct  HolderNotFound
 
struct  HolderNotFoundBySid
 
class  IndexOutOfRangeException
 Exception class for "index out of range". More...
 
class  InvalidBlockSize
 
struct  InvalidExtentSize
 
class  LogicException
 Exception class for faulty logic within the program. More...
 
class  Luks
 An luks encryption layer on a block device. More...
 
class  LvmLv
 A Logical Volume of the Logical Volume Manager (LVM). More...
 
class  LvmPv
 
class  LvmVg
 A Volume Group of the Logical Volume Manager (LVM). More...
 
struct  LvmVgNotFoundByVgName
 
class  Md
 A MD device. More...
 
class  MdUser
 
class  Msdos
 
class  NoIntersection
 
class  NotImplementedException
 Exception class for features not implemented. More...
 
class  NotInside
 
class  Ntfs
 
class  NullPointerException
 Exception class for generic null pointer exceptions. More...
 
class  OutOfMemoryException
 Exception class for "out of memory". More...
 
class  OverflowException
 Exception class for "overflow". More...
 
class  ParseException
 Exception class for parse errors, e.g. More...
 
class  Partition
 A partition of a Partitionable, e.g. Disk or Md. More...
 
class  Partitionable
 
class  PartitionSlot
 
class  PartitionTable
 
class  Region
 A start/length pair with a block size. More...
 
class  Storage
 The main entry point to libstorage. More...
 
class  Subdevice
 
class  Swap
 
class  Topology
 A class to calculate partition alignment based on hardware topology. More...
 
class  User
 
class  Vfat
 
struct  WrongNumberOfChildren
 
struct  WrongNumberOfParents
 
class  Xfs
 

Typedefs

typedef unsigned int sid_t
 An integer storage ID. More...
 

Enumerations

enum  Side { LHS, RHS }
 
enum  ProbeMode {
  STANDARD, STANDARD_WRITE_DEVICEGRAPH, STANDARD_WRITE_MOCKUP, NONE,
  READ_DEVICEGRAPH, READ_MOCKUP
}
 How to probe the system.
 
enum  TargetMode { DIRECT, CHROOT, IMAGE }
 Is the target a disk, chroot, or image?
 
enum  GraphvizFlags : unsigned int {
  NONE = 0x0, TOOLTIP = 0x1, CLASSNAME = 0x2, SID = 0x4,
  SIZE = 0x8
}
 Bitfield to control graphviz output. More...
 
enum  Transport {
  UNKNOWN, SBP, ATA, FC,
  ISCSI, SAS, SATA, SPI,
  USB, FCOE
}
 Data Transport Layer.
 
enum  DasdFormat { DASDF_NONE, DASDF_LDL, DASDF_CDL }
 
enum  DasdType { DASDTYPE_NONE, DASDTYPE_ECKD, DASDTYPE_FBA }
 
enum  EncryptionType {
  NONE, TWOFISH, TWOFISH_OLD, TWOFISH256_OLD,
  LUKS, UNKNOWN
}
 
enum  MdLevel {
  UNKNOWN, UNKNOWN, UNKNOWN, RAID0,
  RAID1, RAID5, RAID6, RAID10
}
 
enum  MdParity {
  DEFAULT, LEFT_ASYMMETRIC, LEFT_SYMMETRIC, RIGHT_ASYMMETRIC,
  RIGHT_SYMMETRIC, FIRST, LAST, LEFT_ASYMMETRIC_6,
  LEFT_SYMMETRIC_6, RIGHT_ASYMMETRIC_6, RIGHT_SYMMETRIC_6, FIRST_6,
  NEAR_2, OFFSET_2, FAR_2, NEAR_3,
  OFFSET_3, FAR_3
}
 
enum  PartitionType { PRIMARY, EXTENDED, LOGICAL }
 Partition type (primary, extended, logical)
 
enum  IdNum : unsigned int {
  ID_DOS12 = 0x01, ID_DOS16 = 0x06, ID_DOS32 = 0x0c, ID_NTFS = 0x07,
  ID_EXTENDED = 0x0f, ID_PREP = 0x41, ID_LINUX = 0x83, ID_SWAP = 0x82,
  ID_LVM = 0x8e, ID_RAID = 0xfd, ID_ESP = 0xef, ID_UNKNOWN = 0x100,
  ID_BIOS_BOOT = 0x101, ID_WINDOWS_BASIC_DATA = 0x102, ID_MICROSOFT_RESERVED = 0x103
}
 Enum with values used as partition ids. More...
 
enum  PtType {
  PT_UNKNOWN, PT_LOOP, MSDOS, GPT,
  DASD, MAC
}
 Partition Table Type.
 
enum  FsType {
  UNKNOWN, REISERFS, EXT2, EXT3,
  EXT4, BTRFS, VFAT, XFS,
  JFS, HFS, NTFS, SWAP,
  HFSPLUS, NFS, NFS4, TMPFS,
  ISO9660, UDF
}
 
enum  MountByType {
  DEVICE, UUID, LABEL, ID,
  PATH
}
 The key by which the mount program identifies a filesystem.
 
enum  AlignPolicy { ALIGN_END, KEEP_END, KEEP_SIZE }
 

Functions

GraphvizFlags operator| (GraphvizFlags a, GraphvizFlags b)
 
GraphvizFlags operator & (GraphvizFlags a, GraphvizFlags b)
 
bool operator && (GraphvizFlags a, GraphvizFlags b)
 
bool is_bcache (const Device *device)
 
Bcacheto_bcache (Device *device)
 
const Bcacheto_bcache (const Device *device)
 
bool is_bcache_cset (const Device *device)
 
BcacheCsetto_bcache_cset (Device *device)
 
const BcacheCsetto_bcache_cset (const Device *device)
 
bool is_blk_device (const Device *device)
 
BlkDeviceto_blk_device (Device *device)
 
const BlkDeviceto_blk_device (const Device *device)
 
std::string get_transport_name (Transport transport)
 
bool is_disk (const Device *device)
 
Diskto_disk (Device *device)
 Converts pointer to Device to pointer to Disk. More...
 
const Diskto_disk (const Device *device)
 Converts pointer to Device to pointer to Disk. More...
 
bool is_encryption (const Device *device)
 
Encryptionto_encryption (Device *device)
 
const Encryptionto_encryption (const Device *device)
 
bool is_gpt (const Device *device)
 
Gptto_gpt (Device *device)
 
const Gptto_gpt (const Device *device)
 
bool is_luks (const Device *device)
 
Luksto_luks (Device *device)
 
const Luksto_luks (const Device *device)
 
bool is_lvm_lv (const Device *device)
 
LvmLvto_lvm_lv (Device *device)
 
const LvmLvto_lvm_lv (const Device *device)
 
bool is_lvm_pv (const Device *device)
 
LvmPvto_lvm_pv (Device *device)
 
const LvmPvto_lvm_pv (const Device *device)
 
bool is_lvm_vg (const Device *device)
 
LvmVgto_lvm_vg (Device *device)
 
const LvmVgto_lvm_vg (const Device *device)
 
std::string get_md_level_name (MdLevel md_level)
 
std::string get_md_parity_name (MdParity md_parity)
 
bool is_md (const Device *device)
 
Mdto_md (Device *device)
 Converts pointer to Device to pointer to Md. More...
 
const Mdto_md (const Device *device)
 Converts pointer to Device to pointer to Md. More...
 
bool is_msdos (const Device *device)
 
Msdosto_msdos (Device *device)
 
const Msdosto_msdos (const Device *device)
 
bool is_partition (const Device *device)
 
Partitionto_partition (Device *device)
 
const Partitionto_partition (const Device *device)
 
bool is_partitionable (const Device *device)
 
Partitionableto_partitionable (Device *device)
 
const Partitionableto_partitionable (const Device *device)
 
std::string get_pt_type_name (PtType pt_type)
 
bool is_partition_table (const Device *device)
 
PartitionTableto_partition_table (Device *device)
 
const PartitionTableto_partition_table (const Device *device)
 
bool is_btrfs (const Device *device)
 
Btrfsto_btrfs (Device *device)
 
const Btrfsto_btrfs (const Device *device)
 
bool is_ext4 (const Device *device)
 
Ext4to_ext4 (Device *device)
 
const Ext4to_ext4 (const Device *device)
 
std::string get_mount_by_name (MountByType mount_by_type)
 
bool is_filesystem (const Device *device)
 
Filesystemto_filesystem (Device *device)
 
const Filesystemto_filesystem (const Device *device)
 
bool is_ntfs (const Device *device)
 
Ntfsto_ntfs (Device *device)
 
const Ntfsto_ntfs (const Device *device)
 
bool is_swap (const Device *device)
 
Swapto_swap (Device *device)
 
const Swapto_swap (const Device *device)
 
bool is_vfat (const Device *device)
 
Vfatto_vfat (Device *device)
 
const Vfatto_vfat (const Device *device)
 
bool is_xfs (const Device *device)
 
Xfsto_xfs (Device *device)
 
const Xfsto_xfs (const Device *device)
 
bool is_md_user (const Holder *holder)
 
MdUserto_md_user (Holder *device)
 
const MdUserto_md_user (const Holder *device)
 
bool is_subdevice (const Holder *holder)
 
Subdeviceto_subdevice (Holder *device)
 
const Subdeviceto_subdevice (const Holder *device)
 
bool is_user (const Holder *holder)
 
Userto_user (Holder *device)
 
const Userto_user (const Holder *device)
 
std::ostream & operator<< (std::ostream &str, const CodeLocation &obj)
 CodeLocation stream output. More...
 
std::ostream & operator<< (std::ostream &str, const Exception &obj)
 Exception stream output.
 
int num_suffixes ()
 Return number of suffixes. More...
 
std::string get_suffix (int i, bool classic)
 Return a suffix. More...
 
std::string byte_to_humanstring (unsigned long long size, bool classic, int precision, bool omit_zeroes)
 Return a pretty description of a size with required precision and using B, KiB, MiB, GiB, TiB, PiB or EiB as unit as appropriate. More...
 
unsigned long long humanstring_to_byte (const std::string &str, bool classic)
 Converts a size description using B, KiB, KB, MiB, MB, GiB, GB, TiB, TB, PiB, PB, EiB or EB into an integer. More...
 

Variables

const unsigned long long B = 1
 
const unsigned long long KiB = 1024 * B
 
const unsigned long long MiB = 1024 * KiB
 
const unsigned long long GiB = 1024 * MiB
 
const unsigned long long TiB = 1024 * GiB
 
const unsigned long long PiB = 1024 * TiB
 
const unsigned long long EiB = 1024 * PiB
 

Detailed Description

The storage namespace.

Typedef Documentation

§ sid_t

typedef unsigned int storage::sid_t

An integer storage ID.

The storage id (sid) is used to identify devices. The sid is copied when copying the device graph. When adding a device it gets a unique sid (across all device graphs). By using the storage id instead of a device name we can easily identify devices where the device name changed, e.g. renumbered logical partitions or renamed logical volumes. Also some devices do not have a intrinsic device name, e.g. btrfs. We could even have objects for unused space, e.g. space between partitions or unallocated space of a volume group.

Whenever possible use the storage id to find objects instead of e.g. the name since only the storage id guarantees uniqueness.

Enumeration Type Documentation

§ GraphvizFlags

enum storage::GraphvizFlags : unsigned int
strong

Bitfield to control graphviz output.

If TOOLTIP is enabled the output of the others fields is added to the tooltip, otherwise they are added to the label. Not all flags apply to all graphs or all objects (devices, holders and actions).

§ IdNum

enum storage::IdNum : unsigned int

Enum with values used as partition ids.

For MSDOS the value of the enum is equal to the partition type byte. For GPT and DASD the value has no special meaning.

For details about the ids see e.g. https://en.wikipedia.org/wiki/Partition_type and https://en.wikipedia.org/wiki/GUID_Partition_Table.

Enumerator
ID_DOS12 

Only for MSDOS.

ID_DOS16 

Only for MSDOS.

ID_DOS32 

Only for MSDOS.

ID_NTFS 

Only for MSDOS.

ID_EXTENDED 

Only for MSDOS.

ID_PREP 

PPC PReP Boot partition, for MSDOS and GPT.

ID_LINUX 

For MSDOS and GPT.

ID_SWAP 

Swap partition, for MSDOS and GPT, but GPT only when the partition is created.

ID_LVM 

LVM partition, for MSDOS and GPT.

ID_RAID 

RAID partition, for MSDOS and GPT.

ID_ESP 

EFI System Partition, for MSDOS and GPT.

ID_UNKNOWN 

Only set during probing.

For MSDOS and GPT.

ID_BIOS_BOOT 

BIOS boot partition (https://en.wikipedia.org/wiki/BIOS_boot_partition), only for GPT.

ID_WINDOWS_BASIC_DATA 

Windows basic data partition, only for GPT.

ID_MICROSOFT_RESERVED 

Microsoft reserved partition, only for GPT.

Function Documentation

§ byte_to_humanstring()

std::string storage::byte_to_humanstring ( unsigned long long  size,
bool  classic,
int  precision,
bool  omit_zeroes 
)

Return a pretty description of a size with required precision and using B, KiB, MiB, GiB, TiB, PiB or EiB as unit as appropriate.

Parameters
sizesize in bytes
classicuse classic locale instead of global C++ locale
precisionnumber of fraction digits in output
omit_zeroesif true omit trailing zeroes for exact values
Returns
formatted string

§ get_suffix()

std::string storage::get_suffix ( int  i,
bool  classic 
)

Return a suffix.

Parameters
iindex of suffix
classicuse classic locale instead of global C++ locale
Returns
suffix

§ humanstring_to_byte()

unsigned long long storage::humanstring_to_byte ( const std::string &  str,
bool  classic 
)

Converts a size description using B, KiB, KB, MiB, MB, GiB, GB, TiB, TB, PiB, PB, EiB or EB into an integer.

Decimal suffixes are treated as binary.

Parameters
strsize string
classicuse classic locale instead of global C++ locale
sizesize in bytes
Returns
true on successful conversion

The conversion is always case-insensitive. With classic set to false the conversion is also sloppy concerning omission of 'B'.

§ num_suffixes()

int storage::num_suffixes ( )

Return number of suffixes.

Returns
number of suffixes

§ operator<<()

std::ostream& storage::operator<< ( std::ostream &  str,
const CodeLocation obj 
)

CodeLocation stream output.

Stream output.

§ to_disk() [1/2]

Disk* storage::to_disk ( Device device)

Converts pointer to Device to pointer to Disk.

Returns
Pointer to Disk.
Exceptions
DeviceHasWrongType,NullPointerException

§ to_disk() [2/2]

const Disk* storage::to_disk ( const Device device)

Converts pointer to Device to pointer to Disk.

Returns
Pointer to Disk.
Exceptions
DeviceHasWrongType,NullPointerException

§ to_md() [1/2]

Md* storage::to_md ( Device device)

Converts pointer to Device to pointer to Md.

Returns
Pointer to Md.
Exceptions
DeviceHasWrongType,NullPointerException

§ to_md() [2/2]

const Md* storage::to_md ( const Device device)

Converts pointer to Device to pointer to Md.

Returns
Pointer to Md.
Exceptions
DeviceHasWrongType,NullPointerException