diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index f6495f33a355..95362d15128c 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -4818,6 +4818,29 @@ css_get_next(struct cgroup_subsys *ss, int id, | |||
4818 | return ret; | 4818 | return ret; |
4819 | } | 4819 | } |
4820 | 4820 | ||
4821 | /* | ||
4822 | * get corresponding css from file open on cgroupfs directory | ||
4823 | */ | ||
4824 | struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id) | ||
4825 | { | ||
4826 | struct cgroup *cgrp; | ||
4827 | struct inode *inode; | ||
4828 | struct cgroup_subsys_state *css; | ||
4829 | |||
4830 | inode = f->f_dentry->d_inode; | ||
4831 | /* check in cgroup filesystem dir */ | ||
4832 | if (inode->i_op != &cgroup_dir_inode_operations) | ||
4833 | return ERR_PTR(-EBADF); | ||
4834 | |||
4835 | if (id < 0 || id >= CGROUP_SUBSYS_COUNT) | ||
4836 | return ERR_PTR(-EINVAL); | ||
4837 | |||
4838 | /* get cgroup */ | ||
4839 | cgrp = __d_cgrp(f->f_dentry); | ||
4840 | css = cgrp->subsys[id]; | ||
4841 | return css ? css : ERR_PTR(-ENOENT); | ||
4842 | } | ||
4843 | |||
4821 | #ifdef CONFIG_CGROUP_DEBUG | 4844 | #ifdef CONFIG_CGROUP_DEBUG |
4822 | static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, | 4845 | static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, |
4823 | struct cgroup *cont) | 4846 | struct cgroup *cont) |