]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/bdev.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
26 /* blockdev operations for:
27 * aufs, dir, raw, btrfs, overlayfs, aufs, lvm, loop, zfs
28 * someday: qemu-nbd, qcow2, qed
33 #include <lxc/lxccontainer.h>
38 * specifications for how to create a new backing store
42 uint64_t fssize
; // fs size in bytes
49 char *thinpool
; // lvm thin pool to use, if any
54 /* detect whether path is of this bdev type */
55 int (*detect
)(const char *path
);
56 // mount requires src and dest to be set.
57 int (*mount
)(struct bdev
*bdev
);
58 int (*umount
)(struct bdev
*bdev
);
59 int (*destroy
)(struct bdev
*bdev
);
60 int (*create
)(struct bdev
*bdev
, const char *dest
, const char *n
,
61 struct bdev_specs
*specs
);
62 /* given original mount, rename the paths for cloned container */
63 int (*clone_paths
)(struct bdev
*orig
, struct bdev
*new, const char *oldname
,
64 const char *cname
, const char *oldpath
, const char *lxcpath
,
65 int snap
, uint64_t newsize
);
70 * When lxc-start (conf.c) is mounting a rootfs, then src will be the
71 * 'lxc.rootfs' value, dest will be mount dir (i.e. $libdir/lxc) When clone
72 * or create is doing so, then dest will be $lxcpath/$lxcname/rootfs, since
73 * we may need to rsync from one to the other.
74 * data is so far unused.
77 const struct bdev_ops
*ops
;
82 // turn the following into a union if need be
83 // lofd is the open fd for the mounted loopback file
87 char *overlay_getlower(char *p
);
89 bool bdev_is_dir(const char *path
);
92 * Instantiate a bdev object. The src is used to determine which blockdev
93 * type this should be. The dst and data are optional, and will be used
94 * in case of mount/umount.
96 * Optionally, src can be 'dir:/var/lib/lxc/c1' or 'lvm:/dev/lxc/c1'. For
97 * other backing stores, this will allow additional options. In particular,
98 * "overlayfs:/var/lib/lxc/canonical/rootfs:/var/lib/lxc/c1/delta" will mean
99 * use /var/lib/lxc/canonical/rootfs as lower dir, and /var/lib/lxc/c1/delta
100 * as the upper, writeable layer.
102 struct bdev
*bdev_init(const char *src
, const char *dst
, const char *data
);
104 struct bdev
*bdev_copy(struct lxc_container
*c0
, const char *cname
,
105 const char *lxcpath
, const char *bdevtype
,
106 int flags
, const char *bdevdata
, uint64_t newsize
,
108 struct bdev
*bdev_create(const char *dest
, const char *type
,
109 const char *cname
, struct bdev_specs
*specs
);
110 void bdev_put(struct bdev
*bdev
);
112 /* define constants if the kernel/glibc headers don't define them */
114 #define MS_DIRSYNC 128
126 #define MS_SLAVE (1<<19)
130 #define MS_RELATIME (1 << 21)
133 #ifndef MS_STRICTATIME
134 #define MS_STRICTATIME (1 << 24)