sbuild  1.7.2
loopback.h
1 /* Copyright © 2005-2013 Roger Leigh <rleigh@debian.org>
2  *
3  * schroot is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * schroot is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  *********************************************************************/
18 
19 #ifndef SBUILD_CHROOT_FACET_LOOPBACK_H
20 #define SBUILD_CHROOT_FACET_LOOPBACK_H
21 
22 #include <sbuild/chroot/chroot.h>
23 #include <sbuild/chroot/facet/facet.h>
24 #include <sbuild/chroot/facet/session-setup.h>
25 #include <sbuild/chroot/facet/storage.h>
26 
27 namespace sbuild
28 {
29  namespace chroot
30  {
31  namespace facet
32  {
33 
39  class loopback : public facet,
40  public storage,
41  public session_setup
42  {
43  public:
46 
48  typedef std::shared_ptr<loopback> ptr;
49 
51  typedef std::shared_ptr<const loopback> const_ptr;
52 
53  protected:
55  loopback ();
56 
58  loopback (const loopback& rhs);
59 
60  void
62  bool copy);
63 
64  friend class chroot;
65 
66  public:
68  virtual ~loopback ();
69 
70  virtual std::string const&
71  get_name () const;
72 
78  static ptr
79  create ();
80 
82  clone () const;
83 
89  std::string const&
90  get_filename () const;
91 
97  void
98  set_filename (const std::string& filename);
99 
100  virtual std::string
101  get_path () const;
102 
103  virtual void
104  setup_env (environment& env) const;
105 
106  protected:
107  virtual void
108  setup_lock (chroot::setup_type type,
109  bool lock,
110  int status);
111 
112  virtual void
113  get_details (format_detail& detail) const;
114 
115  virtual void
116  get_used_keys (string_list& used_keys) const;
117 
118  virtual void
119  get_keyfile (keyfile& keyfile) const;
120 
121  virtual void
122  set_keyfile (const keyfile& keyfile);
123 
124  virtual void
125  chroot_session_setup (const chroot& parent,
126  const std::string& session_id,
127  const std::string& alias,
128  const std::string& user,
129  bool root);
130 
131  private:
133  std::string filename;
134  };
135 
136  }
137  }
138 }
139 
140 #endif /* SBUILD_CHROOT_FACET_LOOPBACK_H */
141 
142 /*
143  * Local Variables:
144  * mode:C++
145  * End:
146  */
facet::ptr clone() const
Copy the chroot facet.
Definition: loopback.cc:110
Debian source builder components.
Definition: ctty.cc:31
Chroot storage.
Definition: storage.h:39
std::shared_ptr< loopback > ptr
A shared_ptr to a chroot facet object.
Definition: loopback.h:48
std::shared_ptr< const loopback > const_ptr
A shared_ptr to a const chroot facet object.
Definition: loopback.h:51
virtual ~loopback()
The destructor.
Definition: loopback.cc:75
std::string filename
The file to use.
Definition: loopback.h:133
chroot::error error
Exception type.
Definition: loopback.h:45
Container of environment variables.
Definition: environment.h:38
loopback()
The constructor.
Definition: loopback.cc:59
Common chroot data.
Definition: chroot.h:50
virtual void set_keyfile(const keyfile &keyfile)
Set the chroot properties from a keyfile.
Definition: loopback.cc:199
Advisory locking.
Definition: lock.h:38
static ptr create()
Create a chroot facet.
Definition: loopback.cc:104
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.
Definition: loopback.cc:207
Base class for all facets.
Definition: facet.h:50
std::vector< std::string > string_list
A string vector.
Definition: types.h:38
Common chroot data.
Definition: session-setup.h:41
Custom error.
Definition: custom-error.h:31
virtual void get_used_keys(string_list &used_keys) const
Get a list of the keys used during keyfile parsing.
Definition: loopback.cc:186
void set_filename(const std::string &filename)
Set the filename containing the chroot.
Definition: loopback.cc:122
virtual std::string const & get_name() const
Get the name of the chroot facet.
Definition: loopback.cc:98
Format names and values for output.
Definition: format-detail.h:38
A chroot stored in a file for loopback mounting.
Definition: loopback.h:39
Configuration file parser.
Definition: keyfile.h:46
std::string const & get_filename() const
Get the filename containing the chroot.
Definition: loopback.cc:116
virtual std::string get_path() const
Get the path to the chroot.
Definition: loopback.cc:131
virtual void get_details(format_detail &detail) const
Get detailed information about the chroot for output.
Definition: loopback.cc:179
std::shared_ptr< facet > ptr
A shared_ptr to a chroot facet object.
Definition: facet.h:63
void set_chroot(chroot &chroot, bool copy)
Set containing chroot.
Definition: loopback.cc:80
virtual void get_keyfile(keyfile &keyfile) const
Copy the chroot properties into a keyfile.
Definition: loopback.cc:192
virtual void setup_env(environment &env) const
Set environment.
Definition: loopback.cc:145
setup_type
Type of setup to perform.
Definition: chroot.h:54