aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/cgroup.c90
1 files changed, 60 insertions, 30 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 4b218a46ddd3..3e6517e51fd3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1074,7 +1074,8 @@ struct cgroup_sb_opts {
1074 */ 1074 */
1075static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) 1075static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1076{ 1076{
1077 char *token, *o = data ?: "all"; 1077 char *token, *o = data;
1078 bool all_ss = false, one_ss = false;
1078 unsigned long mask = (unsigned long)-1; 1079 unsigned long mask = (unsigned long)-1;
1079 int i; 1080 int i;
1080 bool module_pin_failed = false; 1081 bool module_pin_failed = false;
@@ -1090,24 +1091,27 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1090 while ((token = strsep(&o, ",")) != NULL) { 1091 while ((token = strsep(&o, ",")) != NULL) {
1091 if (!*token) 1092 if (!*token)
1092 return -EINVAL; 1093 return -EINVAL;
1093 if (!strcmp(token, "all")) { 1094 if (!strcmp(token, "none")) {
1094 /* Add all non-disabled subsystems */
1095 opts->subsys_bits = 0;
1096 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
1097 struct cgroup_subsys *ss = subsys[i];
1098 if (ss == NULL)
1099 continue;
1100 if (!ss->disabled)
1101 opts->subsys_bits |= 1ul << i;
1102 }
1103 } else if (!strcmp(token, "none")) {
1104 /* Explicitly have no subsystems */ 1095 /* Explicitly have no subsystems */
1105 opts->none = true; 1096 opts->none = true;
1106 } else if (!strcmp(token, "noprefix")) { 1097 continue;
1098 }
1099 if (!strcmp(token, "all")) {
1100 /* Mutually exclusive option 'all' + subsystem name */
1101 if (one_ss)
1102 return -EINVAL;
1103 all_ss = true;
1104 continue;
1105 }
1106 if (!strcmp(token, "noprefix")) {
1107 set_bit(ROOT_NOPREFIX, &opts->flags); 1107 set_bit(ROOT_NOPREFIX, &opts->flags);
1108 } else if (!strcmp(token, "clone_children")) { 1108 continue;
1109 }
1110 if (!strcmp(token, "clone_children")) {
1109 opts->clone_children = true; 1111 opts->clone_children = true;
1110 } else if (!strncmp(token, "release_agent=", 14)) { 1112 continue;
1113 }
1114 if (!strncmp(token, "release_agent=", 14)) {
1111 /* Specifying two release agents is forbidden */ 1115 /* Specifying two release agents is forbidden */
1112 if (opts->release_agent) 1116 if (opts->release_agent)
1113 return -EINVAL; 1117 return -EINVAL;
@@ -1115,7 +1119,9 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1115 kstrndup(token + 14, PATH_MAX - 1, GFP_KERNEL); 1119 kstrndup(token + 14, PATH_MAX - 1, GFP_KERNEL);
1116 if (!opts->release_agent) 1120 if (!opts->release_agent)
1117 return -ENOMEM; 1121 return -ENOMEM;
1118 } else if (!strncmp(token, "name=", 5)) { 1122 continue;
1123 }
1124 if (!strncmp(token, "name=", 5)) {
1119 const char *name = token + 5; 1125 const char *name = token + 5;
1120 /* Can't specify an empty name */ 1126 /* Can't specify an empty name */
1121 if (!strlen(name)) 1127 if (!strlen(name))
@@ -1137,20 +1143,44 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
1137 GFP_KERNEL); 1143 GFP_KERNEL);
1138 if (!opts->name) 1144 if (!opts->name)
1139 return -ENOMEM; 1145 return -ENOMEM;
1140 } else { 1146
1141 struct cgroup_subsys *ss; 1147 continue;
1142 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 1148 }
1143 ss = subsys[i]; 1149
1144 if (ss == NULL) 1150 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
1145 continue; 1151 struct cgroup_subsys *ss = subsys[i];
1146 if (!strcmp(token, ss->name)) { 1152 if (ss == NULL)
1147 if (!ss->disabled) 1153 continue;
1148 set_bit(i, &opts->subsys_bits); 1154 if (strcmp(token, ss->name))
1149 break; 1155 continue;
1150 } 1156 if (ss->disabled)
1151 } 1157 continue;
1152 if (i == CGROUP_SUBSYS_COUNT) 1158
1153 return -ENOENT; 1159 /* Mutually exclusive option 'all' + subsystem name */
1160 if (all_ss)
1161 return -EINVAL;
1162 set_bit(i, &opts->subsys_bits);
1163 one_ss = true;
1164
1165 break;
1166 }
1167 if (i == CGROUP_SUBSYS_COUNT)
1168 return -ENOENT;
1169 }
1170
1171 /*
1172 * If the 'all' option was specified select all the subsystems,
1173 * otherwise 'all, 'none' and a subsystem name options were not
1174 * specified, let's default to 'all'
1175 */
1176 if (all_ss || (!all_ss && !one_ss && !opts->none)) {
1177 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
1178 struct cgroup_subsys *ss = subsys[i];
1179 if (ss == NULL)
1180 continue;
1181 if (ss->disabled)
1182 continue;
1183 set_bit(i, &opts->subsys_bits);
1154 } 1184 }
1155 } 1185 }
1156 1186