Commit 83e79752 by Christian Brauner

Unify naming for overlay types & functions

Use ovl_ as prefix for types and functions. Signed-off-by: 's avatarChristian Brauner <christian.brauner@mailbox.org>
parent 4ec31c52
...@@ -2349,13 +2349,13 @@ static int rsync_delta_wrapper(void *data) ...@@ -2349,13 +2349,13 @@ static int rsync_delta_wrapper(void *data)
} }
/* overlay */ /* overlay */
static const struct bdev_ops overlayfs_ops = { static const struct bdev_ops ovl_ops = {
.detect = &overlayfs_detect, .detect = &ovl_detect,
.mount = &overlayfs_mount, .mount = &ovl_mount,
.umount = &overlayfs_umount, .umount = &ovl_umount,
.clone_paths = &overlayfs_clonepaths, .clone_paths = &ovl_clonepaths,
.destroy = &overlayfs_destroy, .destroy = &ovl_destroy,
.create = &overlayfs_create, .create = &ovl_create,
.can_snapshot = true, .can_snapshot = true,
.can_backup = true, .can_backup = true,
}; };
...@@ -2963,7 +2963,7 @@ static const struct bdev_type bdevs[] = { ...@@ -2963,7 +2963,7 @@ static const struct bdev_type bdevs[] = {
{.name = "btrfs", .ops = &btrfs_ops,}, {.name = "btrfs", .ops = &btrfs_ops,},
{.name = "dir", .ops = &dir_ops,}, {.name = "dir", .ops = &dir_ops,},
{.name = "aufs", .ops = &aufs_ops,}, {.name = "aufs", .ops = &aufs_ops,},
{.name = "overlayfs", .ops = &overlayfs_ops,}, {.name = "overlayfs", .ops = &ovl_ops,},
{.name = "loop", .ops = &loop_ops,}, {.name = "loop", .ops = &loop_ops,},
{.name = "nbd", .ops = &nbd_ops,}, {.name = "nbd", .ops = &nbd_ops,},
}; };
......
...@@ -49,7 +49,7 @@ extern int do_rsync(const char *src, const char *dest); ...@@ -49,7 +49,7 @@ extern int do_rsync(const char *src, const char *dest);
extern char *dir_new_path(char *src, const char *oldname, const char *name, extern char *dir_new_path(char *src, const char *oldname, const char *name,
const char *oldpath, const char *lxcpath); const char *oldpath, const char *lxcpath);
char *overlay_getlower(char *p) char *ovl_getlower(char *p)
{ {
char *p1 = strchr(p, ':'); char *p1 = strchr(p, ':');
if (p1) if (p1)
...@@ -57,15 +57,15 @@ char *overlay_getlower(char *p) ...@@ -57,15 +57,15 @@ char *overlay_getlower(char *p)
return p; return p;
} }
int overlayfs_detect(const char *path) int ovl_detect(const char *path)
{ {
if (strncmp(path, "overlayfs:", 10) == 0) if (strncmp(path, "overlayfs:", 10) == 0)
return 1; // take their word for it return 1; // take their word for it
return 0; return 0;
} }
static char *overlayfs_name; static char *ovl_name;
static char *detect_overlayfs_name(void) static char *ovl_detect_name(void)
{ {
char *v = "overlayfs"; char *v = "overlayfs";
char *line = NULL; char *line = NULL;
...@@ -87,7 +87,7 @@ static char *detect_overlayfs_name(void) ...@@ -87,7 +87,7 @@ static char *detect_overlayfs_name(void)
} }
/* XXXXXXX plain directory bind mount ops */ /* XXXXXXX plain directory bind mount ops */
int overlayfs_mount(struct bdev *bdev) int ovl_mount(struct bdev *bdev)
{ {
char *options, *dup, *lower, *upper; char *options, *dup, *lower, *upper;
char *options_work, *work, *lastslash; char *options_work, *work, *lastslash;
...@@ -102,9 +102,8 @@ int overlayfs_mount(struct bdev *bdev) ...@@ -102,9 +102,8 @@ int overlayfs_mount(struct bdev *bdev)
if (!bdev->src || !bdev->dest) if (!bdev->src || !bdev->dest)
return -22; return -22;
// defined in bdev.c if (!ovl_name)
if (!overlayfs_name) ovl_name = ovl_detect_name();
overlayfs_name = detect_overlayfs_name();
// separately mount it first // separately mount it first
// mount -t overlayfs -oupperdir=${upper},lowerdir=${lower} lower dest // mount -t overlayfs -oupperdir=${upper},lowerdir=${lower} lower dest
...@@ -175,13 +174,13 @@ int overlayfs_mount(struct bdev *bdev) ...@@ -175,13 +174,13 @@ int overlayfs_mount(struct bdev *bdev)
} }
// mount without workdir option for overlayfs before v21 // mount without workdir option for overlayfs before v21
ret = mount(lower, bdev->dest, overlayfs_name, MS_MGC_VAL | mntflags, options); ret = mount(lower, bdev->dest, ovl_name, MS_MGC_VAL | mntflags, options);
if (ret < 0) { if (ret < 0) {
INFO("overlayfs: error mounting %s onto %s options %s. retry with workdir", INFO("overlayfs: error mounting %s onto %s options %s. retry with workdir",
lower, bdev->dest, options); lower, bdev->dest, options);
// retry with workdir option for overlayfs v22 and higher // retry with workdir option for overlayfs v22 and higher
ret = mount(lower, bdev->dest, overlayfs_name, MS_MGC_VAL | mntflags, options_work); ret = mount(lower, bdev->dest, ovl_name, MS_MGC_VAL | mntflags, options_work);
if (ret < 0) if (ret < 0)
SYSERROR("overlayfs: error mounting %s onto %s options %s", SYSERROR("overlayfs: error mounting %s onto %s options %s",
lower, bdev->dest, options_work); lower, bdev->dest, options_work);
...@@ -195,7 +194,7 @@ int overlayfs_mount(struct bdev *bdev) ...@@ -195,7 +194,7 @@ int overlayfs_mount(struct bdev *bdev)
return ret; return ret;
} }
int overlayfs_umount(struct bdev *bdev) int ovl_umount(struct bdev *bdev)
{ {
if (strcmp(bdev->type, "overlayfs")) if (strcmp(bdev->type, "overlayfs"))
return -22; return -22;
...@@ -229,18 +228,18 @@ static int ovl_rsync(struct ovl_rsync_data *data) ...@@ -229,18 +228,18 @@ static int ovl_rsync(struct ovl_rsync_data *data)
ERROR("Continuing..."); ERROR("Continuing...");
} }
} }
if (overlayfs_mount(data->orig) < 0) { if (ovl_mount(data->orig) < 0) {
ERROR("Failed mounting original container fs"); ERROR("Failed mounting original container fs");
return -1; return -1;
} }
if (overlayfs_mount(data->new) < 0) { if (ovl_mount(data->new) < 0) {
ERROR("Failed mounting new container fs"); ERROR("Failed mounting new container fs");
return -1; return -1;
} }
ret = do_rsync(data->orig->dest, data->new->dest); ret = do_rsync(data->orig->dest, data->new->dest);
overlayfs_umount(data->new); ovl_umount(data->new);
overlayfs_umount(data->orig); ovl_umount(data->orig);
if (ret < 0) { if (ret < 0) {
ERROR("rsyncing %s to %s", data->orig->dest, data->new->dest); ERROR("rsyncing %s to %s", data->orig->dest, data->new->dest);
...@@ -273,9 +272,9 @@ static int ovl_do_rsync(struct bdev *orig, struct bdev *new, struct lxc_conf *co ...@@ -273,9 +272,9 @@ static int ovl_do_rsync(struct bdev *orig, struct bdev *new, struct lxc_conf *co
return ret; return ret;
} }
int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname, int ovl_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
const char *cname, const char *oldpath, const char *lxcpath, int snap, const char *cname, const char *oldpath, const char *lxcpath,
uint64_t newsize, struct lxc_conf *conf) int snap, uint64_t newsize, struct lxc_conf *conf)
{ {
if (!snap) { if (!snap) {
ERROR("overlayfs is only for snapshot clones"); ERROR("overlayfs is only for snapshot clones");
...@@ -425,7 +424,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam ...@@ -425,7 +424,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam
} else { } else {
ERROR("overlayfs clone of %s container is not yet supported", ERROR("overlayfs clone of %s container is not yet supported",
orig->type); orig->type);
// Note, supporting this will require overlayfs_mount supporting // Note, supporting this will require ovl_mount supporting
// mounting of the underlay. No big deal, just needs to be done. // mounting of the underlay. No big deal, just needs to be done.
return -1; return -1;
} }
...@@ -433,7 +432,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam ...@@ -433,7 +432,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam
return 0; return 0;
} }
int overlayfs_destroy(struct bdev *orig) int ovl_destroy(struct bdev *orig)
{ {
char *upper; char *upper;
...@@ -452,7 +451,7 @@ int overlayfs_destroy(struct bdev *orig) ...@@ -452,7 +451,7 @@ int overlayfs_destroy(struct bdev *orig)
* changes after starting the container are written to * changes after starting the container are written to
* $lxcpath/$lxcname/delta0 * $lxcpath/$lxcname/delta0
*/ */
int overlayfs_create(struct bdev *bdev, const char *dest, const char *n, int ovl_create(struct bdev *bdev, const char *dest, const char *n,
struct bdev_specs *specs) struct bdev_specs *specs)
{ {
char *delta; char *delta;
...@@ -502,9 +501,9 @@ int overlayfs_create(struct bdev *bdev, const char *dest, const char *n, ...@@ -502,9 +501,9 @@ int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
* independent of each other since lxc_conf->mountlist may container more mount * independent of each other since lxc_conf->mountlist may container more mount
* entries (e.g. from other included files) than lxc_conf->unexpanded_config . * entries (e.g. from other included files) than lxc_conf->unexpanded_config .
*/ */
int update_ovl_paths(struct lxc_conf *lxc_conf, const char *lxc_path, int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
const char *lxc_name, const char *newpath, const char *lxc_name, const char *newpath,
const char *newname) const char *newname)
{ {
char new_upper[MAXPATHLEN]; char new_upper[MAXPATHLEN];
char new_work[MAXPATHLEN]; char new_work[MAXPATHLEN];
......
...@@ -38,16 +38,15 @@ struct bdev_specs; ...@@ -38,16 +38,15 @@ struct bdev_specs;
/* defined conf.h */ /* defined conf.h */
struct lxc_conf; struct lxc_conf;
int overlayfs_detect(const char *path); int ovl_detect(const char *path);
int overlayfs_mount(struct bdev *bdev); int ovl_mount(struct bdev *bdev);
int overlayfs_umount(struct bdev *bdev); int ovl_umount(struct bdev *bdev);
int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, int ovl_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
const char *oldname, const char *cname, const char *cname, const char *oldpath, const char *lxcpath,
const char *oldpath, const char *lxcpath, int snap, int snap, uint64_t newsize, struct lxc_conf *conf);
uint64_t newsize, struct lxc_conf *conf); int ovl_destroy(struct bdev *orig);
int overlayfs_destroy(struct bdev *orig); int ovl_create(struct bdev *bdev, const char *dest, const char *n,
int overlayfs_create(struct bdev *bdev, const char *dest, const char *n, struct bdev_specs *specs);
struct bdev_specs *specs);
/* /*
* To be called from lxcapi_clone() in lxccontainer.c: When we clone a container * To be called from lxcapi_clone() in lxccontainer.c: When we clone a container
...@@ -57,14 +56,14 @@ int overlayfs_create(struct bdev *bdev, const char *dest, const char *n, ...@@ -57,14 +56,14 @@ int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
* independent of each other since lxc_conf->mountlist may container more mount * independent of each other since lxc_conf->mountlist may container more mount
* entries (e.g. from other included files) than lxc_conf->unexpanded_config . * entries (e.g. from other included files) than lxc_conf->unexpanded_config .
*/ */
int update_ovl_paths(struct lxc_conf *lxc_conf, const char *lxc_path, int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
const char *lxc_name, const char *newpath, const char *lxc_name, const char *newpath,
const char *newname); const char *newname);
/* /*
* 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.
*/ */
char *overlay_getlower(char *p); char *ovl_getlower(char *p);
#endif /* __LXC_OVERLAY_H */ #endif /* __LXC_OVERLAY_H */
...@@ -1093,9 +1093,9 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool need_ ...@@ -1093,9 +1093,9 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool need_
* the template * the template
*/ */
if (strncmp(src, "overlayfs:", 10) == 0) if (strncmp(src, "overlayfs:", 10) == 0)
src = overlay_getlower(src+10); src = ovl_getlower(src+10);
if (strncmp(src, "aufs:", 5) == 0) if (strncmp(src, "aufs:", 5) == 0)
src = overlay_getlower(src+5); src = ovl_getlower(src+5);
bdev = bdev_init(c->lxc_conf, src, c->lxc_conf->rootfs.mount, NULL); bdev = bdev_init(c->lxc_conf, src, c->lxc_conf->rootfs.mount, NULL);
if (!bdev) { if (!bdev) {
...@@ -3125,7 +3125,7 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char ...@@ -3125,7 +3125,7 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
} }
// update absolute paths for overlay mount directories // update absolute paths for overlay mount directories
if (update_ovl_paths(c2->lxc_conf, c->config_path, c->name, lxcpath, newname) < 0) if (ovl_update_abs_paths(c2->lxc_conf, c->config_path, c->name, lxcpath, newname) < 0)
goto out; goto out;
// We've now successfully created c2's storage, so clear it out if we // We've now successfully created c2's storage, so clear it out if we
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment