diff options
-rw-r--r-- | fdisks/fdisk.c | 10 | ||||
-rw-r--r-- | fdisks/fdiskdoslabel.c | 42 | ||||
-rw-r--r-- | libfdisk/src/label.c | 9 |
3 files changed, 29 insertions, 32 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 1ac4dd9b7..60c69d1f3 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -149,16 +149,6 @@ void list_partition_types(struct fdisk_context *cxt) putchar('\n'); } -int warn_geometry(struct fdisk_context *cxt) -{ - if (fdisk_missing_geometry(cxt)) { - fdisk_warnx(cxt, _("Incomplete geometry setting. You can do " - "this from the extra functions menu.")); - return 1; - } - return 0; -} - void toggle_dos_compatibility_flag(struct fdisk_context *cxt) { struct fdisk_label *lb = fdisk_context_get_label(cxt, "dos"); diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c index 934312b6c..7b1391786 100644 --- a/fdisks/fdiskdoslabel.c +++ b/fdisks/fdiskdoslabel.c @@ -145,24 +145,6 @@ static int is_cleared_partition(struct dos_partition *p) dos_partition_get_start(p) || dos_partition_get_size(p)); } -static void warn_alignment(struct fdisk_context *cxt) -{ - if (fdisk_context_listonly(cxt)) - return; - - if (cxt->sector_size != cxt->phy_sector_size) - fdisk_info(cxt, _( -"The device presents a logical sector size that is smaller than " -"the physical sector size. Aligning to a physical sector (or optimal " -"I/O) size boundary is recommended, or performance may be impacted.")); - - if (is_dos_compatible(cxt)) - fdisk_warnx(cxt, _("DOS-compatible mode is deprecated.")); - - if (fdisk_context_use_cylinders(cxt)) - fdisk_warnx(cxt, _("Cylinders as display units are deprecated.")); - -} static int get_partition_unused_primary(struct fdisk_context *cxt) { @@ -266,10 +248,28 @@ static void dos_init(struct fdisk_context *cxt) pe->changed = 0; } - warn_geometry(cxt); - warn_alignment(cxt); + if (fdisk_context_listonly(cxt)) + return; + /* + * Various warnings... + */ + if (fdisk_missing_geometry(cxt)) + fdisk_warnx(cxt, _("You can set geometry from the extra functions menu.")); + + if (is_dos_compatible(cxt)) { + fdisk_warnx(cxt, _("DOS-compatible mode is deprecated.")); + + if (cxt->sector_size != cxt->phy_sector_size) + fdisk_info(cxt, _( + "The device presents a logical sector size that is smaller than " + "the physical sector size. Aligning to a physical sector (or optimal " + "I/O) size boundary is recommended, or performance may be impacted.")); + } + + if (fdisk_context_use_cylinders(cxt)) + fdisk_warnx(cxt, _("Cylinders as display units are deprecated.")); - if (cxt->total_sectors > UINT_MAX && !fdisk_context_listonly(cxt)) { + if (cxt->total_sectors > UINT_MAX) { unsigned long long bytes = cxt->total_sectors * cxt->sector_size; int giga = bytes / 1000000000; int hectogiga = (giga + 50) / 100; diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c index f7631811d..bae968480 100644 --- a/libfdisk/src/label.c +++ b/libfdisk/src/label.c @@ -90,12 +90,19 @@ int fdisk_require_geometry(struct fdisk_context *cxt) int fdisk_missing_geometry(struct fdisk_context *cxt) { + int rc; + assert(cxt); assert(cxt->label); - return (fdisk_require_geometry(cxt) && + rc = (fdisk_require_geometry(cxt) && (!cxt->geom.heads || !cxt->geom.sectors || !cxt->geom.cylinders)); + + if (rc && !fdisk_context_listonly(cxt)) + fdisk_warnx(cxt, _("Incomplete geometry setting.")); + + return rc; } /** |