+ if (lcfg->lcfg_inllen1 <= 0 ||
+ lcfg->lcfg_inllen1 > sizeof(struct obd_uuid)) {
+ CERROR("invalid conn_uuid\n");
+ RETURN(-EINVAL);
+ }
+ if (lcfg->lcfg_inllen2 != sizeof(int)) {
+ CERROR("invalid priority\n");
+ RETURN(-EINVAL);
+ }
+ if (strcmp(obd->obd_type->typ_name, "mdc") &&
+ strcmp(obd->obd_type->typ_name, "osc")) {
+ CERROR("can't add connection on non-client dev\n");
+ RETURN(-EINVAL);
+ }
+
+ imp = obd->u.cli.cl_import;
+ if (!imp) {
+ CERROR("try to add conn on immature client dev\n");
+ RETURN(-EINVAL);
+ }
+
+ obd_str2uuid(&uuid, lcfg->lcfg_inlbuf1);
+ priority = *((int*) lcfg->lcfg_inlbuf2);
+ rc = obd_add_conn(imp, &uuid, priority);
+
+ RETURN(rc);
+}
+int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
+{
+ struct obd_import *imp;
+ struct obd_uuid uuid;
+ int rc;
+ ENTRY;
+
+ if (lcfg->lcfg_inllen1 <= 0 ||
+ lcfg->lcfg_inllen1 > sizeof(struct obd_uuid)) {
+ CERROR("invalid conn_uuid\n");
+ RETURN(-EINVAL);
+ }
+ if (strcmp(obd->obd_type->typ_name, "mdc") &&
+ strcmp(obd->obd_type->typ_name, "osc")) {
+ CERROR("can't add connection on non-client dev\n");
+ RETURN(-EINVAL);
+ }
+
+ imp = obd->u.cli.cl_import;
+ if (!imp) {
+ CERROR("try to del conn on immature client dev\n");
+ RETURN(-EINVAL);
+ }
+
+ obd_str2uuid(&uuid, lcfg->lcfg_inlbuf1);
+ rc = obd_del_conn(imp, &uuid);
+
+ RETURN(rc);