libstorage-ng
|
The main entry point to libstorage. More...
#include <Storage.h>
Public Member Functions | |
Storage (const Environment &environment) | |
Construct Storage object. More... | |
const Environment & | get_environment () const |
const Arch & | get_arch () const |
Devicegraph * | create_devicegraph (const std::string &name) |
Create a devicegraph with name. More... | |
Devicegraph * | copy_devicegraph (const std::string &source_name, const std::string &dest_name) |
void | remove_devicegraph (const std::string &name) |
Remove a devicegraph by name. More... | |
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. More... | |
Devicegraph * | get_devicegraph (const std::string &name) |
Return a devicegraph by name. More... | |
const Devicegraph * | get_devicegraph (const std::string &name) const |
Return a devicegraph by name. More... | |
Devicegraph * | get_staging () |
Return the staging devicegraph. More... | |
const Devicegraph * | get_staging () const |
Return the staging devicegraph. More... | |
const Devicegraph * | get_probed () const |
Return the probed devicegraph. More... | |
Devicegraph * | get_system () |
Return the system devicegraph. More... | |
const Devicegraph * | get_system () const |
Return the system devicegraph. More... | |
void | check (const CheckCallbacks *check_callbacks=nullptr) const |
Checks all devicegraphs. More... | |
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 Actiongraph * | calculate_actiongraph () |
The actiongraph is only valid until either the probed or staging devicegraph is modified. More... | |
void | activate (const ActivateCallbacks *activate_callbacks) const |
Activate devices like multipath, DM and MD RAID, LVM and LUKS. More... | |
DeactivateStatus | deactivate () const ST_DEPRECATED |
DeactivateStatusV2 | deactivate_v2 () const |
Deactivate devices like multipath, DM and MD RAID, LVM and LUKS. More... | |
void | probe (const ProbeCallbacks *probe_callbacks=nullptr) |
Probe the system and replace the probed, system and staging devicegraphs. More... | |
void | commit (const CommitOptions &commit_options, const CommitCallbacks *commit_callbacks=nullptr) |
The actiongraph must be valid. More... | |
void | commit (const CommitCallbacks *commit_callbacks=nullptr) ST_DEPRECATED |
The actiongraph must be valid. More... | |
void | generate_pools (const Devicegraph *devicegraph) |
Generate pools, e.g. More... | |
Pool * | create_pool (const std::string &name) |
Create a pool with name. More... | |
void | remove_pool (const std::string &name) |
Remove a pool by name. More... | |
void | rename_pool (const std::string &old_name, const std::string &new_name) |
Rename a pool. More... | |
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. More... | |
Pool * | get_pool (const std::string &name) |
Return a pool by name. More... | |
const Pool * | get_pool (const std::string &name) const |
Return a pool by name. More... | |
Impl & | get_impl () |
const Impl & | get_impl () const |
The main entry point to libstorage.
storage::Storage::Storage | ( | const Environment & | environment | ) |
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.
const Actiongraph* storage::Storage::calculate_actiongraph | ( | ) |
The actiongraph is only valid until either the probed or staging devicegraph is modified.
Exception |
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.
Exception |
void storage::Storage::commit | ( | const CommitOptions & | commit_options, |
const CommitCallbacks * | commit_callbacks = nullptr |
||
) |
void storage::Storage::commit | ( | const CommitCallbacks * | commit_callbacks = nullptr | ) |
Devicegraph* storage::Storage::copy_devicegraph | ( | const std::string & | source_name, |
const std::string & | dest_name | ||
) |
Exception |
Devicegraph* storage::Storage::create_devicegraph | ( | const std::string & | name | ) |
Create a devicegraph with name.
Exception |
Pool* storage::Storage::create_pool | ( | const std::string & | name | ) |
Create a pool with name.
Exception |
DeactivateStatus storage::Storage::deactivate | ( | ) | const |
Exception |
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.
Exception |
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.
Devicegraph* storage::Storage::get_devicegraph | ( | const std::string & | name | ) |
Return a devicegraph by name.
Exception |
const Devicegraph* storage::Storage::get_devicegraph | ( | const std::string & | name | ) | const |
Return a devicegraph by name.
Exception |
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.
Pool* storage::Storage::get_pool | ( | const std::string & | name | ) |
Return a pool by name.
Exception |
const Pool* storage::Storage::get_pool | ( | const std::string & | name | ) | const |
Return a pool by name.
Exception |
std::map<std::string, const Pool*> storage::Storage::get_pools | ( | ) | const |
Get all pools with their names.
const Devicegraph* storage::Storage::get_probed | ( | ) | const |
Return the probed devicegraph.
Exception |
Devicegraph* storage::Storage::get_staging | ( | ) |
Return the staging devicegraph.
Exception |
const Devicegraph* storage::Storage::get_staging | ( | ) | const |
Return the staging devicegraph.
Exception |
Devicegraph* storage::Storage::get_system | ( | ) |
Return the system devicegraph.
Exception |
const Devicegraph* storage::Storage::get_system | ( | ) | const |
Return the system devicegraph.
Exception |
void storage::Storage::probe | ( | const ProbeCallbacks * | probe_callbacks = nullptr | ) |
void storage::Storage::remove_devicegraph | ( | const std::string & | name | ) |
Remove a devicegraph by name.
Exception |
void storage::Storage::remove_pool | ( | const std::string & | name | ) |
Remove a pool by name.
Exception |
void storage::Storage::rename_pool | ( | const std::string & | old_name, |
const std::string & | new_name | ||
) |
Rename a pool.
Exception |
void storage::Storage::restore_devicegraph | ( | const std::string & | name | ) |
Exception |