]>
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
28 #include <sys/mount.h>
30 #include <lxc/lxccontainer.h>
33 #include <../include/lxcmntent.h>
39 #define MS_DIRSYNC 128
51 #define MS_SLAVE (1 << 19)
55 #define MS_RELATIME (1 << 21)
58 #ifndef MS_STRICTATIME
59 #define MS_STRICTATIME (1 << 24)
62 #define DEFAULT_FS_SIZE 1073741824
63 #define DEFAULT_FSTYPE "ext4"
65 #define LXC_STORAGE_INTERNAL_OVERLAY_RESTORE (1 << 6)
69 struct lxc_storage_ops
{
70 /* detect whether path is of this bdev type */
71 bool (*detect
)(const char *path
);
73 /* mount requires src and dest to be set. */
74 int (*mount
)(struct lxc_storage
*bdev
);
75 int (*umount
)(struct lxc_storage
*bdev
);
76 int (*destroy
)(struct lxc_storage
*bdev
);
77 int (*create
)(struct lxc_storage
*bdev
, const char *dest
, const char *n
,
78 struct bdev_specs
*specs
);
79 /* given original mount, rename the paths for cloned container */
80 int (*clone_paths
)(struct lxc_storage
*orig
, struct lxc_storage
*new,
81 const char *oldname
, const char *cname
,
82 const char *oldpath
, const char *lxcpath
, int snap
,
83 uint64_t newsize
, struct lxc_conf
*conf
);
84 bool (*copy
)(struct lxc_conf
*conf
, struct lxc_storage
*orig
,
85 struct lxc_storage
*new, uint64_t newsize
);
86 bool (*snapshot
)(struct lxc_conf
*conf
, struct lxc_storage
*orig
,
87 struct lxc_storage
*new, uint64_t newsize
);
92 /* When lxc is mounting a rootfs, then src will be the "lxc.rootfs.path" value,
93 * dest will be the mount dir (i.e. "<libdir>/lxc") When clone or create is
94 * doing so, then dest will be "<lxcpath>/<lxcname>/rootfs", since we may need
95 * to rsync from one to the other.
98 const struct lxc_storage_ops
*ops
;
103 /* Turn the following into a union if need be. */
104 /* lofd is the open fd for the mounted loopback file. */
106 /* index for the connected nbd device. */
112 * storage_is_dir : Check whether the roots is a directory. This function will
113 * trust the config file. If the config file key
114 * lxc.rootfs.path is set to <storage type>:<container path>
115 * the confile parser will have split this into <storage type>
116 * and <container path> and set the <bdev_type> member in the
117 * lxc_rootfs struct to <storage type> and the <path> member
118 * will be set to a clean <container path> without the <storage
119 * type> prefix. This is the new, clean way of handling storage
120 * type specifications. If the <storage type> prefix is not
121 * detected liblxc will try to detect the storage type.
123 extern bool storage_is_dir(struct lxc_conf
*conf
);
124 extern bool storage_can_backup(struct lxc_conf
*conf
);
126 extern struct lxc_storage
*storage_init(struct lxc_conf
*conf
);
128 extern struct lxc_storage
*storage_copy(struct lxc_container
*c
,
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
);
138 extern bool rootfs_is_blockdev(struct lxc_conf
*conf
);
139 extern const char *lxc_storage_get_path(char *src
, const char *prefix
);
141 #endif /* #define __LXC_STORAGE_H */