]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/storage/storage.h
storage: hide unnecessary symbols
[mirror_lxc.git] / src / lxc / storage / storage.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #ifndef __LXC_STORAGE_H
4 #define __LXC_STORAGE_H
5
6 #include <stdint.h>
7 #include <sys/mount.h>
8
9 #include <lxc/lxccontainer.h>
10
11 #if IS_BIONIC
12 #include <../include/lxcmntent.h>
13 #else
14 #include <mntent.h>
15 #endif
16
17 #include "compiler.h"
18
19 #ifndef MS_DIRSYNC
20 #define MS_DIRSYNC 128
21 #endif
22
23 #ifndef MS_REC
24 #define MS_REC 16384
25 #endif
26
27 #ifndef MNT_DETACH
28 #define MNT_DETACH 2
29 #endif
30
31 #ifndef MS_SLAVE
32 #define MS_SLAVE (1 << 19)
33 #endif
34
35 #ifndef MS_RELATIME
36 #define MS_RELATIME (1 << 21)
37 #endif
38
39 #ifndef MS_STRICTATIME
40 #define MS_STRICTATIME (1 << 24)
41 #endif
42
43 #define DEFAULT_FS_SIZE 1073741824
44 #define DEFAULT_FSTYPE "ext4"
45
46 #define LXC_STORAGE_INTERNAL_OVERLAY_RESTORE (1 << 6)
47
48 struct lxc_storage;
49
50 struct lxc_storage_ops {
51 /* detect whether path is of this bdev type */
52 bool (*detect)(const char *path);
53
54 /* mount requires src and dest to be set. */
55 int (*mount)(struct lxc_storage *bdev);
56 int (*umount)(struct lxc_storage *bdev);
57 int (*destroy)(struct lxc_storage *bdev);
58 int (*create)(struct lxc_storage *bdev, const char *dest, const char *n,
59 struct bdev_specs *specs, const struct lxc_conf *conf);
60 /* given original mount, rename the paths for cloned container */
61 int (*clone_paths)(struct lxc_storage *orig, struct lxc_storage *new,
62 const char *oldname, const char *cname,
63 const char *oldpath, const char *lxcpath, int snap,
64 uint64_t newsize, struct lxc_conf *conf);
65 bool (*copy)(struct lxc_conf *conf, struct lxc_storage *orig,
66 struct lxc_storage *new, uint64_t newsize);
67 bool (*snapshot)(struct lxc_conf *conf, struct lxc_storage *orig,
68 struct lxc_storage *new, uint64_t newsize);
69 bool can_snapshot;
70 bool can_backup;
71 };
72
73 /* When lxc is mounting a rootfs, then src will be the "lxc.rootfs.path" value,
74 * dest will be the mount dir (i.e. "<libdir>/lxc") When clone or create is
75 * doing so, then dest will be "<lxcpath>/<lxcname>/rootfs", since we may need
76 * to rsync from one to the other.
77 */
78 struct lxc_storage {
79 const struct lxc_storage_ops *ops;
80 const char *type;
81 char *src;
82 char *dest;
83 char *mntopts;
84 /* Turn the following into a union if need be. */
85 /* lofd is the open fd for the mounted loopback file. */
86 int lofd;
87 /* index for the connected nbd device. */
88 int nbd_idx;
89 int flags;
90 };
91
92 /**
93 * storage_is_dir : Check whether the roots is a directory. This function will
94 * trust the config file. If the config file key
95 * lxc.rootfs.path is set to <storage type>:<container path>
96 * the confile parser will have split this into <storage type>
97 * and <container path> and set the <bdev_type> member in the
98 * lxc_rootfs struct to <storage type> and the <path> member
99 * will be set to a clean <container path> without the <storage
100 * type> prefix. This is the new, clean way of handling storage
101 * type specifications. If the <storage type> prefix is not
102 * detected liblxc will try to detect the storage type.
103 */
104 __hidden extern bool storage_is_dir(struct lxc_conf *conf);
105 __hidden extern bool storage_can_backup(struct lxc_conf *conf);
106 __hidden extern struct lxc_storage *storage_init(struct lxc_conf *conf);
107 __hidden extern struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
108 const char *lxcpath, const char *bdevtype,
109 int flags, const char *bdevdata, uint64_t newsize,
110 bool *needs_rdep);
111 __hidden extern struct lxc_storage *storage_create(const char *dest, const char *type,
112 const char *cname, struct bdev_specs *specs,
113 const struct lxc_conf *conf);
114 __hidden extern void storage_put(struct lxc_storage *bdev);
115 __hidden extern bool storage_destroy(struct lxc_conf *conf);
116 __hidden extern bool rootfs_is_blockdev(struct lxc_conf *conf);
117 __hidden extern const char *lxc_storage_get_path(char *src, const char *prefix);
118
119 #endif /* #define __LXC_STORAGE_H */