sbuild  1.7.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
sbuild::chroot::facet::btrfs_snapshot Class Reference

A chroot stored on a Btrfs subvolume. More...

#include <btrfs-snapshot.h>

+ Inheritance diagram for sbuild::chroot::facet::btrfs_snapshot:
+ Collaboration diagram for sbuild::chroot::facet::btrfs_snapshot:

Public Types

typedef chroot::error error
 Exception type.
 
typedef std::shared_ptr
< btrfs_snapshot
ptr
 A shared_ptr to a chroot facet object.
 
typedef std::shared_ptr< const
btrfs_snapshot
const_ptr
 A shared_ptr to a const chroot facet object.
 
- Public Types inherited from sbuild::chroot::facet::facet
enum  session_flags { SESSION_NOFLAGS = 0, SESSION_CREATE = 1 << 0, SESSION_CLONE = 1 << 1, SESSION_PURGE = 1 << 2 }
 Chroot session properties. More...
 
typedef std::shared_ptr< facetptr
 A shared_ptr to a chroot facet object.
 
typedef std::shared_ptr< const
facet
const_ptr
 A shared_ptr to a const chroot facet object.
 
- Public Types inherited from sbuild::chroot::facet::storage
typedef std::shared_ptr< storageptr
 A shared_ptr to a chroot storage object.
 
typedef std::shared_ptr< const
storage
const_ptr
 A shared_ptr to a const chroot storage object.
 
- Public Types inherited from sbuild::chroot::facet::session_setup
typedef std::shared_ptr
< session_setup
ptr
 A shared_ptr to a chroot session_setup object.
 
typedef std::shared_ptr< const
session_setup
const_ptr
 A shared_ptr to a const chroot session_setup object.
 
- Public Types inherited from sbuild::chroot::facet::source_setup
typedef std::shared_ptr
< source_setup
ptr
 A shared_ptr to a chroot source_setup object.
 
typedef std::shared_ptr< const
source_setup
const_ptr
 A shared_ptr to a const chroot source_setup object.
 

Public Member Functions

virtual ~btrfs_snapshot ()
 The destructor.
 
virtual std::string const & get_name () const
 Get the name of the chroot facet. More...
 
facet::ptr clone () const
 Copy the chroot facet. More...
 
std::string const & get_source_subvolume () const
 Get the source subvolume path. More...
 
void set_source_subvolume (const std::string &source_subvolume)
 Set the source subvolume path. More...
 
std::string const & get_snapshot_directory () const
 Get the snapshot directory. More...
 
void set_snapshot_directory (const std::string &snapshot_directory)
 Set the snapshot directory. More...
 
std::string const & get_snapshot_name () const
 Get the snapshot name. More...
 
void set_snapshot_name (const std::string &snapshot_name)
 Set the snapshot name. More...
 
virtual std::string get_path () const
 Get the path to the chroot. More...
 
virtual void setup_env (environment &env) const
 Set environment. More...
 
virtual session_flags get_session_flags () const
 Get the session flags of the chroot. More...
 
- Public Member Functions inherited from sbuild::chroot::facet::facet
virtual ~facet ()
 The destructor.
 
- Public Member Functions inherited from sbuild::chroot::facet::storage
virtual ~storage ()
 The destructor.
 
- Public Member Functions inherited from sbuild::chroot::facet::session_setup
virtual ~session_setup ()
 The destructor.
 
- Public Member Functions inherited from sbuild::chroot::facet::source_setup
virtual ~source_setup ()
 The destructor.
 

Static Public Member Functions

static ptr create ()
 Create a chroot facet. More...
 

Protected Member Functions

 btrfs_snapshot ()
 The constructor.
 
 btrfs_snapshot (const btrfs_snapshot &rhs)
 The copy constructor.
 
void set_chroot (chroot &chroot, bool copy)
 Set containing chroot. More...
 
virtual void setup_lock (chroot::setup_type type, bool lock, int status)
 
virtual void get_details (format_detail &detail) const
 Get detailed information about the chroot for output. More...
 
virtual void get_used_keys (string_list &used_keys) const
 Get a list of the keys used during keyfile parsing. More...
 
virtual void get_keyfile (keyfile &keyfile) const
 Copy the chroot properties into a keyfile. More...
 
virtual void set_keyfile (const keyfile &keyfile)
 Set the chroot properties from a keyfile. More...
 
virtual void chroot_session_setup (const chroot &parent, const std::string &session_id, const std::string &alias, const std::string &user, bool root)
 Set up a newly-cloned session chroot. More...
 
virtual void chroot_source_setup (const chroot &parent)
 Set up a newly-cloned source chroot. More...
 
- Protected Member Functions inherited from sbuild::chroot::facet::facet
 facet ()
 The constructor.
 
- Protected Member Functions inherited from sbuild::chroot::facet::storage
 storage ()
 The constructor.
 
- Protected Member Functions inherited from sbuild::chroot::facet::session_setup
 session_setup ()
 The constructor.
 
- Protected Member Functions inherited from sbuild::chroot::facet::source_setup
 source_setup ()
 The constructor.
 

Private Attributes

std::string source_subvolume
 Btrfs source subvolume.
 
std::string snapshot_directory
 Btrfs snapshot path.
 
std::string snapshot_name
 Btrfs snapshot name.
 

Friends

class chroot
 

Additional Inherited Members

- Protected Attributes inherited from sbuild::chroot::facet::facet
chrootowner
 Chroot owning this facet.
 

Detailed Description

A chroot stored on a Btrfs subvolume.

A snapshot subvolume will be created and mounted on demand.

Member Function Documentation

void sbuild::chroot::facet::btrfs_snapshot::chroot_session_setup ( const chroot parent,
const std::string &  session_id,
const std::string &  alias,
const std::string &  user,
bool  root 
)
protectedvirtual

Set up a newly-cloned session chroot.

Parameters
parentthe parent of the cloned chroot.
session_idthe identifier (session_id) for the new session.
aliasused to initially identify the chroot.
userthe user creating the session.
roottrue if the user has root access, otherwise false.

Implements sbuild::chroot::facet::session_setup.

References sbuild::chroot::chroot::get_name(), get_snapshot_directory(), sbuild::chroot::facet::facet::owner, and set_snapshot_name().

void sbuild::chroot::facet::btrfs_snapshot::chroot_source_setup ( const chroot parent)
protectedvirtual

Set up a newly-cloned source chroot.

Parameters
parentthe parent of the cloned chroot.

Implements sbuild::chroot::facet::source_setup.

References sbuild::chroot::facet::directory::create(), sbuild::chroot::facet::facet::owner, and sbuild::chroot::chroot::replace_facet().

facet::ptr sbuild::chroot::facet::btrfs_snapshot::clone ( ) const
virtual

Copy the chroot facet.

This is a virtual copy constructor.

Returns
a shared_ptr to the new copy of the chroot facet.

Implements sbuild::chroot::facet::facet.

References btrfs_snapshot().

btrfs_snapshot::ptr sbuild::chroot::facet::btrfs_snapshot::create ( )
static

Create a chroot facet.

Returns
a shared_ptr to the new chroot facet.

References btrfs_snapshot().

void sbuild::chroot::facet::btrfs_snapshot::get_details ( format_detail detail) const
protectedvirtual

Get detailed information about the chroot for output.

Parameters
detailthe details to output to.

Reimplemented from sbuild::chroot::facet::facet.

References sbuild::_(), sbuild::format_detail::add(), get_snapshot_directory(), get_snapshot_name(), and get_source_subvolume().

void sbuild::chroot::facet::btrfs_snapshot::get_keyfile ( keyfile keyfile) const
protectedvirtual

Copy the chroot properties into a keyfile.

The keyfile group with the name of the chroot will be set; if it already exists, it will be removed before setting it.

Parameters
keyfilethe keyfile to use.

Reimplemented from sbuild::chroot::facet::facet.

References sbuild::chroot::chroot::get_facet(), sbuild::chroot::chroot::get_name(), get_snapshot_directory(), get_snapshot_name(), get_source_subvolume(), sbuild::chroot::facet::facet::owner, and sbuild::keyfile::set_object_value().

std::string const & sbuild::chroot::facet::btrfs_snapshot::get_name ( ) const
virtual

Get the name of the chroot facet.

Returns
the chroot facet name.

Implements sbuild::chroot::facet::facet.

std::string sbuild::chroot::facet::btrfs_snapshot::get_path ( ) const
virtual

Get the path to the chroot.

This is the absolute path to the root of the chroot, and is typically the same as the mount location and location concatenated together, but is overridden by the chroot type if required.

Returns
the path.

Implements sbuild::chroot::facet::storage.

References sbuild::chroot::chroot::get_mount_location(), and sbuild::chroot::facet::facet::owner.

facet::session_flags sbuild::chroot::facet::btrfs_snapshot::get_session_flags ( ) const
virtual

Get the session flags of the chroot.

These determine how the Session controlling the chroot will operate.

Parameters
chrootthe chroot to use.
Returns
the session flags.

Reimplemented from sbuild::chroot::facet::facet.

References sbuild::chroot::chroot::get_facet(), sbuild::chroot::facet::facet::owner, sbuild::chroot::facet::facet::SESSION_NOFLAGS, and sbuild::chroot::facet::facet::SESSION_PURGE.

std::string const & sbuild::chroot::facet::btrfs_snapshot::get_snapshot_directory ( ) const

Get the snapshot directory.

Returns
the directory.

References snapshot_directory.

Referenced by chroot_session_setup(), get_details(), get_keyfile(), and setup_env().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::facet::btrfs_snapshot::get_snapshot_name ( ) const

Get the snapshot name.

This is used by "btrfs subvolume snapshot", and is the full path to the snapshot.

Returns
the name.

References snapshot_name.

Referenced by get_details(), get_keyfile(), and setup_env().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::facet::btrfs_snapshot::get_source_subvolume ( ) const

Get the source subvolume path.

This is used by "btrfs subvolume snapshot".

Returns
the source subvolume.

References source_subvolume.

Referenced by sbuild::chroot::facet::directory::directory(), get_details(), get_keyfile(), and setup_env().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::btrfs_snapshot::get_used_keys ( string_list used_keys) const
protectedvirtual

Get a list of the keys used during keyfile parsing.

Returns
a list of key names.

Reimplemented from sbuild::chroot::facet::facet.

void sbuild::chroot::facet::btrfs_snapshot::set_chroot ( chroot chroot,
bool  copy 
)
protectedvirtual

Set containing chroot.

The copy parameter is used to inform the facet if it is new or a copy; this is intended to allow additional facets to only be added if the facet is new, for example, to avoid re-adding removed facets when copying a chroot.

Parameters
chrootthe chroot containing this facet.
copytrue if the facet has been copied, or false if this is a new instance.

Reimplemented from sbuild::chroot::facet::facet.

References sbuild::chroot::chroot::add_facet(), sbuild::chroot::facet::session_clonable::create(), sbuild::chroot::facet::source_clonable::create(), sbuild::chroot::chroot::get_facet(), sbuild::chroot::facet::facet::owner, and sbuild::chroot::facet::facet::set_chroot().

void sbuild::chroot::facet::btrfs_snapshot::set_keyfile ( const keyfile keyfile)
protectedvirtual

Set the chroot properties from a keyfile.

The chroot name must have previously been set, so that the correct keyfile group may be determined.

Parameters
keyfilethe keyfile to get the properties from.

Reimplemented from sbuild::chroot::facet::facet.

References sbuild::chroot::chroot::get_facet(), sbuild::chroot::chroot::get_name(), sbuild::keyfile::get_object_value(), sbuild::chroot::facet::facet::owner, sbuild::keyfile::PRIORITY_DISALLOWED, sbuild::keyfile::PRIORITY_REQUIRED, set_snapshot_directory(), set_snapshot_name(), and set_source_subvolume().

void sbuild::chroot::facet::btrfs_snapshot::set_snapshot_directory ( const std::string &  snapshot_directory)

Set the snapshot directory.

Parameters
snapshot_directorythe snapshot directory.

References sbuild::chroot::chroot::DIRECTORY_ABS, sbuild::is_absname(), snapshot_directory, and source_subvolume.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::btrfs_snapshot::set_snapshot_name ( const std::string &  snapshot_name)

Set the snapshot name.

This is used by "btrfs subvolume snapshot", and is the full path to the snapshot.

Parameters
snapshot_namethe snapshot name.

References sbuild::chroot::chroot::DIRECTORY_ABS, sbuild::is_absname(), snapshot_name, and source_subvolume.

Referenced by chroot_session_setup(), and set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::btrfs_snapshot::set_source_subvolume ( const std::string &  source_subvolume)

Set the source subvolume path.

This is used by "btrfs subvolume snapshot".

Parameters
source_subvolumethe source subvolume.

References sbuild::chroot::chroot::DIRECTORY_ABS, sbuild::is_absname(), and source_subvolume.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::btrfs_snapshot::setup_env ( environment env) const
virtual

Set environment.

Set the environment that the setup scripts will see during execution.

Parameters
envthe environment to set.

Reimplemented from sbuild::chroot::facet::facet.

References sbuild::environment::add(), get_snapshot_directory(), get_snapshot_name(), and get_source_subvolume().


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