The function fdisk_reorder_partitions() is also used in sfdisk and cfdisk
and these commands assume info/warn messages from the library. So move all
messages from fdisk to fdisk_reorder_partitions().
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
break;
case 'f':
rc = fdisk_reorder_partitions(cxt);
- switch (rc) {
- default:
- fdisk_warnx(cxt, _("Failed to fix partitions order."));
- break;
- case 0:
- fdisk_info(cxt, _("Partitions order fixed."));
- break;
- case 1:
- fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
- break;
- }
break;
case 'r':
rc = fdisk_enable_details(cxt, 0);
*/
int fdisk_reorder_partitions(struct fdisk_context *cxt)
{
+ int rc;
+
if (!cxt || !cxt->label)
return -EINVAL;
if (!cxt->label->op->reorder)
return -ENOSYS;
- return cxt->label->op->reorder(cxt);
+ rc = cxt->label->op->reorder(cxt);
+
+ switch (rc) {
+ case 0:
+ fdisk_info(cxt, _("Partitions order fixed."));
+ break;
+ case 1:
+ fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
+ break;
+ default:
+ fdisk_warnx(cxt, _("Failed to fix partitions order."));
+ break;
+ }
+
+ return rc;
}
/*