return ret;
}
+static void cgroup_exit_cftypes(struct cftype *cfts)
+{
+ struct cftype *cft;
+
+ for (cft = cfts; cft->name[0] != '\0'; cft++)
+ cft->ss = NULL;
+}
+
+static void cgroup_init_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
+{
+ struct cftype *cft;
+
+ for (cft = cfts; cft->name[0] != '\0'; cft++)
+ cft->ss = ss;
+}
+
/**
* cgroup_add_cftypes - add an array of cftypes to a subsystem
* @ss: target cgroup subsystem
int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
{
struct cftype_set *set;
- struct cftype *cft;
int ret;
set = kzalloc(sizeof(*set), GFP_KERNEL);
if (!set)
return -ENOMEM;
- for (cft = cfts; cft->name[0] != '\0'; cft++)
- cft->ss = ss;
+ cgroup_init_cftypes(ss, cfts);
cgroup_cfts_prepare();
set->cfts = cfts;
*/
int cgroup_rm_cftypes(struct cftype *cfts)
{
+ struct cftype *found = NULL;
struct cftype_set *set;
if (!cfts || !cfts[0].ss)
if (set->cfts == cfts) {
list_del(&set->node);
kfree(set);
- cgroup_cfts_commit(cfts, false);
- return 0;
+ found = cfts;
+ break;
}
}
- cgroup_cfts_commit(NULL, false);
- return -ENOENT;
+ cgroup_cfts_commit(found, false);
+ cgroup_exit_cftypes(cfts);
+ return found ? 0 : -ENOENT;
}
/**
if (err)
return err;
+ cgroup_init_cftypes(NULL, cgroup_base_files);
+
for_each_subsys(ss, i) {
if (!ss->early_init)
cgroup_init_subsys(ss);