diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cgroup.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index e5583d10a325..afb8d53ca6c7 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -1846,36 +1846,43 @@ out: | |||
| 1846 | EXPORT_SYMBOL_GPL(cgroup_path); | 1846 | EXPORT_SYMBOL_GPL(cgroup_path); |
| 1847 | 1847 | ||
| 1848 | /** | 1848 | /** |
| 1849 | * task_cgroup_path_from_hierarchy - cgroup path of a task on a hierarchy | 1849 | * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy |
| 1850 | * @task: target task | 1850 | * @task: target task |
| 1851 | * @hierarchy_id: the hierarchy to look up @task's cgroup from | ||
| 1852 | * @buf: the buffer to write the path into | 1851 | * @buf: the buffer to write the path into |
| 1853 | * @buflen: the length of the buffer | 1852 | * @buflen: the length of the buffer |
| 1854 | * | 1853 | * |
| 1855 | * Determine @task's cgroup on the hierarchy specified by @hierarchy_id and | 1854 | * Determine @task's cgroup on the first (the one with the lowest non-zero |
| 1856 | * copy its path into @buf. This function grabs cgroup_mutex and shouldn't | 1855 | * hierarchy_id) cgroup hierarchy and copy its path into @buf. This |
| 1857 | * be used inside locks used by cgroup controller callbacks. | 1856 | * function grabs cgroup_mutex and shouldn't be used inside locks used by |
| 1857 | * cgroup controller callbacks. | ||
| 1858 | * | ||
| 1859 | * Returns 0 on success, fails with -%ENAMETOOLONG if @buflen is too short. | ||
| 1858 | */ | 1860 | */ |
| 1859 | int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, | 1861 | int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen) |
| 1860 | char *buf, size_t buflen) | ||
| 1861 | { | 1862 | { |
| 1862 | struct cgroupfs_root *root; | 1863 | struct cgroupfs_root *root; |
| 1863 | struct cgroup *cgrp = NULL; | 1864 | struct cgroup *cgrp; |
| 1864 | int ret = -ENOENT; | 1865 | int hierarchy_id = 1, ret = 0; |
| 1866 | |||
| 1867 | if (buflen < 2) | ||
| 1868 | return -ENAMETOOLONG; | ||
| 1865 | 1869 | ||
| 1866 | mutex_lock(&cgroup_mutex); | 1870 | mutex_lock(&cgroup_mutex); |
| 1867 | 1871 | ||
| 1868 | root = idr_find(&cgroup_hierarchy_idr, hierarchy_id); | 1872 | root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id); |
| 1873 | |||
| 1869 | if (root) { | 1874 | if (root) { |
| 1870 | cgrp = task_cgroup_from_root(task, root); | 1875 | cgrp = task_cgroup_from_root(task, root); |
| 1871 | ret = cgroup_path(cgrp, buf, buflen); | 1876 | ret = cgroup_path(cgrp, buf, buflen); |
| 1877 | } else { | ||
| 1878 | /* if no hierarchy exists, everyone is in "/" */ | ||
| 1879 | memcpy(buf, "/", 2); | ||
| 1872 | } | 1880 | } |
| 1873 | 1881 | ||
| 1874 | mutex_unlock(&cgroup_mutex); | 1882 | mutex_unlock(&cgroup_mutex); |
| 1875 | |||
| 1876 | return ret; | 1883 | return ret; |
| 1877 | } | 1884 | } |
| 1878 | EXPORT_SYMBOL_GPL(task_cgroup_path_from_hierarchy); | 1885 | EXPORT_SYMBOL_GPL(task_cgroup_path); |
| 1879 | 1886 | ||
| 1880 | /* | 1887 | /* |
| 1881 | * Control Group taskset | 1888 | * Control Group taskset |
