]>
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, nbd (qcow2, raw, vdi, qed)
32 #include <lxc/lxccontainer.h>
37 /* detect whether path is of this bdev type */
38 int (*detect
)(const char *path
);
39 // mount requires src and dest to be set.
40 int (*mount
)(struct bdev
*bdev
);
41 int (*umount
)(struct bdev
*bdev
);
42 int (*destroy
)(struct bdev
*bdev
);
43 int (*create
)(struct bdev
*bdev
, const char *dest
, const char *n
,
44 struct bdev_specs
*specs
);
45 /* given original mount, rename the paths for cloned container */
46 int (*clone_paths
)(struct bdev
*orig
, struct bdev
*new, const char *oldname
,
47 const char *cname
, const char *oldpath
, const char *lxcpath
,
48 int snap
, uint64_t newsize
, struct lxc_conf
*conf
);
54 * When lxc-start (conf.c) is mounting a rootfs, then src will be the
55 * 'lxc.rootfs' value, dest will be mount dir (i.e. $libdir/lxc) When clone
56 * or create is doing so, then dest will be $lxcpath/$lxcname/rootfs, since
57 * we may need to rsync from one to the other.
58 * data is so far unused.
61 const struct bdev_ops
*ops
;
66 // turn the following into a union if need be
67 // lofd is the open fd for the mounted loopback file
69 // index for the connected nbd device
73 char *overlay_getlower(char *p
);
75 bool bdev_is_dir(struct lxc_conf
*conf
, const char *path
);
76 bool bdev_can_backup(struct lxc_conf
*conf
);
79 * Instantiate a bdev object. The src is used to determine which blockdev
80 * type this should be. The dst and data are optional, and will be used
81 * in case of mount/umount.
83 * Optionally, src can be 'dir:/var/lib/lxc/c1' or 'lvm:/dev/lxc/c1'. For
84 * other backing stores, this will allow additional options. In particular,
85 * "overlayfs:/var/lib/lxc/canonical/rootfs:/var/lib/lxc/c1/delta" will mean
86 * use /var/lib/lxc/canonical/rootfs as lower dir, and /var/lib/lxc/c1/delta
87 * as the upper, writeable layer.
89 struct bdev
*bdev_init(struct lxc_conf
*conf
, const char *src
, const char *dst
,
92 struct bdev
*bdev_copy(struct lxc_container
*c0
, const char *cname
,
93 const char *lxcpath
, const char *bdevtype
,
94 int flags
, const char *bdevdata
, uint64_t newsize
,
96 struct bdev
*bdev_create(const char *dest
, const char *type
,
97 const char *cname
, struct bdev_specs
*specs
);
98 void bdev_put(struct bdev
*bdev
);
101 * these are really for qemu-nbd support, as container shutdown
102 * must explicitly request device detach.
104 bool attach_block_device(struct lxc_conf
*conf
);
105 void detach_block_device(struct lxc_conf
*conf
);
107 bool rootfs_is_blockdev(struct lxc_conf
*conf
);
109 /* define constants if the kernel/glibc headers don't define them */
111 #define MS_DIRSYNC 128
123 #define MS_SLAVE (1<<19)
127 #define MS_RELATIME (1 << 21)
130 #ifndef MS_STRICTATIME
131 #define MS_STRICTATIME (1 << 24)