if (!sf->quiet)
fputs(_("Checking that no-one is using this disk right now ..."), stdout);
if (is_device_used(sf)) {
- fputs(_(" FAILED\n\n"), stdout);
+ if (!sf->quiet)
+ fputs(_(" FAILED\n\n"), stdout);
fdisk_warnx(sf->cxt, _(
"This disk is currently in use - repartitioning is probably a bad idea.\n"
if (!sf->force)
errx(EXIT_FAILURE, _("Use the --force flag to overrule all checks."));
- } else
+ } else if (!sf->quiet)
fputs(_(" OK\n\n"), stdout);
}
goto done;
}
+ /* Be paranoid and check agains on-disk setting rather than against libfdisk cxt */
+ if (user_l > le64_to_cpu(pheader->last_usable_lba)) {
+ fdisk_warnx(cxt, _("The last usable GPT sector is %ju, but %ju is requested."),
+ le64_to_cpu(pheader->last_usable_lba), user_l);
+ rc = -EINVAL;
+ goto done;
+ }
+
+ if (user_f < le64_to_cpu(pheader->first_usable_lba)) {
+ fdisk_warnx(cxt, _("The first usable GPT sector is %ju, but %ju is requested."),
+ le64_to_cpu(pheader->first_usable_lba), user_f);
+ rc = -EINVAL;
+ goto done;
+ }
+
assert(!FDISK_IS_UNDEF(user_l));
assert(!FDISK_IS_UNDEF(user_f));