1
/* Copyright © 2008-2009 Jan-Marek Glogowski <glogow@fbihome.de>
2
* Copyright © 2005-2009 Roger Leigh <rleigh@debian.org>
4
* schroot is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
9
* schroot is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see
16
* <http://www.gnu.org/licenses/>.
18
*********************************************************************/
20
#ifndef SBUILD_CHROOT_FACET_UNION_H
21
#define SBUILD_CHROOT_FACET_UNION_H
23
#include <sbuild/sbuild-chroot-facet.h>
29
* Chroot support for filesystem union based sessions.
31
* A chroot may offer session support using a filesystem union like
32
* aufs or unionfs. A new union type may need to adapt the 10mount
33
* or 05union script to properly populate the underlay and mount
34
* directory. The overlay directory and union setup is already
37
class chroot_facet_union : public chroot_facet
43
UNION_TYPE_UNKNOWN, ///< Unknown filesystem union type.
44
UNION_OVERLAY_ABS, ///< Union overlay must have an absolute path.
45
UNION_UNDERLAY_ABS ///< Union underlay must have an absolute path.
49
typedef custom_error<error_code> error;
51
/// A shared_ptr to a chroot facet object.
52
typedef std::tr1::shared_ptr<chroot_facet_union> ptr;
54
/// A shared_ptr to a const chroot facet object.
55
typedef std::tr1::shared_ptr<const chroot_facet_union> const_ptr;
59
chroot_facet_union ();
63
virtual ~chroot_facet_union ();
66
* Create a chroot facet.
68
* @returns a shared_ptr to the new chroot facet.
73
virtual chroot_facet::ptr
80
clone_source_setup (chroot::ptr& clone) const;
83
* Get fs union configured state.
85
* @returns if fs union is configured
88
get_union_configured () const;
91
* Get the filesystem union type.
94
* @returns the union filesytem type.
96
virtual std::string const&
97
get_union_type () const;
100
* Set the filesystem union type.
102
* Currently supported values are aufs, unionfs and none.
104
* @param union_type the filesystem type.
107
set_union_type (std::string const& union_type);
110
* Get the filesystem union mount options (branch configuration).
112
* @see set_union_mount_options
113
* @returns the filesystem union branch configuration.
115
virtual std::string const&
116
get_union_mount_options () const;
119
* Set the filesystem union mount options (branch configuration).
121
* Normally a temporary directory is used as the writeable branch,
122
* which is removed on session end. This allows the building of a
123
* complex union which can merge multiple branches. The string has
124
* to be constructed as expected by the filesystem union type and
125
* is directly used as the mount '-o' option string.
127
* @param union_mount_options a union filesystem-specific branch
131
set_union_mount_options (std::string const& union_mount_options);
134
* Get the union overlay directory.
136
* @returns the writeable overlay directory.
138
virtual std::string const&
139
get_union_overlay_directory () const;
142
* Set the union overlay directory.
144
* @returns the writeable overlay directory.
147
set_union_overlay_directory (std::string const& directory);
150
* Get the union underlay directory.
152
* @returns the writeable underlay directory.
154
virtual std::string const&
155
get_union_underlay_directory () const;
158
* Set the union underlay directory.
160
* @returns the writeable underlay directory.
163
set_union_underlay_directory (std::string const& directory);
166
setup_env (chroot const& chroot,
167
environment& env) const;
169
virtual chroot::session_flags
170
get_session_flags (chroot const& chroot) const;
173
get_details (chroot const& chroot,
174
format_detail& detail) const;
177
get_keyfile (chroot const& chroot,
178
keyfile& keyfile) const;
181
set_keyfile (chroot& chroot,
182
keyfile const& keyfile,
183
string_list& used_keys);
186
/// filesystem union type.
187
std::string union_type;
188
/// Union mount options (branch configuration).
189
std::string union_mount_options;
190
/// Union read-write overlay directory.
191
std::string union_overlay_directory;
192
/// Union read-only underlay directory.
193
std::string union_underlay_directory;
198
#endif /* SBUILD_CHROOT_FACET_UNION_H */