mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 01:34:56 +00:00
storage: constify where possible
This was made necessary by changes to the overlay driver. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
parent
ec5d663c3e
commit
41dc71558e
@ -2735,7 +2735,7 @@ int chown_mapped_root_exec_wrapper(void *args)
|
|||||||
* root is privileged with respect to hostuid/hostgid X, allowing
|
* root is privileged with respect to hostuid/hostgid X, allowing
|
||||||
* him to do the chown.
|
* him to do the chown.
|
||||||
*/
|
*/
|
||||||
int chown_mapped_root(char *path, struct lxc_conf *conf)
|
int chown_mapped_root(const char *path, struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
uid_t rootuid, rootgid;
|
uid_t rootuid, rootgid;
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
@ -2743,14 +2743,14 @@ int chown_mapped_root(char *path, struct lxc_conf *conf)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
char map1[100], map2[100], map3[100], map4[100], map5[100];
|
char map1[100], map2[100], map3[100], map4[100], map5[100];
|
||||||
char ugid[100];
|
char ugid[100];
|
||||||
char *args1[] = {"lxc-usernsexec",
|
const char *args1[] = {"lxc-usernsexec",
|
||||||
"-m", map1,
|
"-m", map1,
|
||||||
"-m", map2,
|
"-m", map2,
|
||||||
"-m", map3,
|
"-m", map3,
|
||||||
"-m", map5,
|
"-m", map5,
|
||||||
"--", "chown", ugid, path,
|
"--", "chown", ugid, path,
|
||||||
NULL};
|
NULL};
|
||||||
char *args2[] = {"lxc-usernsexec",
|
const char *args2[] = {"lxc-usernsexec",
|
||||||
"-m", map1,
|
"-m", map1,
|
||||||
"-m", map2,
|
"-m", map2,
|
||||||
"-m", map3,
|
"-m", map3,
|
||||||
|
@ -396,7 +396,7 @@ extern int setup_resource_limits(struct lxc_list *limits, pid_t pid);
|
|||||||
extern int find_unmapped_nsid(struct lxc_conf *conf, enum idtype idtype);
|
extern int find_unmapped_nsid(struct lxc_conf *conf, enum idtype idtype);
|
||||||
extern int mapped_hostid(unsigned id, struct lxc_conf *conf,
|
extern int mapped_hostid(unsigned id, struct lxc_conf *conf,
|
||||||
enum idtype idtype);
|
enum idtype idtype);
|
||||||
extern int chown_mapped_root(char *path, struct lxc_conf *conf);
|
extern int chown_mapped_root(const char *path, struct lxc_conf *conf);
|
||||||
extern int lxc_ttys_shift_ids(struct lxc_conf *c);
|
extern int lxc_ttys_shift_ids(struct lxc_conf *c);
|
||||||
extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
|
extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
|
||||||
const char *fn_name);
|
const char *fn_name);
|
||||||
|
@ -1315,7 +1315,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool need_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* TODO come up with a better way here! */
|
} else { /* TODO come up with a better way here! */
|
||||||
char *src;
|
const char *src;
|
||||||
free(bdev->dest);
|
free(bdev->dest);
|
||||||
src = lxc_storage_get_path(bdev->src, bdev->type);
|
src = lxc_storage_get_path(bdev->src, bdev->type);
|
||||||
bdev->dest = strdup(src);
|
bdev->dest = strdup(src);
|
||||||
|
@ -187,7 +187,8 @@ bool btrfs_detect(const char *path)
|
|||||||
int btrfs_mount(struct lxc_storage *bdev)
|
int btrfs_mount(struct lxc_storage *bdev)
|
||||||
{
|
{
|
||||||
unsigned long mntflags;
|
unsigned long mntflags;
|
||||||
char *mntdata, *src;
|
char *mntdata;
|
||||||
|
const char *src;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (strcmp(bdev->type, "btrfs"))
|
if (strcmp(bdev->type, "btrfs"))
|
||||||
@ -348,7 +349,7 @@ out:
|
|||||||
|
|
||||||
int btrfs_snapshot_wrapper(void *data)
|
int btrfs_snapshot_wrapper(void *data)
|
||||||
{
|
{
|
||||||
char *src;
|
const char *src;
|
||||||
struct rsync_data_char *arg = data;
|
struct rsync_data_char *arg = data;
|
||||||
|
|
||||||
if (setgid(0) < 0) {
|
if (setgid(0) < 0) {
|
||||||
@ -372,7 +373,7 @@ int btrfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
|
|||||||
const char *oldpath, const char *lxcpath, int snap,
|
const char *oldpath, const char *lxcpath, int snap,
|
||||||
uint64_t newsize, struct lxc_conf *conf)
|
uint64_t newsize, struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
if (!orig->dest || !orig->src)
|
if (!orig->dest || !orig->src)
|
||||||
return -1;
|
return -1;
|
||||||
@ -821,7 +822,7 @@ bool btrfs_try_remove_subvol(const char *path)
|
|||||||
|
|
||||||
int btrfs_destroy(struct lxc_storage *orig)
|
int btrfs_destroy(struct lxc_storage *orig)
|
||||||
{
|
{
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
src = lxc_storage_get_path(orig->src, "btrfs");
|
src = lxc_storage_get_path(orig->src, "btrfs");
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ int dir_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
|
|||||||
const char *lxcpath, int snap, uint64_t newsize,
|
const char *lxcpath, int snap, uint64_t newsize,
|
||||||
struct lxc_conf *conf)
|
struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
char *src_no_prefix;
|
const char *src_no_prefix;
|
||||||
int ret;
|
int ret;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ int dir_create(struct lxc_storage *bdev, const char *dest, const char *n,
|
|||||||
int dir_destroy(struct lxc_storage *orig)
|
int dir_destroy(struct lxc_storage *orig)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
src = lxc_storage_get_path(orig->src, orig->src);
|
src = lxc_storage_get_path(orig->src, orig->src);
|
||||||
|
|
||||||
@ -149,7 +149,8 @@ int dir_mount(struct lxc_storage *bdev)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned long mflags, mntflags;
|
unsigned long mflags, mntflags;
|
||||||
char *src, *mntdata;
|
char *mntdata;
|
||||||
|
const char *src;
|
||||||
|
|
||||||
if (strcmp(bdev->type, "dir"))
|
if (strcmp(bdev->type, "dir"))
|
||||||
return -22;
|
return -22;
|
||||||
|
@ -235,7 +235,7 @@ int loop_mount(struct lxc_storage *bdev)
|
|||||||
{
|
{
|
||||||
int ret, loopfd;
|
int ret, loopfd;
|
||||||
char loname[MAXPATHLEN];
|
char loname[MAXPATHLEN];
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
if (strcmp(bdev->type, "loop"))
|
if (strcmp(bdev->type, "loop"))
|
||||||
return -22;
|
return -22;
|
||||||
|
@ -235,7 +235,7 @@ bool lvm_detect(const char *path)
|
|||||||
|
|
||||||
int lvm_mount(struct lxc_storage *bdev)
|
int lvm_mount(struct lxc_storage *bdev)
|
||||||
{
|
{
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
if (strcmp(bdev->type, "lvm"))
|
if (strcmp(bdev->type, "lvm"))
|
||||||
return -22;
|
return -22;
|
||||||
@ -330,11 +330,12 @@ static int lvm_snapshot_create_new_uuid_wrapper(void *data)
|
|||||||
static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t size)
|
static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t size)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *origsrc, *pathdup, *lv;
|
char *lv, *pathdup;
|
||||||
char sz[24];
|
char sz[24];
|
||||||
char fstype[100];
|
char fstype[100];
|
||||||
char cmd_output[MAXPATHLEN];
|
char cmd_output[MAXPATHLEN];
|
||||||
char repairchar;
|
char repairchar;
|
||||||
|
const char *origsrc;
|
||||||
struct lvcreate_args cmd_args = {0};
|
struct lvcreate_args cmd_args = {0};
|
||||||
|
|
||||||
ret = snprintf(sz, 24, "%" PRIu64 "b", size);
|
ret = snprintf(sz, 24, "%" PRIu64 "b", size);
|
||||||
@ -433,7 +434,8 @@ int lvm_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
|
|||||||
(const char *[]){"lvm:", "dev", vg, cname, NULL},
|
(const char *[]){"lvm:", "dev", vg, cname, NULL},
|
||||||
false);
|
false);
|
||||||
} else {
|
} else {
|
||||||
char *dup, *slider, *src;
|
const char *src;
|
||||||
|
char *dup, *slider;
|
||||||
|
|
||||||
src = lxc_storage_get_path(orig->src, orig->type);
|
src = lxc_storage_get_path(orig->src, orig->type);
|
||||||
|
|
||||||
@ -497,11 +499,11 @@ int lvm_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
|
|||||||
bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
|
bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
|
||||||
struct lxc_storage *new, uint64_t newsize)
|
struct lxc_storage *new, uint64_t newsize)
|
||||||
{
|
{
|
||||||
char *src;
|
|
||||||
const char *thinpool;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
const char *src;
|
||||||
|
const char *thinpool;
|
||||||
struct rsync_data data;
|
struct rsync_data data;
|
||||||
char *cmd_args[2];
|
const char *cmd_args[2];
|
||||||
char cmd_output[MAXPATHLEN] = {0};
|
char cmd_output[MAXPATHLEN] = {0};
|
||||||
char fstype[100] = "ext4";
|
char fstype[100] = "ext4";
|
||||||
uint64_t size = newsize;
|
uint64_t size = newsize;
|
||||||
@ -560,7 +562,7 @@ bool lvm_create_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
|
|||||||
struct lxc_storage *new, uint64_t newsize)
|
struct lxc_storage *new, uint64_t newsize)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *newsrc;
|
const char *newsrc;
|
||||||
uint64_t size = newsize;
|
uint64_t size = newsize;
|
||||||
|
|
||||||
if (is_blktype(orig)) {
|
if (is_blktype(orig)) {
|
||||||
|
@ -118,7 +118,7 @@ bool nbd_detect(const char *path)
|
|||||||
int nbd_mount(struct lxc_storage *bdev)
|
int nbd_mount(struct lxc_storage *bdev)
|
||||||
{
|
{
|
||||||
int ret = -1, partition;
|
int ret = -1, partition;
|
||||||
char *src;
|
const char *src;
|
||||||
char path[50];
|
char path[50];
|
||||||
|
|
||||||
if (strcmp(bdev->type, "nbd"))
|
if (strcmp(bdev->type, "nbd"))
|
||||||
|
@ -54,7 +54,7 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
|
|||||||
int snap, uint64_t newsize, struct lxc_conf *conf)
|
int snap, uint64_t newsize, struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
if (!snap) {
|
if (!snap) {
|
||||||
ERROR("The overlay storage driver can only be used for "
|
ERROR("The overlay storage driver can only be used for "
|
||||||
@ -683,14 +683,14 @@ int ovl_umount(struct lxc_storage *bdev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ovl_get_lower(const char *rootfs_path)
|
const char *ovl_get_lower(const char *rootfs_path)
|
||||||
{
|
{
|
||||||
char *s1;
|
const char *s1 = rootfs_path;
|
||||||
|
|
||||||
s1 = strstr(rootfs_path, ":/");
|
if (strncmp(rootfs_path, "overlay:", 8) == 0)
|
||||||
if (!s1)
|
s1 += 8;
|
||||||
return NULL;
|
else if (strncmp(rootfs_path, "overlayfs:", 10) == 0)
|
||||||
s1++;
|
s1 += 10;
|
||||||
|
|
||||||
s1 = strstr(s1, ":/");
|
s1 = strstr(s1, ":/");
|
||||||
if (!s1)
|
if (!s1)
|
||||||
@ -714,16 +714,20 @@ char *ovl_get_rootfs(const char *rootfs_path, size_t *rootfslen)
|
|||||||
if (!s1)
|
if (!s1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
s2 = strstr(s1, ":/");
|
s2 = s1;
|
||||||
if (s2) {
|
if (strncmp(rootfs_path, "overlay:", 8) == 0)
|
||||||
s2 = s2 + 1;
|
s2 += 8;
|
||||||
if ((s3 = strstr(s2, ":/")))
|
else if (strncmp(rootfs_path, "overlayfs:", 10) == 0)
|
||||||
*s3 = '\0';
|
s2 += 10;
|
||||||
rootfsdir = strdup(s2);
|
|
||||||
if (!rootfsdir) {
|
s3 = strstr(s2, ":/");
|
||||||
free(s1);
|
if (s3)
|
||||||
return NULL;
|
*s3 = '\0';
|
||||||
}
|
|
||||||
|
rootfsdir = strdup(s2);
|
||||||
|
if (!rootfsdir) {
|
||||||
|
free(s1);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rootfsdir)
|
if (!rootfsdir)
|
||||||
|
@ -66,7 +66,7 @@ extern int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
|
|||||||
/* To be called from functions in lxccontainer.c: Get lower directory for
|
/* To be called from functions in lxccontainer.c: Get lower directory for
|
||||||
* overlay rootfs.
|
* overlay rootfs.
|
||||||
*/
|
*/
|
||||||
extern char *ovl_get_lower(const char *rootfs_path);
|
extern const char *ovl_get_lower(const char *rootfs_path);
|
||||||
|
|
||||||
/* Get rootfs path for overlay backed containers. Allocated memory must be freed
|
/* Get rootfs path for overlay backed containers. Allocated memory must be freed
|
||||||
* by caller.
|
* by caller.
|
||||||
|
@ -189,7 +189,7 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n,
|
|||||||
int rbd_destroy(struct lxc_storage *orig)
|
int rbd_destroy(struct lxc_storage *orig)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *src;
|
const char *src;
|
||||||
char *rbdfullname;
|
char *rbdfullname;
|
||||||
char cmd_output[MAXPATHLEN];
|
char cmd_output[MAXPATHLEN];
|
||||||
struct rbd_args args = {0};
|
struct rbd_args args = {0};
|
||||||
@ -233,7 +233,7 @@ bool rbd_detect(const char *path)
|
|||||||
|
|
||||||
int rbd_mount(struct lxc_storage *bdev)
|
int rbd_mount(struct lxc_storage *bdev)
|
||||||
{
|
{
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
if (strcmp(bdev->type, "rbd"))
|
if (strcmp(bdev->type, "rbd"))
|
||||||
return -22;
|
return -22;
|
||||||
|
@ -86,7 +86,7 @@ int lxc_rsync_exec(const char *src, const char *dest)
|
|||||||
int lxc_rsync(struct rsync_data *data)
|
int lxc_rsync(struct rsync_data *data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *dest, *src;
|
const char *dest, *src;
|
||||||
struct lxc_storage *orig = data->orig, *new = data->new;
|
struct lxc_storage *orig = data->orig, *new = data->new;
|
||||||
|
|
||||||
ret = unshare(CLONE_NEWNS);
|
ret = unshare(CLONE_NEWNS);
|
||||||
|
@ -338,7 +338,7 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
|
|||||||
uint64_t newsize, bool *needs_rdep)
|
uint64_t newsize, bool *needs_rdep)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *src_no_prefix;
|
const char *src_no_prefix;
|
||||||
struct lxc_storage *new, *orig;
|
struct lxc_storage *new, *orig;
|
||||||
bool snap = (flags & LXC_CLONE_SNAPSHOT);
|
bool snap = (flags & LXC_CLONE_SNAPSHOT);
|
||||||
bool maybe_snap = (flags & LXC_CLONE_MAYBE_SNAPSHOT);
|
bool maybe_snap = (flags & LXC_CLONE_MAYBE_SNAPSHOT);
|
||||||
@ -718,7 +718,7 @@ bool rootfs_is_blockdev(struct lxc_conf *conf)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *lxc_storage_get_path(char *src, const char *prefix)
|
const char *lxc_storage_get_path(char *src, const char *prefix)
|
||||||
{
|
{
|
||||||
size_t prefix_len;
|
size_t prefix_len;
|
||||||
|
|
||||||
|
@ -137,6 +137,6 @@ extern struct lxc_storage *storage_create(const char *dest, const char *type,
|
|||||||
extern void storage_put(struct lxc_storage *bdev);
|
extern void storage_put(struct lxc_storage *bdev);
|
||||||
extern bool storage_destroy(struct lxc_conf *conf);
|
extern bool storage_destroy(struct lxc_conf *conf);
|
||||||
extern bool rootfs_is_blockdev(struct lxc_conf *conf);
|
extern bool rootfs_is_blockdev(struct lxc_conf *conf);
|
||||||
extern char *lxc_storage_get_path(char *src, const char *prefix);
|
extern const char *lxc_storage_get_path(char *src, const char *prefix);
|
||||||
|
|
||||||
#endif /* #define __LXC_STORAGE_H */
|
#endif /* #define __LXC_STORAGE_H */
|
||||||
|
@ -133,7 +133,7 @@ bool attach_block_device(struct lxc_conf *conf)
|
|||||||
int blk_getsize(struct lxc_storage *bdev, uint64_t *size)
|
int blk_getsize(struct lxc_storage *bdev, uint64_t *size)
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
char *src;
|
const char *src;
|
||||||
|
|
||||||
src = lxc_storage_get_path(bdev->src, bdev->type);
|
src = lxc_storage_get_path(bdev->src, bdev->type);
|
||||||
fd = open(src, O_RDONLY);
|
fd = open(src, O_RDONLY);
|
||||||
@ -162,11 +162,15 @@ void detach_block_device(struct lxc_conf *conf)
|
|||||||
*/
|
*/
|
||||||
int detect_fs(struct lxc_storage *bdev, char *type, int len)
|
int detect_fs(struct lxc_storage *bdev, char *type, int len)
|
||||||
{
|
{
|
||||||
int p[2], ret;
|
int ret;
|
||||||
|
int p[2];
|
||||||
size_t linelen;
|
size_t linelen;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *sp1, *sp2, *sp3, *srcdev, *line = NULL;
|
char *sp1, *sp2, *sp3;
|
||||||
|
const char *l, *srcdev;
|
||||||
|
char devpath[MAXPATHLEN];
|
||||||
|
char *line = NULL;
|
||||||
|
|
||||||
if (!bdev || !bdev->src || !bdev->dest)
|
if (!bdev || !bdev->src || !bdev->dest)
|
||||||
return -1;
|
return -1;
|
||||||
@ -218,9 +222,7 @@ int detect_fs(struct lxc_storage *bdev, char *type, int len)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if symlink, get the real dev name */
|
l = linkderef(srcdev, devpath);
|
||||||
char devpath[MAXPATHLEN];
|
|
||||||
char *l = linkderef(srcdev, devpath);
|
|
||||||
if (!l)
|
if (!l)
|
||||||
exit(1);
|
exit(1);
|
||||||
f = fopen("/proc/self/mounts", "r");
|
f = fopen("/proc/self/mounts", "r");
|
||||||
@ -383,7 +385,7 @@ int find_fstype_cb(char *buffer, void *data)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *linkderef(char *path, char *dest)
|
const char *linkderef(const char *path, char *dest)
|
||||||
{
|
{
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
@ -45,7 +45,7 @@ extern int is_blktype(struct lxc_storage *b);
|
|||||||
extern int mount_unknown_fs(const char *rootfs, const char *target,
|
extern int mount_unknown_fs(const char *rootfs, const char *target,
|
||||||
const char *options);
|
const char *options);
|
||||||
extern int find_fstype_cb(char *buffer, void *data);
|
extern int find_fstype_cb(char *buffer, void *data);
|
||||||
extern char *linkderef(char *path, char *dest);
|
extern const char *linkderef(const char *path, char *dest);
|
||||||
extern bool unpriv_snap_allowed(struct lxc_storage *b, const char *t, bool snap,
|
extern bool unpriv_snap_allowed(struct lxc_storage *b, const char *t, bool snap,
|
||||||
bool maybesnap);
|
bool maybesnap);
|
||||||
extern bool is_valid_storage_type(const char *type);
|
extern bool is_valid_storage_type(const char *type);
|
||||||
|
@ -180,7 +180,8 @@ int zfs_mount(struct lxc_storage *bdev)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
size_t oldlen, newlen, totallen;
|
size_t oldlen, newlen, totallen;
|
||||||
char *mntdata, *src, *tmp;
|
char *mntdata, *tmp;
|
||||||
|
const char *src;
|
||||||
unsigned long mntflags;
|
unsigned long mntflags;
|
||||||
char cmd_output[MAXPATHLEN] = {0};
|
char cmd_output[MAXPATHLEN] = {0};
|
||||||
|
|
||||||
@ -287,13 +288,13 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig,
|
|||||||
char cmd_output[MAXPATHLEN], option[MAXPATHLEN];
|
char cmd_output[MAXPATHLEN], option[MAXPATHLEN];
|
||||||
struct rsync_data data = {0, 0};
|
struct rsync_data data = {0, 0};
|
||||||
struct zfs_args cmd_args = {0};
|
struct zfs_args cmd_args = {0};
|
||||||
char *argv[] = {"zfs", /* 0 */
|
const char *argv[] = {"zfs", /* 0 */
|
||||||
"create", /* 1 */
|
"create", /* 1 */
|
||||||
"-o", "", /* 2, 3 */
|
"-o", "", /* 2, 3 */
|
||||||
"-o", "canmount=noauto", /* 4, 5 */
|
"-o", "canmount=noauto", /* 4, 5 */
|
||||||
"-p", /* 6 */
|
"-p", /* 6 */
|
||||||
"", /* 7 */
|
"", /* 7 */
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
/* mountpoint */
|
/* mountpoint */
|
||||||
ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", new->dest);
|
ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", new->dest);
|
||||||
@ -342,7 +343,8 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
size_t snapshot_len, len;
|
size_t snapshot_len, len;
|
||||||
char *orig_src, *tmp, *snap_name, *snapshot;
|
char *tmp, *snap_name, *snapshot;
|
||||||
|
const char *orig_src;
|
||||||
struct zfs_args cmd_args = {0};
|
struct zfs_args cmd_args = {0};
|
||||||
char cmd_output[MAXPATHLEN] = {0}, option[MAXPATHLEN];
|
char cmd_output[MAXPATHLEN] = {0}, option[MAXPATHLEN];
|
||||||
|
|
||||||
@ -447,8 +449,9 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
|
|||||||
const char *lxcpath, int snap, uint64_t newsize,
|
const char *lxcpath, int snap, uint64_t newsize,
|
||||||
struct lxc_conf *conf)
|
struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
char *dataset, *orig_src, *tmp;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
char *dataset, *tmp;
|
||||||
|
const char *orig_src;
|
||||||
size_t dataset_len, len;
|
size_t dataset_len, len;
|
||||||
char cmd_output[MAXPATHLEN] = {0};
|
char cmd_output[MAXPATHLEN] = {0};
|
||||||
|
|
||||||
@ -576,7 +579,8 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
|
|||||||
int zfs_destroy(struct lxc_storage *orig)
|
int zfs_destroy(struct lxc_storage *orig)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *dataset, *src, *tmp;
|
char *dataset, *tmp;
|
||||||
|
const char *src;
|
||||||
bool found;
|
bool found;
|
||||||
char *parent_snapshot = NULL;
|
char *parent_snapshot = NULL;
|
||||||
struct zfs_args cmd_args = {0};
|
struct zfs_args cmd_args = {0};
|
||||||
@ -709,13 +713,13 @@ int zfs_create(struct lxc_storage *bdev, const char *dest, const char *n,
|
|||||||
size_t len;
|
size_t len;
|
||||||
struct zfs_args cmd_args = {0};
|
struct zfs_args cmd_args = {0};
|
||||||
char cmd_output[MAXPATHLEN], option[MAXPATHLEN];
|
char cmd_output[MAXPATHLEN], option[MAXPATHLEN];
|
||||||
char *argv[] = {"zfs", /* 0 */
|
const char *argv[] = {"zfs", /* 0 */
|
||||||
"create", /* 1 */
|
"create", /* 1 */
|
||||||
"-o", "", /* 2, 3 */
|
"-o", "", /* 2, 3 */
|
||||||
"-o", "canmount=noauto", /* 4, 5 */
|
"-o", "canmount=noauto", /* 4, 5 */
|
||||||
"-p", /* 6 */
|
"-p", /* 6 */
|
||||||
"", /* 7 */
|
"", /* 7 */
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
if (!specs || !specs->zfs.zfsroot)
|
if (!specs || !specs->zfs.zfsroot)
|
||||||
zfsroot = lxc_global_config_value("lxc.bdev.zfs.root");
|
zfsroot = lxc_global_config_value("lxc.bdev.zfs.root");
|
||||||
|
@ -65,7 +65,7 @@ lxc_log_define(lxc_utils, lxc);
|
|||||||
*/
|
*/
|
||||||
extern bool btrfs_try_remove_subvol(const char *path);
|
extern bool btrfs_try_remove_subvol(const char *path);
|
||||||
|
|
||||||
static int _recursive_rmdir(char *dirname, dev_t pdev,
|
static int _recursive_rmdir(const char *dirname, dev_t pdev,
|
||||||
const char *exclude, int level, bool onedev)
|
const char *exclude, int level, bool onedev)
|
||||||
{
|
{
|
||||||
struct dirent *direntp;
|
struct dirent *direntp;
|
||||||
@ -180,18 +180,18 @@ static bool is_native_overlayfs(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* returns 0 on success, -1 if there were any failures */
|
/* returns 0 on success, -1 if there were any failures */
|
||||||
extern int lxc_rmdir_onedev(char *path, const char *exclude)
|
extern int lxc_rmdir_onedev(const char *path, const char *exclude)
|
||||||
{
|
{
|
||||||
struct stat mystat;
|
struct stat mystat;
|
||||||
bool onedev = true;
|
bool onedev = true;
|
||||||
|
|
||||||
if (is_native_overlayfs(path)) {
|
if (is_native_overlayfs(path))
|
||||||
onedev = false;
|
onedev = false;
|
||||||
}
|
|
||||||
|
|
||||||
if (lstat(path, &mystat) < 0) {
|
if (lstat(path, &mystat) < 0) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ERROR("Failed to stat %s", path);
|
ERROR("Failed to stat %s", path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
#define LXC_IDMAPLEN 4096
|
#define LXC_IDMAPLEN 4096
|
||||||
|
|
||||||
/* returns 1 on success, 0 if there were any failures */
|
/* returns 1 on success, 0 if there were any failures */
|
||||||
extern int lxc_rmdir_onedev(char *path, const char *exclude);
|
extern int lxc_rmdir_onedev(const char *path, const char *exclude);
|
||||||
extern int get_u16(unsigned short *val, const char *arg, int base);
|
extern int get_u16(unsigned short *val, const char *arg, int base);
|
||||||
extern int mkdir_p(const char *dir, mode_t mode);
|
extern int mkdir_p(const char *dir, mode_t mode);
|
||||||
extern char *get_rundir(void);
|
extern char *get_rundir(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user