libstorage-ng
Loading...
Searching...
No Matches
storage::Storage Class Reference

The main entry point to libstorage. More...

#include <Storage.h>

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

Public Member Functions

 Storage (const Environment &environment)
 Construct Storage object.
const Environmentget_environment () const
const Archget_arch () const
 So far only valid after probing.
Devicegraphcreate_devicegraph (const std::string &name)
 Create a devicegraph with name.
Devicegraphcopy_devicegraph (const std::string &source_name, const std::string &dest_name)
void remove_devicegraph (const std::string &name)
 Remove a devicegraph by name.
void restore_devicegraph (const std::string &name)
bool equal_devicegraph (const std::string &lhs, const std::string &rhs) const
bool exist_devicegraph (const std::string &name) const
 Check whether a devicegraph exists by name.
std::vector< std::string > get_devicegraph_names () const ST_DEPRECATED
 Get the names of all devicegraphs.
std::map< std::string, const Devicegraph * > get_devicegraphs () const
 Get all devicegraphs with their names.
Devicegraphget_devicegraph (const std::string &name)
 Return a devicegraph by name.
const Devicegraphget_devicegraph (const std::string &name) const
 Return a devicegraph by name.
Devicegraphget_staging ()
 Return the staging devicegraph.
const Devicegraphget_staging () const
 Return the staging devicegraph.
const Devicegraphget_probed () const
 Return the probed devicegraph.
Devicegraphget_system ()
 Return the system devicegraph.
const Devicegraphget_system () const
 Return the system devicegraph.
void check (const CheckCallbacks *check_callbacks=nullptr) const
 Checks all devicegraphs.
MountByType get_default_mount_by () const
 Query the default mount-by method.
void set_default_mount_by (MountByType default_mount_by)
 Set the default mount-by method.
const std::string & get_rootprefix () const
void set_rootprefix (const std::string &rootprefix) ST_DEPRECATED
std::string prepend_rootprefix (const std::string &mount_point) const
 Prepends the root prefix to a mount point if necessary.
const Actiongraphcalculate_actiongraph ()
 Calculates the actiongraph including the compound actions.
void activate (const ActivateCallbacks *activate_callbacks) const
 Activate devices like multipath, DM and MD RAID, LVM and LUKS.
DeactivateStatus deactivate () const ST_DEPRECATED
DeactivateStatusV2 deactivate_v2 () const
 Deactivate devices like multipath, DM and MD RAID, LVM and LUKS.
void probe (const ProbeCallbacks *probe_callbacks=nullptr)
 Probe the system and replace the probed, system and staging devicegraphs.
void probe (SystemInfo &system_info, const ProbeCallbacksV3 *probe_callbacks=nullptr)
 Same as probe(const ProbeCallbacks* probe_callbacks) except for the SystemInfo parameter.
void commit (const CommitOptions &commit_options, const CommitCallbacks *commit_callbacks=nullptr)
 The actiongraph must be valid.
void commit (const CommitCallbacks *commit_callbacks=nullptr) ST_DEPRECATED
 The actiongraph must be valid.
void generate_pools (const Devicegraph *devicegraph)
 Generate pools, e.g.
Poolcreate_pool (const std::string &name)
 Create a pool with name.
void remove_pool (const std::string &name)
 Remove a pool by name.
void rename_pool (const std::string &old_name, const std::string &new_name)
 Rename a pool.
bool exists_pool (const std::string &name) const
 Check whether a pool exists by name.
std::vector< std::string > get_pool_names () const ST_DEPRECATED
 Get the names of all pools.
std::map< std::string, Pool * > get_pools ()
 Get all pools with their names.
std::map< std::string, const Pool * > get_pools () const
 Get all pools with their names.
Poolget_pool (const std::string &name)
 Return a pool by name.
const Poolget_pool (const std::string &name) const
 Return a pool by name.
Impl & get_impl ()
const Impl & get_impl () const

Detailed Description

The main entry point to libstorage.

Constructor & Destructor Documentation

◆ Storage()

storage::Storage::Storage ( const Environment & environment)

Construct Storage object.

Does not call activate() nor probe().

Exceptions
LockException,Exception

Member Function Documentation

◆ activate()

void storage::Storage::activate ( const ActivateCallbacks * activate_callbacks) const

Activate devices like multipath, DM and MD RAID, LVM and LUKS.

It is not required to have probed the system to call this function. On the other hand after calling activate() the system should be probed.

The message callback is unreliable since certain subsystems can be activated automatically (e.g. MD RAIDs by udev).

If an error reported via activate_callbacks is not ignored the function throws Aborted.

This function is only intended for the installation system.

Exceptions
Aborted,Exception

◆ calculate_actiongraph()

const Actiongraph * storage::Storage::calculate_actiongraph ( )

Calculates the actiongraph including the compound actions.

The actiongraph is only valid until either the probed or staging devicegraph is modified.

Exceptions
Exception

◆ check()

void storage::Storage::check ( const CheckCallbacks * check_callbacks = nullptr) const

Checks all devicegraphs.

There are two types of errors that can be found:

Errors that indicate a problem inside the library or a severe misuse of the library, e.g. attaching a BlkFilesystem directly to a PartitionTable. For these errors an exception is thrown.

Errors that can be easily fixed by the user, e.g. an overcommitted volume group. For these errors CheckCallbacks::error() is called.

The checks are WIP.

Exceptions
Exception

◆ commit() [1/2]

void storage::Storage::commit ( const CommitCallbacks * commit_callbacks = nullptr)

The actiongraph must be valid.

If an error reported via commit_callbacks is not ignored the function throws Aborted.

Exceptions
Aborted,Exception

◆ commit() [2/2]

void storage::Storage::commit ( const CommitOptions & commit_options,
const CommitCallbacks * commit_callbacks = nullptr )

The actiongraph must be valid.

If an error reported via commit_callbacks is not ignored the function throws Aborted.

Exceptions
Aborted,Exception

◆ copy_devicegraph()

Devicegraph * storage::Storage::copy_devicegraph ( const std::string & source_name,
const std::string & dest_name )
Exceptions
Exception

◆ create_devicegraph()

Devicegraph * storage::Storage::create_devicegraph ( const std::string & name)

Create a devicegraph with name.

Exceptions
Exception

◆ create_pool()

Pool * storage::Storage::create_pool ( const std::string & name)

Create a pool with name.

Exceptions
Exception

◆ deactivate()

DeactivateStatus storage::Storage::deactivate ( ) const
Exceptions
Exception

◆ deactivate_v2()

DeactivateStatusV2 storage::Storage::deactivate_v2 ( ) const

Deactivate devices like multipath, DM and MD RAID, LVM and LUKS.

It is not required to have probed the system to call this function. On the other hand after calling this function activate() should be called and the system should be probed.

The purpose of this function is to reverse the actions of activate() and auto-assemble.

This function is only intended for the installation system.

Exceptions
Exception

◆ generate_pools()

void storage::Storage::generate_pools ( const Devicegraph * devicegraph)

Generate pools, e.g.

"HDDs (512 B)" for HDDs with 512 B sector size and "SSDs (4 KiB)" for SSDs with 4 KiB sector size. The pools generated and their names may change anytime.

This function does not remove pools or devices from pools. It only adds things.

◆ get_devicegraph() [1/2]

Devicegraph * storage::Storage::get_devicegraph ( const std::string & name)

Return a devicegraph by name.

Exceptions
Exception

◆ get_devicegraph() [2/2]

const Devicegraph * storage::Storage::get_devicegraph ( const std::string & name) const

Return a devicegraph by name.

Exceptions
Exception

◆ get_devicegraphs()

std::map< std::string, const Devicegraph * > storage::Storage::get_devicegraphs ( ) const

Get all devicegraphs with their names.

Note: There is no non-const version since that would provide non-const access to the probed devicegraph.

◆ get_pool() [1/2]

Pool * storage::Storage::get_pool ( const std::string & name)

Return a pool by name.

Exceptions
Exception

◆ get_pool() [2/2]

const Pool * storage::Storage::get_pool ( const std::string & name) const

Return a pool by name.

Exceptions
Exception

◆ get_pools()

std::map< std::string, const Pool * > storage::Storage::get_pools ( ) const

Get all pools with their names.

◆ get_probed()

const Devicegraph * storage::Storage::get_probed ( ) const

Return the probed devicegraph.

Exceptions
Exception

◆ get_staging() [1/2]

Devicegraph * storage::Storage::get_staging ( )

Return the staging devicegraph.

Exceptions
Exception

◆ get_staging() [2/2]

const Devicegraph * storage::Storage::get_staging ( ) const

Return the staging devicegraph.

Exceptions
Exception

◆ get_system() [1/2]

Devicegraph * storage::Storage::get_system ( )

Return the system devicegraph.

Exceptions
Exception

◆ get_system() [2/2]

const Devicegraph * storage::Storage::get_system ( ) const

Return the system devicegraph.

Exceptions
Exception

◆ probe() [1/2]

void storage::Storage::probe ( const ProbeCallbacks * probe_callbacks = nullptr)

Probe the system and replace the probed, system and staging devicegraphs.

If an error reported via probe_callbacks is not ignored the function throws Aborted.

See also
probe(SystemInfo& system_info, const ProbeCallbacks* probe_callbacks)
Exceptions
Aborted,Exception

◆ probe() [2/2]

void storage::Storage::probe ( SystemInfo & system_info,
const ProbeCallbacksV3 * probe_callbacks = nullptr )

Same as probe(const ProbeCallbacks* probe_callbacks) except for the SystemInfo parameter.

Useful when after probing additional calls to BlkDevice::find_by_any_name() are used.

See also
probe(const ProbeCallbacks* probe_callbacks)
Exceptions
Aborted,Exception

◆ remove_devicegraph()

void storage::Storage::remove_devicegraph ( const std::string & name)

Remove a devicegraph by name.

Exceptions
Exception

◆ remove_pool()

void storage::Storage::remove_pool ( const std::string & name)

Remove a pool by name.

Exceptions
Exception

◆ rename_pool()

void storage::Storage::rename_pool ( const std::string & old_name,
const std::string & new_name )

Rename a pool.

Exceptions
Exception

◆ restore_devicegraph()

void storage::Storage::restore_devicegraph ( const std::string & name)
Exceptions
Exception

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