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

Chroot support for filesystem union based sessions. More...

#include <fsunion.h>

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

Public Types

enum  error_code { FSUNION_TYPE_UNKNOWN, FSUNION_OVERLAY_ABS, FSUNION_UNDERLAY_ABS }
 Error codes. More...
 
typedef custom_error< error_codeerror
 Exception type.
 
typedef std::shared_ptr< fsunionptr
 A shared_ptr to a chroot facet object.
 
typedef std::shared_ptr< const
fsunion
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::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 ~fsunion ()
 The destructor.
 
virtual facet::ptr clone () const
 Copy the chroot facet. More...
 
std::string const & get_name () const
 Get the name of the chroot facet. More...
 
bool get_union_configured () const
 Get fs union configured state. More...
 
virtual std::string const & get_union_type () const
 Get the filesystem union type. More...
 
virtual void set_union_type (const std::string &union_type)
 Set the filesystem union type. More...
 
virtual std::string const & get_union_mount_options () const
 Get the filesystem union mount options (branch configuration). More...
 
virtual void set_union_mount_options (const std::string &union_mount_options)
 Set the filesystem union mount options (branch configuration). More...
 
virtual std::string const & get_union_overlay_directory () const
 Get the union overlay directory. More...
 
virtual void set_union_overlay_directory (const std::string &directory)
 Set the union overlay directory. More...
 
virtual std::string const & get_union_underlay_directory () const
 Get the union underlay directory. More...
 
virtual void set_union_underlay_directory (const std::string &directory)
 Set the union underlay directory. 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...
 
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...
 
- Public Member Functions inherited from sbuild::chroot::facet::facet
virtual ~facet ()
 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...
 

Private Member Functions

 fsunion ()
 The constructor.
 

Private Attributes

std::string union_type
 filesystem union type.
 
std::string union_mount_options
 Union mount options (branch configuration).
 
std::string union_overlay_directory
 Union read-write overlay directory.
 
std::string union_underlay_directory
 Union read-only underlay directory.
 

Additional Inherited Members

- Protected Member Functions inherited from sbuild::chroot::facet::facet
 facet ()
 The constructor.
 
virtual void set_chroot (chroot &chroot, bool copy=false)
 Set containing chroot. More...
 
- 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.
 
- Protected Attributes inherited from sbuild::chroot::facet::facet
chrootowner
 Chroot owning this facet.
 

Detailed Description

Chroot support for filesystem union based sessions.

A chroot may offer session support using a filesystem union like aufs or unionfs. A new union type may need to adapt the 10mount or 05union script to properly populate the underlay and mount directory. The overlay directory and union setup is already handled.

Member Enumeration Documentation

Error codes.

Enumerator
FSUNION_TYPE_UNKNOWN 

Unknown filesystem union type.

FSUNION_OVERLAY_ABS 

Union overlay must have an absolute path.

FSUNION_UNDERLAY_ABS 

Union underlay must have an absolute path.

Member Function Documentation

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

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_union_overlay_directory(), get_union_underlay_directory(), sbuild::chroot::facet::facet::owner, sbuild::chroot::chroot::remove_facet(), set_union_overlay_directory(), and set_union_underlay_directory().

void sbuild::chroot::facet::fsunion::chroot_source_setup ( const chroot parent)
virtual

Set up a newly-cloned source chroot.

Parameters
parentthe parent of the cloned chroot.

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

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

facet::ptr sbuild::chroot::facet::fsunion::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 fsunion().

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

Create a chroot facet.

Returns
a shared_ptr to the new chroot facet.

References fsunion().

Referenced by sbuild::chroot::facet::loopback::set_chroot(), sbuild::chroot::facet::block_device::set_chroot(), and sbuild::chroot::facet::directory::set_chroot().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::fsunion::get_details ( format_detail detail) const
virtual
void sbuild::chroot::facet::fsunion::get_keyfile ( keyfile keyfile) const
virtual

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_name(), get_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), get_union_underlay_directory(), sbuild::chroot::facet::facet::owner, and sbuild::keyfile::set_object_value().

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

Get the name of the chroot facet.

Returns
the chroot facet name.

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

facet::session_flags sbuild::chroot::facet::fsunion::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(), get_union_configured(), sbuild::chroot::facet::facet::owner, sbuild::chroot::facet::facet::SESSION_NOFLAGS, and sbuild::chroot::facet::facet::SESSION_PURGE.

bool sbuild::chroot::facet::fsunion::get_union_configured ( ) const

Get fs union configured state.

Returns
if fs union is configured

References get_union_type().

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

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::facet::fsunion::get_union_mount_options ( ) const
virtual

Get the filesystem union mount options (branch configuration).

See Also
set_union_mount_options
Returns
the filesystem union branch configuration.

References union_mount_options.

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

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::facet::fsunion::get_union_overlay_directory ( ) const
virtual

Get the union overlay directory.

Returns
the writeable overlay directory.

References union_overlay_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::fsunion::get_union_type ( ) const
virtual

Get the filesystem union type.

See Also
set_union_type
Returns
the union filesytem type.

References union_type.

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

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::facet::fsunion::get_union_underlay_directory ( ) const
virtual

Get the union underlay directory.

Returns
the writeable underlay directory.

References union_underlay_directory.

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

+ Here is the caller graph for this function:

void sbuild::chroot::facet::fsunion::get_used_keys ( string_list used_keys) const
virtual

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::fsunion::set_keyfile ( const keyfile keyfile)
virtual

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(), get_union_configured(), sbuild::chroot::facet::facet::owner, sbuild::keyfile::PRIORITY_OPTIONAL, sbuild::keyfile::PRIORITY_REQUIRED, set_union_mount_options(), set_union_overlay_directory(), set_union_type(), and set_union_underlay_directory().

void sbuild::chroot::facet::fsunion::set_union_mount_options ( const std::string &  union_mount_options)
virtual

Set the filesystem union mount options (branch configuration).

Normally a temporary directory is used as the writeable branch, which is removed on session end. This allows the building of a complex union which can merge multiple branches. The string has to be constructed as expected by the filesystem union type and is directly used as the mount '-o' option string.

Parameters
union_mount_optionsa union filesystem-specific branch description

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::fsunion::set_union_overlay_directory ( const std::string &  directory)
virtual

Set the union overlay directory.

Parameters
directorythe writeable overlay directory.

References sbuild::is_absname().

Referenced by chroot_session_setup(), and set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::fsunion::set_union_type ( const std::string &  union_type)
virtual

Set the filesystem union type.

Currently supported values are aufs, unionfs and none.

Parameters
union_typethe filesystem type.

References sbuild::chroot::facet::source_clonable::create(), FSUNION_TYPE_UNKNOWN, sbuild::chroot::facet::facet::owner, and union_type.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::fsunion::set_union_underlay_directory ( const std::string &  directory)
virtual

Set the union underlay directory.

Parameters
directorythe writeable underlay directory.

References sbuild::is_absname().

Referenced by chroot_session_setup(), and set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::fsunion::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_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), and get_union_underlay_directory().


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