Unverified Commit d0986340 by Stéphane Graber Committed by GitHub

Merge pull request #3225 from brauner/cgroup_improvements

cgroups/cgfsng: rework legacy cpuset handling
parents dc3cdf28 8e64b673
......@@ -14,7 +14,6 @@
#define DEFAULT_MONITOR_CGROUP_PREFIX "lxc.monitor."
#define CGROUP_CREATE_RETRY "-NNNN"
#define CGROUP_CREATE_RETRY_LEN (STRLITERALLEN(CGROUP_CREATE_RETRY))
#define CGROUP_PIVOT "lxc.pivot"
struct lxc_handler;
struct lxc_conf;
......
......@@ -13,6 +13,7 @@
#include "config.h"
#include "file_utils.h"
#include "log.h"
#include "macro.h"
#include "memory_utils.h"
#include "string_utils.h"
......
......@@ -1791,21 +1791,19 @@ int fd_cloexec(int fd, bool cloexec)
return 0;
}
int recursive_destroy(char *dirname)
int recursive_destroy(const char *dirname)
{
__do_closedir DIR *dir = NULL;
int fret = 0;
int ret;
struct dirent *direntp;
DIR *dir;
int r = 0;
dir = opendir(dirname);
if (!dir) {
SYSERROR("Failed to open dir \"%s\"", dirname);
return -1;
}
if (!dir)
return log_error_errno(-1, errno, "Failed to open dir \"%s\"", dirname);
while ((direntp = readdir(dir))) {
char *pathname;
__do_free char *pathname = NULL;
struct stat mystat;
if (!strcmp(direntp->d_name, ".") ||
......@@ -1813,44 +1811,28 @@ int recursive_destroy(char *dirname)
continue;
pathname = must_make_path(dirname, direntp->d_name, NULL);
ret = lstat(pathname, &mystat);
if (ret < 0) {
if (!r)
if (!fret)
SYSWARN("Failed to stat \"%s\"", pathname);
r = -1;
goto next;
fret = -1;
continue;
}
if (!S_ISDIR(mystat.st_mode))
goto next;
continue;
ret = recursive_destroy(pathname);
if (ret < 0)
r = -1;
next:
free(pathname);
fret = -1;
}
ret = rmdir(dirname);
if (ret < 0) {
if (!r)
SYSWARN("Failed to delete \"%s\"", dirname);
r = -1;
}
ret = closedir(dir);
if (ret < 0) {
if (!r)
SYSWARN("Failed to delete \"%s\"", dirname);
r = -1;
}
if (ret < 0)
return log_warn_errno(-1, errno, "Failed to delete \"%s\"", dirname);
return r;
return fret;
}
int lxc_setup_keyring(void)
......
......@@ -231,7 +231,7 @@ extern uint64_t lxc_find_next_power2(uint64_t n);
/* Set a signal the child process will receive after the parent has died. */
extern int lxc_set_death_signal(int signal, pid_t parent, int parent_status_fd);
extern int fd_cloexec(int fd, bool cloexec);
extern int recursive_destroy(char *dirname);
extern int recursive_destroy(const char *dirname);
extern int lxc_setup_keyring(void);
#endif /* __LXC_UTILS_H */
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