sbuild  1.7.1
btrfs-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_BTRFS_SNAPSHOT_H
20 #define SBUILD_CHROOT_FACET_BTRFS_SNAPSHOT_H
21 
22 #include <sbuild/chroot/chroot.h>
23 #include <sbuild/chroot/facet/facet.h>
24 #include <sbuild/chroot/facet/storage.h>
25 #include <sbuild/chroot/facet/session-setup.h>
26 #include <sbuild/chroot/facet/source-setup.h>
27 
28 namespace sbuild
29 {
30  namespace chroot
31  {
32  namespace facet
33  {
34 
40  class btrfs_snapshot : public facet,
41  public storage,
42  public session_setup,
43  public source_setup
44  {
45  public:
48 
50  typedef std::shared_ptr<btrfs_snapshot> ptr;
51 
53  typedef std::shared_ptr<const btrfs_snapshot> const_ptr;
54 
55  protected:
57  btrfs_snapshot ();
58 
60  btrfs_snapshot (const btrfs_snapshot& rhs);
61 
62  void
64  bool copy);
65 
66  friend class chroot;
67 
68  public:
70  virtual ~btrfs_snapshot ();
71 
72  virtual std::string const&
73  get_name () const;
74 
80  static ptr
81  create ();
82 
84  clone () const;
85 
92  std::string const&
93  get_source_subvolume () const;
94 
101  void
102  set_source_subvolume (const std::string& source_subvolume);
103 
109  std::string const&
110  get_snapshot_directory () const;
111 
117  void
118  set_snapshot_directory (const std::string& snapshot_directory);
119 
126  std::string const&
127  get_snapshot_name () const;
128 
135  void
136  set_snapshot_name (const std::string& snapshot_name);
137 
138  virtual std::string
139  get_path () const;
140 
141  virtual void
142  setup_env (environment& env) const;
143 
144  virtual session_flags
145  get_session_flags () const;
146 
147  protected:
148  virtual void
149  setup_lock (chroot::setup_type type,
150  bool lock,
151  int status);
152 
153  virtual void
154  get_details (format_detail& detail) const;
155 
156  virtual void
157  get_used_keys (string_list& used_keys) const;
158 
159  virtual void
160  get_keyfile (keyfile& keyfile) const;
161 
162  virtual void
163  set_keyfile (const keyfile& keyfile);
164 
165  virtual void
166  chroot_session_setup (const chroot& parent,
167  const std::string& session_id,
168  const std::string& alias,
169  const std::string& user,
170  bool root);
171 
172  virtual void
173  chroot_source_setup (const chroot& parent);
174 
175  private:
177  std::string source_subvolume;
179  std::string snapshot_directory;
181  std::string snapshot_name;
182  };
183 
184  }
185  }
186 }
187 
188 #endif /* SBUILD_CHROOT_FACET_BTRFS_SNAPSHOT_H */
189 
190 /*
191  * Local Variables:
192  * mode:C++
193  * End:
194  */