]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Unify naming for overlay types & functions
authorChristian Brauner <christian.brauner@mailbox.org>
Sun, 13 Dec 2015 18:44:09 +0000 (19:44 +0100)
committerChristian Brauner <christian.brauner@mailbox.org>
Tue, 15 Dec 2015 16:03:58 +0000 (17:03 +0100)
Use ovl_ as prefix for types and functions.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
src/lxc/bdev/bdev.c
src/lxc/bdev/overlay.c
src/lxc/bdev/overlay.h
src/lxc/lxccontainer.c

index 479a09ac51688bdd6ca6f4cbcc2dfc8348a70bb2..1c487a503646c902d758b4df92e6614868702bba 100644 (file)
@@ -2349,13 +2349,13 @@ static int rsync_delta_wrapper(void *data)
 }
 
 /* overlay */
-static const struct bdev_ops overlayfs_ops = {
-       .detect = &overlayfs_detect,
-       .mount = &overlayfs_mount,
-       .umount = &overlayfs_umount,
-       .clone_paths = &overlayfs_clonepaths,
-       .destroy = &overlayfs_destroy,
-       .create = &overlayfs_create,
+static const struct bdev_ops ovl_ops = {
+       .detect = &ovl_detect,
+       .mount = &ovl_mount,
+       .umount = &ovl_umount,
+       .clone_paths = &ovl_clonepaths,
+       .destroy = &ovl_destroy,
+       .create = &ovl_create,
        .can_snapshot = true,
        .can_backup = true,
 };
@@ -2963,7 +2963,7 @@ static const struct bdev_type bdevs[] = {
        {.name = "btrfs", .ops = &btrfs_ops,},
        {.name = "dir", .ops = &dir_ops,},
        {.name = "aufs", .ops = &aufs_ops,},
-       {.name = "overlayfs", .ops = &overlayfs_ops,},
+       {.name = "overlayfs", .ops = &ovl_ops,},
        {.name = "loop", .ops = &loop_ops,},
        {.name = "nbd", .ops = &nbd_ops,},
 };
index 3b5c8268b633e2cdcf7e6da7784d7e5b6d8eca75..26a7238f09593e34e672a0699fd324e99c0dc0d7 100644 (file)
@@ -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,
                          const char *oldpath, const char *lxcpath);
 
-char *overlay_getlower(char *p)
+char *ovl_getlower(char *p)
 {
        char *p1 = strchr(p, ':');
        if (p1)
@@ -57,15 +57,15 @@ char *overlay_getlower(char *p)
        return p;
 }
 
-int overlayfs_detect(const char *path)
+int ovl_detect(const char *path)
 {
        if (strncmp(path, "overlayfs:", 10) == 0)
                return 1; // take their word for it
        return 0;
 }
 
-static char *overlayfs_name;
-static char *detect_overlayfs_name(void)
+static char *ovl_name;
+static char *ovl_detect_name(void)
 {
        char *v = "overlayfs";
        char *line = NULL;
@@ -87,7 +87,7 @@ static char *detect_overlayfs_name(void)
 }
 
 /* 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_work, *work, *lastslash;
@@ -102,9 +102,8 @@ int overlayfs_mount(struct bdev *bdev)
        if (!bdev->src || !bdev->dest)
                return -22;
 
-       // defined in bdev.c
-       if (!overlayfs_name)
-               overlayfs_name = detect_overlayfs_name();
+       if (!ovl_name)
+               ovl_name = ovl_detect_name();
 
        //  separately mount it first
        //  mount -t overlayfs -oupperdir=${upper},lowerdir=${lower} lower dest
@@ -175,13 +174,13 @@ int overlayfs_mount(struct bdev *bdev)
        }
 
        // 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) {
                INFO("overlayfs: error mounting %s onto %s options %s. retry with workdir",
                        lower, bdev->dest, options);
 
                // 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)
                        SYSERROR("overlayfs: error mounting %s onto %s options %s",
                                lower, bdev->dest, options_work);
@@ -195,7 +194,7 @@ int overlayfs_mount(struct bdev *bdev)
        return ret;
 }
 
-int overlayfs_umount(struct bdev *bdev)
+int ovl_umount(struct bdev *bdev)
 {
        if (strcmp(bdev->type, "overlayfs"))
                return -22;
@@ -229,18 +228,18 @@ static int ovl_rsync(struct ovl_rsync_data *data)
                        ERROR("Continuing...");
                }
        }
-       if (overlayfs_mount(data->orig) < 0) {
+       if (ovl_mount(data->orig) < 0) {
                ERROR("Failed mounting original container fs");
                return -1;
        }
-       if (overlayfs_mount(data->new) < 0) {
+       if (ovl_mount(data->new) < 0) {
                ERROR("Failed mounting new container fs");
                return -1;
        }
        ret = do_rsync(data->orig->dest, data->new->dest);
 
-       overlayfs_umount(data->new);
-       overlayfs_umount(data->orig);
+       ovl_umount(data->new);
+       ovl_umount(data->orig);
 
        if (ret < 0) {
                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
        return ret;
 }
 
-int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
-               const char *cname, const char *oldpath, const char *lxcpath, int snap,
-               uint64_t newsize, struct lxc_conf *conf)
+int ovl_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
+                  const char *cname, const char *oldpath, const char *lxcpath,
+                  int snap, uint64_t newsize, struct lxc_conf *conf)
 {
        if (!snap) {
                ERROR("overlayfs is only for snapshot clones");
@@ -425,7 +424,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam
        } else {
                ERROR("overlayfs clone of %s container is not yet supported",
                        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.
                return -1;
        }
@@ -433,7 +432,7 @@ int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldnam
        return 0;
 }
 
-int overlayfs_destroy(struct bdev *orig)
+int ovl_destroy(struct bdev *orig)
 {
        char *upper;
 
@@ -452,7 +451,7 @@ int overlayfs_destroy(struct bdev *orig)
  * changes after starting the container are written to
  * $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)
 {
        char *delta;
@@ -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
  * 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,
-                    const char *lxc_name, const char *newpath,
-                    const char *newname)
+int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
+                        const char *lxc_name, const char *newpath,
+                        const char *newname)
 {
        char new_upper[MAXPATHLEN];
        char new_work[MAXPATHLEN];
index 360759b70be981dd83efae5c5ef9f6ff2fcb022c..338fb86baedfb1d90f26dfced2232846e21252ba 100644 (file)
@@ -38,16 +38,15 @@ struct bdev_specs;
 /* defined conf.h */
 struct lxc_conf;
 
-int overlayfs_detect(const char *path);
-int overlayfs_mount(struct bdev *bdev);
-int overlayfs_umount(struct bdev *bdev);
-int overlayfs_clonepaths(struct bdev *orig, struct bdev *new,
-                        const char *oldname, const char *cname,
-                        const char *oldpath, const char *lxcpath, int snap,
-                        uint64_t newsize, struct lxc_conf *conf);
-int overlayfs_destroy(struct bdev *orig);
-int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
-                    struct bdev_specs *specs);
+int ovl_detect(const char *path);
+int ovl_mount(struct bdev *bdev);
+int ovl_umount(struct bdev *bdev);
+int ovl_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
+                  const char *cname, const char *oldpath, const char *lxcpath,
+                  int snap, uint64_t newsize, struct lxc_conf *conf);
+int ovl_destroy(struct bdev *orig);
+int ovl_create(struct bdev *bdev, const char *dest, const char *n,
+              struct bdev_specs *specs);
 
 /*
  * 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,
  * independent of each other since lxc_conf->mountlist may container more mount
  * 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,
-                    const char *lxc_name, const char *newpath,
-                    const char *newname);
+int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
+                        const char *lxc_name, const char *newpath,
+                        const char *newname);
 
 /*
  * To be called from functions in lxccontainer.c: Get lower directory for
  * overlay rootfs.
  */
-char *overlay_getlower(char *p);
+char *ovl_getlower(char *p);
 
 #endif /* __LXC_OVERLAY_H */
index 97abced97a9de8967b03e4f515e91b14cdcd6124..68644c057e125e505d3471c58d02204cbf372b3e 100644 (file)
@@ -1093,9 +1093,9 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool need_
                 * the template
                 */
                if (strncmp(src, "overlayfs:", 10) == 0)
-                       src = overlay_getlower(src+10);
+                       src = ovl_getlower(src+10);
                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);
                if (!bdev) {
@@ -3125,7 +3125,7 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
        }
 
        // 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;
 
        // We've now successfully created c2's storage, so clear it out if we