+static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct obd_device *obd = class_name2obd(kobj->name);
+
+ return sprintf(buf, "%s\n", obd->obd_uuid.uuid);
+}
+LUSTRE_RO_ATTR(uuid);
+
+static struct attribute *server_uuid_attrs[] = {
+ &lustre_attr_uuid.attr,
+ NULL,
+};
+
+static struct attribute_group server_def_attr_group = {
+ .attrs = server_uuid_attrs,
+};
+
+void lprocfs_kset_unregister(struct obd_device *obd, struct kset *kset)
+{
+ if (obd->obd_proc_entry) {
+ lprocfs_remove(&obd->obd_proc_entry);
+ obd->obd_proc_entry = NULL;
+ }
+
+ if (kset)
+ kset_unregister(kset);
+}
+EXPORT_SYMBOL(lprocfs_kset_unregister);
+
+int lprocfs_kset_register(struct obd_device *obd, struct kset **kset)
+{
+ struct kset *obd_kset;
+ int rc = 0;
+
+ obd_kset = kset_create_and_add(obd->obd_name, NULL,
+ obd->obd_type->typ_kobj);
+ if (!obd_kset) {
+ CERROR("%s: cannot add new kset: rc = %d\n", obd->obd_name, rc);
+ rc = -ENOMEM;
+ }
+
+ if (!obd->obd_attrs)
+ obd->obd_attrs = &server_def_attr_group;
+
+ rc = sysfs_create_group(&obd_kset->kobj, obd->obd_attrs);
+ if (rc) {
+ CERROR("%s: cannot create attr group: rc = %d\n", obd->obd_name,
+ rc);
+ kset_unregister(obd_kset);
+ obd_kset = NULL;
+ return rc;
+ }
+
+ obd->obd_proc_entry = lprocfs_register(obd->obd_name,
+ obd->obd_type->typ_procroot,
+ obd->obd_vars, obd);
+ if (IS_ERR(obd->obd_proc_entry)) {
+ rc = PTR_ERR(obd->obd_proc_entry);
+ CERROR("%s: error %d setting up lprocfs\n", obd->obd_name, rc);
+ obd->obd_proc_entry = NULL;
+
+ kset_unregister(obd_kset);
+ obd_kset = NULL;
+ }
+ *kset = obd_kset;
+ return rc;
+}
+EXPORT_SYMBOL(lprocfs_kset_register);
+