- info = tsi2mdt_info(tsi);
- if (!mdt_hsm_is_admin(info))
- GOTO(out, rc = -EPERM);
+ archives_size = req_capsule_get_size(tsi->tsi_pill,
+ &RMF_MDS_HSM_ARCHIVE, RCL_CLIENT);
+
+ /* compatibility check for the old clients */
+ if (!exp_connect_archive_id_array(exp)) {
+ if (archives_size != sizeof(*archives))
+ GOTO(out, rc = err_serious(-EPROTO));
+
+ /* XXX: directly include this function here? */
+ rc = mdt_hsm_agent_register_mask(info,
+ &tsi->tsi_exp->exp_client_uuid,
+ *archives);
+ GOTO(out, rc);
+ }
+
+ if (archives_size % sizeof(*archives) != 0)
+ GOTO(out, rc = err_serious(-EPROTO));
+
+ archive_count = archives_size / sizeof(*archives);
+ if (archive_count == 1 && *archives == 0) {
+ archive_count = 0;
+ archives = NULL;
+ }
+
+ rc = mdt_hsm_agent_register(info, &tsi->tsi_exp->exp_client_uuid,
+ archive_count, archives);