]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/storage/storage.h
2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #ifndef __LXC_STORAGE_H
25 #define __LXC_STORAGE_H
29 #include <sys/mount.h>
31 #include <lxc/lxccontainer.h>
34 #include <../include/lxcmntent.h>
40 #define MS_DIRSYNC 128
52 #define MS_SLAVE (1 << 19)
56 #define MS_RELATIME (1 << 21)
59 #ifndef MS_STRICTATIME
60 #define MS_STRICTATIME (1 << 24)
63 #define DEFAULT_FS_SIZE 1073741824
64 #define DEFAULT_FSTYPE "ext3"
66 #define LXC_STORAGE_INTERNAL_OVERLAY_RESTORE (1 << 6)
70 struct lxc_storage_ops
{
71 /* detect whether path is of this bdev type */
72 bool (*detect
)(const char *path
);
74 /* mount requires src and dest to be set. */
75 int (*mount
)(struct lxc_storage
*bdev
);
76 int (*umount
)(struct lxc_storage
*bdev
);
77 int (*destroy
)(struct lxc_storage
*bdev
);
78 int (*create
)(struct lxc_storage
*bdev
, const char *dest
, const char *n
,
79 struct bdev_specs
*specs
);
80 /* given original mount, rename the paths for cloned container */
81 int (*clone_paths
)(struct lxc_storage
*orig
, struct lxc_storage
*new,
82 const char *oldname
, const char *cname
,
83 const char *oldpath
, const char *lxcpath
, int snap
,
84 uint64_t newsize
, struct lxc_conf
*conf
);
85 bool (*copy
)(struct lxc_conf
*conf
, struct lxc_storage
*orig
,
86 struct lxc_storage
*new, uint64_t newsize
);
87 bool (*snapshot
)(struct lxc_conf
*conf
, struct lxc_storage
*orig
,
88 struct lxc_storage
*new, uint64_t newsize
);
93 /* When lxc is mounting a rootfs, then src will be the "lxc.rootfs.path" value,
94 * dest will be the mount dir (i.e. "<libdir>/lxc") When clone or create is
95 * doing so, then dest will be "<lxcpath>/<lxcname>/rootfs", since we may need
96 * to rsync from one to the other.
99 const struct lxc_storage_ops
*ops
;
104 /* Turn the following into a union if need be. */
105 /* lofd is the open fd for the mounted loopback file. */
107 /* index for the connected nbd device. */
112 extern bool storage_is_dir(struct lxc_conf
*conf
, const char *path
);
113 extern bool storage_can_backup(struct lxc_conf
*conf
);
115 /* Instantiate a lxc_storage object. The src is used to determine which blockdev
116 * type this should be. The dst and data are optional, and will be used in case
119 * The source will be "dir:/var/lib/lxc/c1" or "lvm:/dev/lxc/c1". For other
120 * backing stores, this will allow additional options. In particular,
121 * "overlayfs:/var/lib/lxc/canonical/rootfs:/var/lib/lxc/c1/delta" will mean use
122 * /var/lib/lxc/canonical/rootfs as lower dir, and /var/lib/lxc/c1/delta as the
123 * upper, writeable layer.
125 extern struct lxc_storage
*storage_init(struct lxc_conf
*conf
, const char *src
,
126 const char *dst
, const char *data
);
128 extern struct lxc_storage
*storage_copy(struct lxc_container
*c0
,
129 const char *cname
, const char *lxcpath
,
130 const char *bdevtype
, int flags
,
131 const char *bdevdata
, uint64_t newsize
,
133 extern struct lxc_storage
*storage_create(const char *dest
, const char *type
,
135 struct bdev_specs
*specs
);
136 extern void storage_put(struct lxc_storage
*bdev
);
137 extern bool storage_destroy(struct lxc_conf
*conf
);
139 extern int storage_destroy_wrapper(void *data
);
140 extern bool rootfs_is_blockdev(struct lxc_conf
*conf
);
141 extern char *lxc_storage_get_path(char *src
, const char *prefix
);
143 #endif /* #define __LXC_STORAGE_H */