sbuild::personality Class Reference

Chroot personality. More...

#include <sbuild-personality.h>

List of all members.

Public Types

enum  error_code { BAD, SET }
 Error codes. More...
typedef unsigned long type
 Personality type.
typedef custom_error< error_codeerror
 Exception type.

Public Member Functions

 personality ()
 The constructor.
 personality (type persona)
 The constructor.
 personality (std::string const &persona)
 The constructor.
 ~personality ()
 * The destructor.
std::string const & get_name () const
 Get the name of the personality.
type get () const
 Get the personality.
void set () const
 Set the process personality.

Static Public Member Functions

static std::string get_personalities ()
 Print a list of the available personalities.

Static Private Member Functions

static type find_personality (std::string const &persona)
 Find a personality by name.
static std::string const & find_personality (type persona)
 Find a personality by number.

Private Attributes

type persona
 The personality type.

Static Private Attributes

static std::map< std::string,
type
personalities
 Mapping between personality name and type.

Friends

template<class charT, class traits>
std::basic_istream< charT,
traits > & 
operator>> (std::basic_istream< charT, traits > &stream, personality &rhs)
 Get the personality name from a stream.
template<class charT, class traits>
std::basic_ostream< charT,
traits > & 
operator<< (std::basic_ostream< charT, traits > &stream, personality const &rhs)
 Print the personality name to a stream.


Detailed Description

Chroot personality.

A chroot may have a personality (also knows as a process execution domain) which is used to run non-native binaries. For example, running 32-bit Linux binaries on a 64-bit Linux system, or an SVR4 binary on a 32-bit Linux system. This is currently a Linux only feature; it does nothing on non-Linux systems. This is a wrapper around the personality(2) system call.

Definition at line 41 of file sbuild-personality.h.


Member Typedef Documentation

typedef unsigned long sbuild::personality::type

Personality type.

Definition at line 45 of file sbuild-personality.h.

typedef custom_error<error_code> sbuild::personality::error

Exception type.

Definition at line 55 of file sbuild-personality.h.


Member Enumeration Documentation

enum sbuild::personality::error_code

Error codes.

Enumerator:
BAD  Personality is unknown.
SET  Could not set personality.

Definition at line 48 of file sbuild-personality.h.


Constructor & Destructor Documentation

sbuild::personality::personality (  ) 

The constructor.

On Linux systems, this is initialised with the current process' personality. On non-Linux systems, it is initialised as "undefined".

Definition at line 98 of file sbuild-personality.cc.

sbuild::personality::personality ( type  persona  ) 

The constructor.

Parameters:
persona the persona to set.

Definition at line 109 of file sbuild-personality.cc.

sbuild::personality::personality ( std::string const &  persona  ) 

The constructor.

Parameters:
persona the persona to set.

Definition at line 114 of file sbuild-personality.cc.

sbuild::personality::~personality (  ) 

* The destructor.

Definition at line 119 of file sbuild-personality.cc.


Member Function Documentation

std::string const & sbuild::personality::get_name (  )  const

Get the name of the personality.

Returns:
the personality name.

Definition at line 150 of file sbuild-personality.cc.

References find_personality().

Referenced by set().

Here is the call graph for this function:

Here is the caller graph for this function:

sbuild::personality::type sbuild::personality::get (  )  const

Get the personality.

Returns:
the personality.

Definition at line 156 of file sbuild-personality.cc.

References persona.

void sbuild::personality::set (  )  const

Set the process personality.

This sets the personality (if valid) using the personality(2) system call. If setting the personality fails, an error is thown.

Definition at line 162 of file sbuild-personality.cc.

References get_name(), and SET.

Here is the call graph for this function:

std::string sbuild::personality::get_personalities (  )  [static]

Print a list of the available personalities.

Returns:
a string of the available personalities.

Definition at line 175 of file sbuild-personality.cc.

References _, and personalities.

sbuild::personality::type sbuild::personality::find_personality ( std::string const &  persona  )  [static, private]

Find a personality by name.

Parameters:
persona the personality to find.
Returns:
the personality type; this is -1 if the personality was undefined, or -2 if the personality was unknown (not found).

Definition at line 124 of file sbuild-personality.cc.

References personalities.

Referenced by get_name().

Here is the caller graph for this function:

std::string const & sbuild::personality::find_personality ( type  persona  )  [static, private]

Find a personality by number.

Parameters:
persona the personality to find.
Returns:
the personality name, "undefined" if the personality was not defined, or "unknown" if the personality was not found.

Definition at line 136 of file sbuild-personality.cc.

References personalities.


Friends And Related Function Documentation

template<class charT, class traits>
std::basic_istream<charT,traits>& operator>> ( std::basic_istream< charT, traits > &  stream,
personality rhs 
) [friend]

Get the personality name from a stream.

Parameters:
stream the stream to get input from.
rhs the personality to set.
Returns:
the stream.

Definition at line 122 of file sbuild-personality.h.

template<class charT, class traits>
std::basic_ostream<charT,traits>& operator<< ( std::basic_ostream< charT, traits > &  stream,
personality const &  rhs 
) [friend]

Print the personality name to a stream.

Parameters:
stream the stream to output to.
rhs the personality to output.
Returns:
the stream.

Definition at line 153 of file sbuild-personality.h.


Member Data Documentation

type sbuild::personality::persona [private]

The personality type.

Definition at line 182 of file sbuild-personality.h.

Referenced by get().

std::map< std::string, sbuild::personality::type > sbuild::personality::personalities [static, private]

Mapping between personality name and type.

Definition at line 185 of file sbuild-personality.h.

Referenced by find_personality(), and get_personalities().


The documentation for this class was generated from the following files:
Generated on Sat Jan 27 16:14:33 2007 for schroot by  doxygen 1.5.1