The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/799

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
- The function mount_entry_create_aufs_dirs() moves from conf.c to
  lxcaufs.{c,h} where it belongs.
- In accordance with the "aufs_" prefix naming scheme for functions associated
  with lxcaufs.{c,h} mount_entry_create_aufs_dirs() becomes aufs_mkdir().

Signed-off-by: Christian Brauner <christian.brau...@mailbox.org>
From ff63aeccfca7284458a1e8c278ebc9e35f72e821 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@mailbox.org>
Date: Wed, 3 Feb 2016 00:41:14 +0100
Subject: [PATCH] move and rename mount_entry_create_aufs_dirs()

- The function mount_entry_create_aufs_dirs() moves from conf.c to
  lxcaufs.{c,h} where it belongs.
- In accordance with the "aufs_" prefix naming scheme for functions associated
  with lxcaufs.{c,h} mount_entry_create_aufs_dirs() becomes aufs_mkdir().

Signed-off-by: Christian Brauner <christian.brau...@mailbox.org>
---
 src/lxc/bdev/lxcaufs.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++
 src/lxc/bdev/lxcaufs.h |  7 ++++++
 src/lxc/conf.c         | 67 ++------------------------------------------------
 3 files changed, 73 insertions(+), 65 deletions(-)

diff --git a/src/lxc/bdev/lxcaufs.c b/src/lxc/bdev/lxcaufs.c
index 408f6a3..bb38eb5 100644
--- a/src/lxc/bdev/lxcaufs.c
+++ b/src/lxc/bdev/lxcaufs.c
@@ -312,3 +312,67 @@ int aufs_umount(struct bdev *bdev)
                return -22;
        return umount(bdev->dest);
 }
+
+static int aufs_mkdir(const struct mntent *mntent,
+               const struct lxc_rootfs *rootfs, const char *lxc_name,
+               const char *lxc_path)
+{
+       char lxcpath[MAXPATHLEN];
+       char *rootfsdir = NULL;
+       char *scratch = NULL;
+       char *tmp = NULL;
+       char *upperdir = NULL;
+       char **opts = NULL;
+       int fret = -1;
+       int ret = 0;
+       size_t arrlen = 0;
+       size_t i;
+       size_t len = 0;
+       size_t rootfslen = 0;
+
+       /* Since we use all of these to check whether the user has given us a
+        * sane absolute path to create the directories needed for overlay
+        * lxc.mount.entry entries we consider any of these missing fatal. */
+       if (!rootfs || !rootfs->path || !lxc_name || !lxc_path)
+               goto err;
+
+       opts = lxc_string_split(mntent->mnt_opts, ',');
+       if (opts)
+               arrlen = lxc_array_len((void **)opts);
+       else
+               goto err;
+
+       for (i = 0; i < arrlen; i++) {
+               if (strstr(opts[i], "br=") && (strlen(opts[i]) > (len = 
strlen("br="))))
+                       tmp = opts[i] + len;
+       }
+       if (!tmp)
+               goto err;
+
+       upperdir = strtok_r(tmp, ":=", &scratch);
+       if (!upperdir)
+               goto err;
+
+       ret = snprintf(lxcpath, MAXPATHLEN, "%s/%s", lxc_path, lxc_name);
+       if (ret < 0 || ret >= MAXPATHLEN)
+               goto err;
+
+       rootfsdir = ovl_get_rootfs(rootfs->path, &rootfslen);
+       if (!rootfsdir)
+               goto err;
+
+       /* We neither allow users to create upperdirs outside the containerdir
+        * nor inside the rootfs. The latter might be debatable. */
+       if ((strncmp(upperdir, lxcpath, strlen(lxcpath)) == 0) && 
(strncmp(upperdir, rootfsdir, rootfslen) != 0))
+               if (mkdir_p(upperdir, 0755) < 0) {
+                       WARN("Failed to create upperdir");
+               }
+
+       fret = 0;
+
+err:
+       free(rootfsdir);
+       lxc_free_array((void **)opts, free);
+       return fret;
+}
+
diff --git a/src/lxc/bdev/lxcaufs.h b/src/lxc/bdev/lxcaufs.h
index e259ee2..4e0160e 100644
--- a/src/lxc/bdev/lxcaufs.h
+++ b/src/lxc/bdev/lxcaufs.h
@@ -49,4 +49,11 @@ int aufs_detect(const char *path);
 int aufs_mount(struct bdev *bdev);
 int aufs_umount(struct bdev *bdev);
 
+/*
+ * Create directories for aufs mounts.
+ */
+static int aufs_mkdir(const struct mntent *mntent,
+               const struct lxc_rootfs *rootfs, const char *lxc_name,
+               const char *lxc_path);
+
 #endif /* __LXC_AUFS_H */
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index a32513d..c2296f9 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -72,6 +72,7 @@
 #include "log.h"
 #include "caps.h"       /* for lxc_caps_last_cap() */
 #include "bdev/bdev.h"
+#include "bdev/lxcaufs.h"
 #include "bdev/lxcoverlay.h"
 #include "cgroup.h"
 #include "lxclock.h"
@@ -1726,70 +1727,6 @@ static void cull_mntent_opt(struct mntent *mntent)
        }
 }
 
-static int mount_entry_create_aufs_dirs(const struct mntent *mntent,
-                                       const struct lxc_rootfs *rootfs,
-                                       const char *lxc_name,
-                                       const char *lxc_path)
-{
-       char lxcpath[MAXPATHLEN];
-       char *rootfsdir = NULL;
-       char *scratch = NULL;
-       char *tmp = NULL;
-       char *upperdir = NULL;
-       char **opts = NULL;
-       int fret = -1;
-       int ret = 0;
-       size_t arrlen = 0;
-       size_t i;
-       size_t len = 0;
-       size_t rootfslen = 0;
-
-       /* Since we use all of these to check whether the user has given us a
-        * sane absolute path to create the directories needed for overlay
-        * lxc.mount.entry entries we consider any of these missing fatal. */
-       if (!rootfs || !rootfs->path || !lxc_name || !lxc_path)
-               goto err;
-
-       opts = lxc_string_split(mntent->mnt_opts, ',');
-       if (opts)
-               arrlen = lxc_array_len((void **)opts);
-       else
-               goto err;
-
-       for (i = 0; i < arrlen; i++) {
-               if (strstr(opts[i], "br=") && (strlen(opts[i]) > (len = 
strlen("br="))))
-                       tmp = opts[i] + len;
-       }
-       if (!tmp)
-               goto err;
-
-       upperdir = strtok_r(tmp, ":=", &scratch);
-       if (!upperdir)
-               goto err;
-
-       ret = snprintf(lxcpath, MAXPATHLEN, "%s/%s", lxc_path, lxc_name);
-       if (ret < 0 || ret >= MAXPATHLEN)
-               goto err;
-
-       rootfsdir = ovl_get_rootfs(rootfs->path, &rootfslen);
-       if (!rootfsdir)
-               goto err;
-
-       /* We neither allow users to create upperdirs outside the containerdir
-        * nor inside the rootfs. The latter might be debatable. */
-       if ((strncmp(upperdir, lxcpath, strlen(lxcpath)) == 0) && 
(strncmp(upperdir, rootfsdir, rootfslen) != 0))
-               if (mkdir_p(upperdir, 0755) < 0) {
-                       WARN("Failed to create upperdir");
-               }
-
-       fret = 0;
-
-err:
-       free(rootfsdir);
-       lxc_free_array((void **)opts, free);
-       return fret;
-}
-
 static int mount_entry_create_dir_file(const struct mntent *mntent,
                                       const char* path, const struct 
lxc_rootfs *rootfs,
                                       const char *lxc_name, const char 
*lxc_path)
@@ -1802,7 +1739,7 @@ static int mount_entry_create_dir_file(const struct 
mntent *mntent,
                if (ovl_mkdir(mntent, rootfs, lxc_name, lxc_path) < 0)
                        return -1;
        } else if (strncmp(mntent->mnt_type, "aufs", 4) == 0) {
-               if (mount_entry_create_aufs_dirs(mntent, rootfs, lxc_name, 
lxc_path) < 0)
+               if (aufs_mkdir(mntent, rootfs, lxc_name, lxc_path) < 0)
                        return -1;
        }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to