Let's print number of detected errors or "No errors detected." for
MBR. We already use the same for GPT.
The patch also modifies fdisk_verify_disklabel() return code to inform
caller about number of issues.
Addresses: https://github.com/karelzak/util-linux/issues/1051
Signed-off-by: Karel Zak <kzak@redhat.com>
last[cxt->label->nparts_max];
struct dos_partition *p;
struct fdisk_dos_label *l = self_label(cxt);
last[cxt->label->nparts_max];
struct dos_partition *p;
struct fdisk_dos_label *l = self_label(cxt);
assert(fdisk_is_label(cxt, DOS));
assert(fdisk_is_label(cxt, DOS));
if (p && is_used_partition(p) && !IS_EXTENDED(p->sys_ind)) {
check_consistency(cxt, p, i);
assert(pe);
if (p && is_used_partition(p) && !IS_EXTENDED(p->sys_ind)) {
check_consistency(cxt, p, i);
assert(pe);
- if (get_abs_partition_start(pe) < first[i])
+ if (get_abs_partition_start(pe) < first[i]) {
fdisk_warnx(cxt, _(
"Partition %zu: bad start-of-data."),
i + 1);
fdisk_warnx(cxt, _(
"Partition %zu: bad start-of-data."),
i + 1);
check(cxt, i + 1, p->eh, p->es, p->ec, last[i]);
total += last[i] + 1 - first[i];
check(cxt, i + 1, p->eh, p->es, p->ec, last[i]);
total += last[i] + 1 - first[i];
fdisk_warnx(cxt, _("Partition %zu: "
"overlaps partition %zu."),
j + 1, i + 1);
fdisk_warnx(cxt, _("Partition %zu: "
"overlaps partition %zu."),
j + 1, i + 1);
total += first[i] >= first[j] ?
first[i] : first[j];
total += first[i] >= first[j] ?
first[i] : first[j];
assert(p);
if (!p->sys_ind) {
assert(p);
if (!p->sys_ind) {
- if (i != 4 || i + 1 < cxt->label->nparts_max)
+ if (i != 4 || i + 1 < cxt->label->nparts_max) {
fdisk_warnx(cxt,
_("Partition %zu: empty."),
i + 1);
fdisk_warnx(cxt,
_("Partition %zu: empty."),
i + 1);
} else if (first[i] < l->ext_offset
|| last[i] > e_last) {
fdisk_warnx(cxt, _("Logical partition %zu: "
"not entirely in partition %zu."),
i + 1, l->ext_index + 1);
} else if (first[i] < l->ext_offset
|| last[i] > e_last) {
fdisk_warnx(cxt, _("Logical partition %zu: "
"not entirely in partition %zu."),
i + 1, l->ext_index + 1);
- if (total > n_sectors)
- fdisk_warnx(cxt, _("Total allocated sectors %llu greater "
- "than the maximum %llu."), total, n_sectors);
- else if (total < n_sectors)
- fdisk_warnx(cxt, _("Remaining %lld unallocated %ld-byte "
- "sectors."), n_sectors - total, cxt->sector_size);
+ if (!nerrors) {
+ fdisk_info(cxt, _("No errors detected."));
+ if (total > n_sectors)
+ fdisk_info(cxt, _("Total allocated sectors %llu greater "
+ "than the maximum %llu."), total, n_sectors);
+ else if (total < n_sectors)
+ fdisk_info(cxt, _("Remaining %lld unallocated %ld-byte "
+ "sectors."), n_sectors - total, cxt->sector_size);
+ } else
+ fdisk_warnx(cxt,
+ P_("%d error detected.", "%d errors detected.", nerrors),
+ nerrors);
P_("%d error detected.", "%d errors detected.", nerror),
nerror);
P_("%d error detected.", "%d errors detected.", nerror),
nerror);
}
/* Delete a single GPT partition, specified by partnum. */
}
/* Delete a single GPT partition, specified by partnum. */
*
* Verifies the partition table.
*
*
* Verifies the partition table.
*
- * Returns: 0 on success, otherwise, a corresponding error.
+ * Returns: 0 on success, <1 runtime or option errors, >0 number of detected issues
*/
int fdisk_verify_disklabel(struct fdisk_context *cxt)
{
*/
int fdisk_verify_disklabel(struct fdisk_context *cxt)
{