]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: cleanup warning messages
authorKarel Zak <kzak@redhat.com>
Tue, 25 Jun 2013 14:57:56 +0000 (16:57 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:47:04 +0000 (16:47 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/fdisk.c
fdisks/fdiskdoslabel.c
libfdisk/src/label.c

index 1ac4dd9b7b0b8f9d283895747039c8d2be883ce2..60c69d1f38feb548b31c4c1ed33d477f92805a7b 100644 (file)
@@ -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");
index 934312b6ceb0268ec0e24f9b0824b29e61fffd8b..7b1391786b87cb60487b36a785d48e273a36ba78 100644 (file)
@@ -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;
index f7631811dc12a8f9398075dc1221a2f8b8169bb9..bae9684804b251c5510f51d0891bce5a1ceee8ad 100644 (file)
@@ -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;
 }
 
 /**