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