return unlink(nsgroup);
}
-int lxc_cgroup_copy(const char *name, const char *subsystem)
-{
- char destination[MAXPATHLEN];
- char source[MAXPATHLEN];
- char buffer[1024];
- int nbbytes, fd_source, fd_destination, ret = -1;
-
- snprintf(source, MAXPATHLEN, LXCPATH "/%s/cgroup/%s", name, subsystem);
-
- if (access(source, F_OK))
- return 0;
-
- fd_source = open(source, O_RDONLY);
- if (fd_source < 0) {
- lxc_log_syserror("failed to open '%s'", source);
- return -1;
- }
-
- snprintf(destination, MAXPATHLEN, LXCPATH "/%s/nsgroup/%s", name, subsystem);
-
- fd_destination = open(destination, O_WRONLY);
- if (fd_destination < 0) {
- lxc_log_syserror("failed to open '%s'", destination);
- goto out;
- }
-
- nbbytes = read(fd_source, buffer, sizeof(buffer));
- if (nbbytes < 0) {
- lxc_log_syserror("failed to read '%s'", source);
- goto out;
- }
-
- if (write(fd_destination, buffer, nbbytes) < 0) {
- lxc_log_syserror("failed to write to '%s'", destination);
- goto out;
- }
-
- ret = 0;
-out:
- close(fd_source);
- close(fd_destination);
- return ret;
-}
-
int lxc_cgroup_set(const char *name, const char *subsystem, const char *value)
{
int fd, ret = -1;;
int lxc_get_cgroup_mount(const char *mtab, char *mnt);
int lxc_link_nsgroup(const char *name, pid_t pid);
int lxc_unlink_nsgroup(const char *name);
-int lxc_cgroup_copy(const char *name, const char *subsystem);
#endif
static int setup_cgroup_cb(void* buffer, void *data)
{
char *key = buffer, *value;
+ char *name = data;
+ int ret;
value = strchr(key, '=');
if (!value)
*value = '\0';
value += 1;
- printf("key: %s\n", key);
- printf("value: %s\n", value);
-
- return 0;
+ ret = lxc_cgroup_set(name, key, value);
+ if (ret)
+ lxc_log_syserror("failed to set cgroup '%s' = '%s' for '%s'",
+ key, value, name);
+ return ret;
}
static int setup_convert_cgroup_cb(const char *name, const char *directory,
}
return file_for_each_line(filename, setup_cgroup_cb,
- line, MAXPATHLEN, filename);
+ line, MAXPATHLEN, (void *)name);
}
static int setup_mount(const char *name)