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

Class to represent a btrfs subvolume in the devicegraph. More...

#include <BtrfsSubvolume.h>

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

Public Member Functions

long get_id () const
 Get the id of the btrfs subvolume.
 
bool is_top_level () const
 Check whether the subvolume is the top-level subvolume.
 
const std::string & get_path () const
 Get the path of the btrfs subvolume.
 
bool is_nocow () const
 Get the copy-on-write (COW) flag of the btrfs subvolume.
 
void set_nocow (bool nocow)
 Set the copy-on-write (COW) flag of the btrfs subvolume.
 
bool is_default_btrfs_subvolume () const
 Check whether the subvolume is the default subvolume.
 
void set_default_btrfs_subvolume ()
 Set the subvolume to be the default subvolume.
 
Btrfsget_btrfs ()
 Return the btrfs filesystem of the btrfs subvolume.
 
const Btrfsget_btrfs () const
 Return the btrfs filesystem of the btrfs subvolume.
 
BtrfsSubvolumeget_top_level_btrfs_subvolume ()
 Return the top-level subvolume.
 
const BtrfsSubvolumeget_top_level_btrfs_subvolume () const
 Return the top-level subvolume.
 
bool has_snapshots () const
 Check whether the btrfs subvolume has snapshots.
 
std::vector< BtrfsSubvolume * > get_snapshots ()
 Get snapshots of the btrfs subvolume.
 
std::vector< const BtrfsSubvolume * > get_snapshots () const
 Get snapshots of the btrfs subvolume.
 
bool has_origin () const
 Check whether the btrfs subvolume has an origin.
 
BtrfsSubvolumeget_origin ()
 Get the origin of the btrfs subvolume if it has one.
 
const BtrfsSubvolumeget_origin () const
 Get the origin of the btrfs subvolume if it has one.
 
bool has_btrfs_qgroup () const
 Return whether the subvolume as a corresponding level 0 qgroup.
 
BtrfsQgroupget_btrfs_qgroup ()
 Return the corresponding level 0 qgroup of the subvolume.
 
const BtrfsQgroupget_btrfs_qgroup () const
 Return the corresponding level 0 qgroup of the subvolume.
 
BtrfsQgroupcreate_btrfs_qgroup ()
 Create the corresponding level 0 qgroup for the subvolume.
 
BtrfsSubvolumecreate_btrfs_subvolume (const std::string &path)
 Create a btrfs subvolume for the btrfs subvolume.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
virtual BtrfsSubvolumeclone () const override
 
 BtrfsSubvolume (Impl *impl)
 
- Public Member Functions inherited from storage::Mountable
bool supports_mount () const
 Checks whether the library supports mounting the mountable.
 
MountPointcreate_mount_point (const std::string &path)
 Create a new mount point for the mountable with path.
 
bool has_mount_point () const
 Checks whether the mountable has a mount point.
 
MountPointget_mount_point ()
 Returns the mount point of the mountable.
 
const MountPointget_mount_point () const
 Returns the mount point of the mountable.
 
void remove_mount_point ()
 Removes the mount point from the mountable.
 
bool has_filesystem () const
 Checks whether the mountable has a filesystem.
 
Filesystemget_filesystem ()
 Return the filesystem of the mountable.
 
const Filesystemget_filesystem () const
 Return the filesystem of the mountable.
 
MountByType get_mount_by () const ST_DEPRECATED
 
void set_mount_by (MountByType mount_by) ST_DEPRECATED
 
const std::vector< std::string > & get_mount_opts () const ST_DEPRECATED
 
void set_mount_opts (const std::vector< std::string > &mount_opts) ST_DEPRECATED
 
const std::vector< std::string > & get_fstab_options () const ST_DEPRECATED
 
void set_fstab_options (const std::vector< std::string > &mount_opts) ST_DEPRECATED
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
- Public Member Functions inherited from storage::Device
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
 
void save (xmlNode *node) const ST_DEPRECATED
 

Static Public Member Functions

static BtrfsSubvolumecreate (Devicegraph *devicegraph, const std::string &path)
 Create a device of type BtrfsSubvolume.
 
static BtrfsSubvolumeload (Devicegraph *devicegraph, const xmlNode *node)
 
static bool compare_by_id (const BtrfsSubvolume *lhs, const BtrfsSubvolume *rhs)
 Compare (less than) two BtrfsSubvolumes by id.
 
- Static Public Member Functions inherited from storage::Mountable
static std::vector< Mountable * > get_all (Devicegraph *devicegraph)
 Get all Mountables.
 
static std::vector< const Mountable * > get_all (const Devicegraph *devicegraph)
 Get all Mountables.
 
static bool is_valid_path (FsType fs_type, const std::string &path)
 Checks whether the path is valid.
 
- Static Public Member Functions inherited from storage::Device
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.
 

Additional Inherited Members

- Protected Member Functions inherited from storage::Mountable
 Mountable (Impl *impl)
 
- Protected Member Functions inherited from storage::Device
 Device (Impl *impl)
 
void create (Devicegraph *devicegraph) ST_DEPRECATED
 Create a device in the devicegraph.
 
void load (Devicegraph *devicegraph) ST_DEPRECATED
 

Detailed Description

Class to represent a btrfs subvolume in the devicegraph.

See also
Btrfs

Member Function Documentation

◆ clone()

virtual BtrfsSubvolume * storage::BtrfsSubvolume::clone ( ) const
overridevirtual

Implements storage::Device.

◆ compare_by_id()

static bool storage::BtrfsSubvolume::compare_by_id ( const BtrfsSubvolume * lhs,
const BtrfsSubvolume * rhs )
static

Compare (less than) two BtrfsSubvolumes by id.

See also
get_id()

◆ create()

static BtrfsSubvolume * storage::BtrfsSubvolume::create ( Devicegraph * devicegraph,
const std::string & path )
static

Create a device of type BtrfsSubvolume.

Usually this function is not called directly. Instead BtrfsSubvolume::create_btrfs_subvolume() is called.

See also
Device::create(Devicegraph*)

◆ create_btrfs_qgroup()

BtrfsQgroup * storage::BtrfsSubvolume::create_btrfs_qgroup ( )

Create the corresponding level 0 qgroup for the subvolume.

Usually the qgroup already exists (if quota is enabled) unless it was removed by the user. Quota must be enabled.

Exceptions
Exception

◆ create_btrfs_subvolume()

BtrfsSubvolume * storage::BtrfsSubvolume::create_btrfs_subvolume ( const std::string & path)

Create a btrfs subvolume for the btrfs subvolume.

If quota is enabled for the btrfs also the corresponding level 0 qgroup is created.

Exceptions
Exception

◆ get_btrfs()

const Btrfs * storage::BtrfsSubvolume::get_btrfs ( ) const

Return the btrfs filesystem of the btrfs subvolume.

◆ get_btrfs_qgroup() [1/2]

BtrfsQgroup * storage::BtrfsSubvolume::get_btrfs_qgroup ( )

Return the corresponding level 0 qgroup of the subvolume.

Exceptions
Exception

◆ get_btrfs_qgroup() [2/2]

const BtrfsQgroup * storage::BtrfsSubvolume::get_btrfs_qgroup ( ) const

Return the corresponding level 0 qgroup of the subvolume.

Exceptions
Exception

◆ get_id()

long storage::BtrfsSubvolume::get_id ( ) const

Get the id of the btrfs subvolume.

For newly created btrfs subvolumes the id is -1.

◆ get_origin() [1/2]

BtrfsSubvolume * storage::BtrfsSubvolume::get_origin ( )

Get the origin of the btrfs subvolume if it has one.

See also
has_origin()
Exceptions
Exception

◆ get_origin() [2/2]

const BtrfsSubvolume * storage::BtrfsSubvolume::get_origin ( ) const

Get the origin of the btrfs subvolume if it has one.

See also
has_origin()
Exceptions
Exception

◆ get_snapshots() [1/2]

std::vector< BtrfsSubvolume * > storage::BtrfsSubvolume::get_snapshots ( )

Get snapshots of the btrfs subvolume.

See also
has_snapshots()

◆ get_snapshots() [2/2]

std::vector< const BtrfsSubvolume * > storage::BtrfsSubvolume::get_snapshots ( ) const

Get snapshots of the btrfs subvolume.

See also
has_snapshots()

◆ get_top_level_btrfs_subvolume() [1/2]

BtrfsSubvolume * storage::BtrfsSubvolume::get_top_level_btrfs_subvolume ( )

Return the top-level subvolume.

See also
is_top_level()

◆ get_top_level_btrfs_subvolume() [2/2]

const BtrfsSubvolume * storage::BtrfsSubvolume::get_top_level_btrfs_subvolume ( ) const

Return the top-level subvolume.

See also
is_top_level()

◆ has_origin()

bool storage::BtrfsSubvolume::has_origin ( ) const

Check whether the btrfs subvolume has an origin.

In other words, whether it is a snapshot. Note that here a snapshot stops being considered a snapshot if the origin has been removed.

The term "origin" is not used with btrfs but with LVM. Unfortunately btrfs is not consistent with the names: With 'btrfs subvolume snapshot' the thing is called "source", with 'btrfs subvolume list' the thing is called "parent_uuid" (but not "parent_id"). Both "source" and "parent" are already used in libstorage-ng.

See also
has_snapshots()

◆ set_default_btrfs_subvolume()

void storage::BtrfsSubvolume::set_default_btrfs_subvolume ( )

Set the subvolume to be the default subvolume.

See also
is_default_btrfs_subvolume()

◆ set_nocow()

void storage::BtrfsSubvolume::set_nocow ( bool nocow)

Set the copy-on-write (COW) flag of the btrfs subvolume.

See also
is_nocow()

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