+static int action_luksRepair(int arg __attribute__((unused)))
+{
+ struct crypt_device *cd = NULL;
+ int r;
+
+ if ((r = crypt_init(&cd, action_argv[0])))
+ goto out;
+
+ /* Currently only LUKS1 allows repair */
+ crypt_set_log_callback(cd, _quiet_log, NULL);
+ r = crypt_load(cd, CRYPT_LUKS1, NULL);
+ crypt_set_log_callback(cd, _log, NULL);
+ if (r == 0) {
+ log_verbose( _("No known problems detected for LUKS header.\n"));
+ goto out;
+ }
+
+ r = _yesDialog(_("Really try to repair LUKS device header?"),
+ NULL) ? 0 : -EINVAL;
+ if (r == 0)
+ r = crypt_repair(cd, CRYPT_LUKS1, NULL);
+out:
+ crypt_free(cd);
+ return r;
+}
+