diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index a8ce09954404..c9483d8f6140 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1102,7 +1102,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) | |||
1102 | if (opts->release_agent) | 1102 | if (opts->release_agent) |
1103 | return -EINVAL; | 1103 | return -EINVAL; |
1104 | opts->release_agent = | 1104 | opts->release_agent = |
1105 | kstrndup(token + 14, PATH_MAX, GFP_KERNEL); | 1105 | kstrndup(token + 14, PATH_MAX - 1, GFP_KERNEL); |
1106 | if (!opts->release_agent) | 1106 | if (!opts->release_agent) |
1107 | return -ENOMEM; | 1107 | return -ENOMEM; |
1108 | } else if (!strncmp(token, "name=", 5)) { | 1108 | } else if (!strncmp(token, "name=", 5)) { |
@@ -1123,7 +1123,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) | |||
1123 | if (opts->name) | 1123 | if (opts->name) |
1124 | return -EINVAL; | 1124 | return -EINVAL; |
1125 | opts->name = kstrndup(name, | 1125 | opts->name = kstrndup(name, |
1126 | MAX_CGROUP_ROOT_NAMELEN, | 1126 | MAX_CGROUP_ROOT_NAMELEN - 1, |
1127 | GFP_KERNEL); | 1127 | GFP_KERNEL); |
1128 | if (!opts->name) | 1128 | if (!opts->name) |
1129 | return -ENOMEM; | 1129 | return -ENOMEM; |
@@ -1623,6 +1623,8 @@ static struct file_system_type cgroup_fs_type = { | |||
1623 | .kill_sb = cgroup_kill_sb, | 1623 | .kill_sb = cgroup_kill_sb, |
1624 | }; | 1624 | }; |
1625 | 1625 | ||
1626 | static struct kobject *cgroup_kobj; | ||
1627 | |||
1626 | static inline struct cgroup *__d_cgrp(struct dentry *dentry) | 1628 | static inline struct cgroup *__d_cgrp(struct dentry *dentry) |
1627 | { | 1629 | { |
1628 | return dentry->d_fsdata; | 1630 | return dentry->d_fsdata; |
@@ -1789,19 +1791,20 @@ out: | |||
1789 | } | 1791 | } |
1790 | 1792 | ||
1791 | /** | 1793 | /** |
1792 | * cgroup_attach_task_current_cg - attach task 'tsk' to current task's cgroup | 1794 | * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' |
1795 | * @from: attach to all cgroups of a given task | ||
1793 | * @tsk: the task to be attached | 1796 | * @tsk: the task to be attached |
1794 | */ | 1797 | */ |
1795 | int cgroup_attach_task_current_cg(struct task_struct *tsk) | 1798 | int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk) |
1796 | { | 1799 | { |
1797 | struct cgroupfs_root *root; | 1800 | struct cgroupfs_root *root; |
1798 | struct cgroup *cur_cg; | ||
1799 | int retval = 0; | 1801 | int retval = 0; |
1800 | 1802 | ||
1801 | cgroup_lock(); | 1803 | cgroup_lock(); |
1802 | for_each_active_root(root) { | 1804 | for_each_active_root(root) { |
1803 | cur_cg = task_cgroup_from_root(current, root); | 1805 | struct cgroup *from_cg = task_cgroup_from_root(from, root); |
1804 | retval = cgroup_attach_task(cur_cg, tsk); | 1806 | |
1807 | retval = cgroup_attach_task(from_cg, tsk); | ||
1805 | if (retval) | 1808 | if (retval) |
1806 | break; | 1809 | break; |
1807 | } | 1810 | } |
@@ -1809,7 +1812,7 @@ int cgroup_attach_task_current_cg(struct task_struct *tsk) | |||
1809 | 1812 | ||
1810 | return retval; | 1813 | return retval; |
1811 | } | 1814 | } |
1812 | EXPORT_SYMBOL_GPL(cgroup_attach_task_current_cg); | 1815 | EXPORT_SYMBOL_GPL(cgroup_attach_task_all); |
1813 | 1816 | ||
1814 | /* | 1817 | /* |
1815 | * Attach task with pid 'pid' to cgroup 'cgrp'. Call with cgroup_mutex | 1818 | * Attach task with pid 'pid' to cgroup 'cgrp'. Call with cgroup_mutex |
@@ -3894,9 +3897,18 @@ int __init cgroup_init(void) | |||
3894 | hhead = css_set_hash(init_css_set.subsys); | 3897 | hhead = css_set_hash(init_css_set.subsys); |
3895 | hlist_add_head(&init_css_set.hlist, hhead); | 3898 | hlist_add_head(&init_css_set.hlist, hhead); |
3896 | BUG_ON(!init_root_id(&rootnode)); | 3899 | BUG_ON(!init_root_id(&rootnode)); |
3900 | |||
3901 | cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj); | ||
3902 | if (!cgroup_kobj) { | ||
3903 | err = -ENOMEM; | ||
3904 | goto out; | ||
3905 | } | ||
3906 | |||
3897 | err = register_filesystem(&cgroup_fs_type); | 3907 | err = register_filesystem(&cgroup_fs_type); |
3898 | if (err < 0) | 3908 | if (err < 0) { |
3909 | kobject_put(cgroup_kobj); | ||
3899 | goto out; | 3910 | goto out; |
3911 | } | ||
3900 | 3912 | ||
3901 | proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations); | 3913 | proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations); |
3902 | 3914 | ||