]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/lxccontainer.c
Merge pull request #1943 from bhelm/master
[mirror_lxc.git] / src / lxc / lxccontainer.c
index 63a66709898897f18910956a613301480e9a73ca..a7f29838aaaea34acd87c1512b51c0317d674a17 100644 (file)
@@ -1935,8 +1935,7 @@ static bool do_lxcapi_create(struct lxc_container *c, const char *t,
 
 out_unlock:
        umask(mask);
-       if (partial_fd >= 0)
-               remove_partial(c, partial_fd);
+       remove_partial(c, partial_fd);
 
 out:
        if (!ret)
@@ -2255,7 +2254,7 @@ static bool add_to_array(char ***names, char *cname, int pos)
        if (!newnames[pos])
                return false;
 
-       /* Sort the arrray as we will use binary search on it. */
+       /* Sort the array as we will use binary search on it. */
        qsort(newnames, pos + 1, sizeof(char *),
              (int (*)(const void *, const void *))string_cmp);
 
@@ -2274,7 +2273,7 @@ static bool add_to_clist(struct lxc_container ***list, struct lxc_container *c,
        *list = newlist;
        newlist[pos] = c;
 
-       /* Sort the arrray as we will use binary search on it. */
+       /* Sort the array as we will use binary search on it. */
        if (sort)
                qsort(newlist, pos + 1, sizeof(struct lxc_container *),
                      (int (*)(const void *, const void *))container_cmp);
@@ -4976,6 +4975,7 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
        char template[PATH_MAX], path[PATH_MAX];
        pid_t pid, init_pid;
        struct stat sb;
+       bool is_dir;
        int ret = -1, fd = -EBADF;
 
        if (!c || !c->lxc_conf) {
@@ -5006,7 +5006,8 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
                }
        }
 
-       if (S_ISDIR(sb.st_mode)) {
+       is_dir = (S_ISDIR(sb.st_mode) != 0);
+       if (is_dir) {
                sret = mkdtemp(template);
                if (!sret) {
                        SYSERROR("Could not create shmounts temporary dir");
@@ -5089,7 +5090,10 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
        ret = 0;
 
        (void)umount2(template, MNT_DETACH);
-       (void)unlink(template);
+       if (is_dir)
+               (void)rmdir(template);
+       else
+               (void)unlink(template);
 
 out:
        if (fd >= 0)