[PATCH 21/28] cgroupfs: create /sys/fs/cgroup to mount cgroupfs on

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg Kroah-Hartman
Date: Thursday, August 5, 2010 - 3:24 pm

From: Greg KH <gregkh@suse.de>

We really shouldn't be asking userspace to create new root filesystems.
So follow along with all of the other in-kernel filesystems, and provide
a mount point in sysfs.

For cgroupfs, this should be in /sys/fs/cgroup/  This change provides
that mount point when the cgroup filesystem is registered in the kernel.

Acked-by: Paul Menage <menage@google.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 kernel/cgroup.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a8ce099..d83cab0 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1623,6 +1623,8 @@ static struct file_system_type cgroup_fs_type = {
 	.kill_sb = cgroup_kill_sb,
 };
 
+static struct kobject *cgroup_kobj;
+
 static inline struct cgroup *__d_cgrp(struct dentry *dentry)
 {
 	return dentry->d_fsdata;
@@ -3894,9 +3896,18 @@ int __init cgroup_init(void)
 	hhead = css_set_hash(init_css_set.subsys);
 	hlist_add_head(&init_css_set.hlist, hhead);
 	BUG_ON(!init_root_id(&rootnode));
+
+	cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
+	if (!cgroup_kobj) {
+		err = -ENOMEM;
+		goto out;
+	}
+
 	err = register_filesystem(&cgroup_fs_type);
-	if (err < 0)
+	if (err < 0) {
+		kobject_put(cgroup_kobj);
 		goto out;
+	}
 
 	proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);
 
-- 
1.7.2

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PATCH] driver core patches for .36, Greg KH, (Thu Aug 5, 2:33 pm)
[PATCH 01/28] uio: Remove IRQF_DISABLED flag from uio_pdrv ..., Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 02/28] uio: Remove IRQF_DISABLED from uio_sercos3.c, Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 03/28] uio: Remove IRQF_DISABLED flag from uio_cif.c, Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 04/28] hotplug: Support kernel/hotplug sysctl varia ..., Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 05/28] Driver core: internal struct dma_coherent_me ..., Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 06/28] Driver core: Drop __must_check from bus_for_ ..., Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 07/28] firmware loader: use statically initialized ..., Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 08/28] firmware loader: embed device into firmware_ ..., Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 09/28] Driver core: use kmemdup in platform_device_ ..., Greg Kroah-Hartman, (Thu Aug 5, 3:23 pm)
[PATCH 10/28] Driver core: reduce duplicated code for plat ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 11/28] Driver core: move platform device creation h ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 12/28] firmware: Update hotplug script, Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 13/28] sysfs: sysfs_chmod_file's attr can be const, Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 14/28] dmi-id: fix a memory leak in dmi_id_init err ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 15/28] dcdbas: remove a redundant smi_data_buf_free ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 16/28] sysfs: fix discrepancies between implementat ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 17/28] sysfs: Fix one more signature discrepancy be ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 18/28] debugfs: no longer needs to depend on SYSFS, Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 19/28] driver core: fix memory leak on one error pa ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 20/28] Driver core: Add BUS_NOTIFY_BIND_DRIVER, Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 21/28] cgroupfs: create /sys/fs/cgroup to mount cgr ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 22/28] scsi: Remove owner field from attribute init ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 23/28] scsi: Remove owner field from attribute init ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 24/28] leds: Remove owner field from attribute init ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 25/28] regulator: Remove owner field from attribute ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 26/28] powerpc/pci: Remove owner field from attribu ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 27/28] sysfs: Remove owner field from sysfs struct ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)
[PATCH 28/28] driver core: device_rename's new_name can be ..., Greg Kroah-Hartman, (Thu Aug 5, 3:24 pm)