sbuild  1.7.2
block-device.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_BLOCK_DEVICE_H
20 #define SBUILD_CHROOT_FACET_BLOCK_DEVICE_H
21 
22 #include <sbuild/config.h>
23 #include <sbuild/chroot/facet/block-device-base.h>
24 #include <sbuild/chroot/facet/lvm-snapshot.h>
25 #include <sbuild/chroot/facet/mountable.h>
26 #include <sbuild/chroot/facet/session-setup.h>
27 
28 namespace sbuild
29 {
30  namespace chroot
31  {
32  namespace facet
33  {
34 
41  public session_setup
42  {
43  public:
45  typedef std::shared_ptr<block_device> ptr;
46 
48  typedef std::shared_ptr<const block_device> const_ptr;
49 
50  protected:
52  block_device ();
53 
55  block_device (const block_device& rhs);
56 
57 #ifdef SBUILD_FEATURE_LVMSNAP
58  block_device (const lvm_snapshot& rhs);
60 #endif
61 
62  void
64  bool copy);
65 
66  friend class chroot;
67 #ifdef SBUILD_FEATURE_LVMSNAP
68  friend class lvm_snapshot;
69 #endif
70 
71  public:
73  virtual ~block_device ();
74 
75  virtual std::string const&
76  get_name () const;
77 
83  static ptr
84  create ();
85 
92 #ifdef SBUILD_FEATURE_LVMSNAP
93  static ptr
94  create (const lvm_snapshot& rhs);
95 #endif // SBUILD_FEATURE_LVMSNAP
96 
97  virtual facet::ptr
98  clone () const;
99 
100  virtual void
101  chroot_session_setup (const chroot& parent,
102  const std::string& session_id,
103  const std::string& alias,
104  const std::string& user,
105  bool root);
106 
107  protected:
108  virtual void
109  setup_lock (chroot::setup_type type,
110  bool lock,
111  int status);
112  };
113 
114  }
115  }
116 }
117 
118 #endif /* SBUILD_CHROOT_FACET_BLOCK_DEVICE_H */
119 
120 /*
121  * Local Variables:
122  * mode:C++
123  * End:
124  */
void set_chroot(chroot &chroot, bool copy)
Set containing chroot.
Definition: block-device.cc:85
Debian source builder components.
Definition: ctty.cc:31
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: block-device.cc:176
Common chroot data.
Definition: chroot.h:50
std::shared_ptr< block_device > ptr
A shared_ptr to a chroot facet object.
Definition: block-device.h:45
Advisory locking.
Definition: lock.h:38
block_device()
The constructor.
Definition: block-device.cc:63
Common chroot data.
Definition: session-setup.h:41
virtual ~block_device()
The destructor.
Definition: block-device.cc:68
static ptr create()
Create a chroot facet.
Definition: block-device.cc:106
virtual std::string const & get_name() const
Get the name of the chroot facet.
Definition: block-device.cc:100
A chroot stored on an unmounted block device.
Definition: block-device.h:40
A base class for block-device chroots.
Definition: block-device-base.h:43
virtual facet::ptr clone() const
Copy the chroot facet.
Definition: block-device.cc:120
std::shared_ptr< facet > ptr
A shared_ptr to a chroot facet object.
Definition: facet.h:63
std::shared_ptr< const block_device > const_ptr
A shared_ptr to a const chroot facet object.
Definition: block-device.h:48
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