+ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
+ struct kobject *kobj)
+{
+ struct kobj_type *typ;
+ ssize_t count = 0;
+ int i;
+
+ if (lcfg->lcfg_command != LCFG_PARAM) {
+ CERROR("Unknown command: %d\n", lcfg->lcfg_command);
+ return -EINVAL;
+ }
+
+ typ = get_ktype(kobj);
+ if (!typ || !typ->default_attrs)
+ return -ENODEV;
+
+ print_lustre_cfg(lcfg);
+
+ /*
+ * e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt
+ * or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar
+ * or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36
+ */
+ for (i = 1; i < lcfg->lcfg_bufcount; i++) {
+ struct attribute *attr;
+ size_t keylen;
+ char *value;
+ char *key;
+ int j;
+
+ key = lustre_cfg_buf(lcfg, i);
+ /* Strip off prefix */
+ if (class_match_param(key, prefix, &key))
+ /* If the prefix doesn't match, return error so we
+ * can pass it down the stack
+ */
+ return -EINVAL;
+
+ value = strchr(key, '=');
+ if (!value || *(value + 1) == 0) {
+ CERROR("%s: can't parse param '%s' (missing '=')\n",
+ lustre_cfg_string(lcfg, 0),
+ lustre_cfg_string(lcfg, i));
+ /* continue parsing other params */
+ continue;
+ }
+ keylen = value - key;
+ value++;
+
+ attr = NULL;
+ for (j = 0; typ->default_attrs[j]; j++) {
+ if (!strncmp(typ->default_attrs[j]->name, key,
+ keylen)) {
+ attr = typ->default_attrs[j];
+ break;
+ }
+ }
+
+ if (!attr) {
+ char *envp[3];
+
+ envp[0] = kasprintf(GFP_KERNEL, "PARAM=%s.%s.%.*s",
+ kobject_name(kobj->parent),
+ kobject_name(kobj),
+ (int) keylen, key);
+ envp[1] = kasprintf(GFP_KERNEL, "SETTING=%s", value);
+ envp[2] = NULL;
+
+ if (kobject_uevent_env(kobj, KOBJ_CHANGE, envp)) {
+ CERROR("%s: failed to send uevent %s\n",
+ kobject_name(kobj), key);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(envp); i++)
+ kfree(envp[i]);
+ } else {
+ count += lustre_attr_store(kobj, attr, value,
+ strlen(value));
+ }
+ }
+ return count;
+}
+EXPORT_SYMBOL(class_modify_config);
+