out_unlock:
umask(mask);
- if (partial_fd >= 0)
- remove_partial(c, partial_fd);
+ remove_partial(c, partial_fd);
out:
if (!ret)
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);
*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);
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) {
}
}
- 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");
ret = 0;
(void)umount2(template, MNT_DETACH);
- (void)unlink(template);
+ if (is_dir)
+ (void)rmdir(template);
+ else
+ (void)unlink(template);
out:
if (fd >= 0)