sbuild  1.7.2
lvm-snapshot.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_LVM_SNAPSHOT_H
20 #define SBUILD_CHROOT_FACET_LVM_SNAPSHOT_H
21 
22 #include <sbuild/chroot/facet/block-device-base.h>
23 #include <sbuild/chroot/facet/session-setup.h>
24 #include <sbuild/chroot/facet/source-setup.h>
25 
26 namespace sbuild
27 {
28  namespace chroot
29  {
30  namespace facet
31  {
32 
39  public session_setup,
40  public source_setup
41  {
42  public:
44  typedef std::shared_ptr<lvm_snapshot> ptr;
45 
47  typedef std::shared_ptr<const lvm_snapshot> const_ptr;
48 
49  protected:
51  lvm_snapshot ();
52 
54  lvm_snapshot (const lvm_snapshot& rhs);
55 
56  void
58  bool copy);
59 
60  friend class chroot;
61 
62  public:
64  virtual ~lvm_snapshot ();
65 
66  virtual std::string const&
67  get_name () const;
68 
74  static ptr
75  create ();
76 
78  clone () const;
79 
86  std::string const&
87  get_snapshot_device () const;
88 
95  void
96  set_snapshot_device (const std::string& snapshot_device);
97 
104  std::string const&
105  get_snapshot_options () const;
106 
113  void
114  set_snapshot_options (const std::string& snapshot_options);
115 
116  virtual void
117  setup_env (environment& env) const;
118 
119  virtual session_flags
120  get_session_flags () const;
121 
122  protected:
123  virtual void
124  setup_lock (chroot::setup_type type,
125  bool lock,
126  int status);
127 
128  virtual void
129  get_details (format_detail& detail) const;
130 
131  virtual void
132  get_used_keys (string_list& used_keys) const;
133 
134  virtual void
135  get_keyfile (keyfile& keyfile) const;
136 
137  virtual void
138  set_keyfile (const keyfile& keyfile);
139 
140  virtual void
141  chroot_session_setup (const chroot& parent,
142  const std::string& session_id,
143  const std::string& alias,
144  const std::string& user,
145  bool root);
146 
147  virtual void
148  chroot_source_setup (const chroot& parent);
149 
150  private:
152  std::string snapshot_device;
154  std::string snapshot_options;
155  };
156 
157  }
158  }
159 }
160 
161 #endif /* SBUILD_CHROOT_FACET_LVM_SNAPSHOT_H */
162 
163 /*
164  * Local Variables:
165  * mode:C++
166  * End:
167  */
Debian source builder components.
Definition: ctty.cc:31
std::shared_ptr< lvm_snapshot > ptr
A shared_ptr to a chroot facet object.
Definition: lvm-snapshot.h:44
std::string const & get_snapshot_options() const
Get the logical volume snapshot options.
Definition: lvm-snapshot.cc:134
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: lvm-snapshot.cc:274
virtual void get_details(format_detail &detail) const
Get detailed information about the chroot for output.
Definition: lvm-snapshot.cc:214
virtual void chroot_source_setup(const chroot &parent)
Set up a newly-cloned source chroot.
Definition: lvm-snapshot.cc:290
std::string const & get_snapshot_device() const
Get the logical volume snapshot device name.
Definition: lvm-snapshot.cc:114
Container of environment variables.
Definition: environment.h:38
void set_chroot(chroot &chroot, bool copy)
Set containing chroot.
Definition: lvm-snapshot.cc:83
lvm_snapshot()
The constructor.
Definition: lvm-snapshot.cc:60
Common chroot data.
Definition: chroot.h:50
Advisory locking.
Definition: lock.h:38
void set_snapshot_options(const std::string &snapshot_options)
Set the logical volume snapshot options.
Definition: lvm-snapshot.cc:140
virtual void setup_env(environment &env) const
Set environment.
Definition: lvm-snapshot.cc:146
virtual void get_keyfile(keyfile &keyfile) const
Copy the chroot properties into a keyfile.
Definition: lvm-snapshot.cc:234
session_flags
Chroot session properties.
Definition: facet.h:54
void set_snapshot_device(const std::string &snapshot_device)
Set the logical volume snapshot device name.
Definition: lvm-snapshot.cc:120
virtual std::string const & get_name() const
Get the name of the chroot facet.
Definition: lvm-snapshot.cc:96
std::vector< std::string > string_list
A string vector.
Definition: types.h:38
Common chroot data.
Definition: session-setup.h:41
std::shared_ptr< const lvm_snapshot > const_ptr
A shared_ptr to a const chroot facet object.
Definition: lvm-snapshot.h:47
virtual void set_keyfile(const keyfile &keyfile)
Set the chroot properties from a keyfile.
Definition: lvm-snapshot.cc:254
Common chroot data.
Definition: source-setup.h:41
Format names and values for output.
Definition: format-detail.h:38
virtual ~lvm_snapshot()
The destructor.
Definition: lvm-snapshot.cc:78
facet::ptr clone() const
Copy the chroot facet.
Definition: lvm-snapshot.cc:108
Configuration file parser.
Definition: keyfile.h:46
A base class for block-device chroots.
Definition: block-device-base.h:43
std::string snapshot_device
LVM snapshot device name for lvcreate.
Definition: lvm-snapshot.h:152
std::shared_ptr< facet > ptr
A shared_ptr to a chroot facet object.
Definition: facet.h:63
A chroot stored on an LVM logical volume (LV).
Definition: lvm-snapshot.h:38
setup_type
Type of setup to perform.
Definition: chroot.h:54
std::string snapshot_options
LVM snapshot options for lvcreate.
Definition: lvm-snapshot.h:154
static ptr create()
Create a chroot facet.
Definition: lvm-snapshot.cc:102
virtual session_flags get_session_flags() const
Get the session flags of the chroot.
Definition: lvm-snapshot.cc:203
virtual void get_used_keys(string_list &used_keys) const
Get a list of the keys used during keyfile parsing.
Definition: lvm-snapshot.cc:225