← Commit list

e8cb0a1d1

Denys Vlasenko
Denys Vlasenko
2026-09-28
SUCCESS Duration: 298s

Subject

fdisk: util-linux compat wrt meaning of -u

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

testsuite/fdisk.tests+3 -4
@@ -7,11 +7,10 @@
# testing "description" "command" "result" "infile" "stdin"
-# We require -u for this test to disable use of incorrectly guessed
+# With -u (use cyinder units) this wouldn't work: incorrectly guessed
# sectors-per-track (15, should be 16).
-# utili-linux 2.41.1 does not - did they change the default?
-testing 'fdisk -u fdisk_8k_parts1_5-11_ext14.raw add primary' \
- 'fdisk -u fdisk_8k_parts1_5-11_ext14.raw 2>&1' \
+testing 'fdisk fdisk_8k_parts1_5-11_ext14.raw add primary' \
+ 'fdisk fdisk_8k_parts1_5-11_ext14.raw 2>&1' \
"\
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
util-linux/fdisk.c+9 -5
@@ -80,8 +80,8 @@
//usage: "[-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] [-t PARTTYPE] DISK"
//usage:#define fdisk_full_usage "\n\n"
//usage: IF_FEATURE_FDISK_WRITABLE("Change")IF_NOT_FEATURE_FDISK_WRITABLE("Show")" partition table\n"
-//usage: "\n -u Start and End are in sectors (instead of cylinders)"
-//usage: "\n Also disable rounding of sizes to cylinders"
+//usage: "\n -u Start and End are in cylinders (instead of sectors)"
+//usage: "\n Also enable rounding of sizes to cylinders"
//usage: "\n -l Show partition table for each DISK and exit"
//usage: IF_FEATURE_FDISK_BLKSIZE(
//usage: "\n -s Show size in kb for each DISK and exit"
@@ -183,7 +183,12 @@ enum {
};
#define USER_SET_SECTOR_SIZE (option_mask32 & OPT_b)
#define NOWARN_OPT_ls (!ENABLE_FEATURE_FDISK_WRITABLE || (option_mask32 & (OPT_l|OPT_s)))
-#define DISPLAY_IN_CYL_UNITS (!(option_mask32 & OPT_u))
+// The meaning of -u was inverted in its meaning in util-linux by:
+// commit 0b1f769f281ac2feb21b8a52af3fe999922c8833
+// Date: Tue Jun 15 13:13:05 2010 +0200
+// fdisk: disable DOS mode and cylinders by default
+// Now it also takes an optional parameter, "cylinder[s]"/"sector[s]" (we don't do that):
+#define DISPLAY_IN_CYL_UNITS (option_mask32 & OPT_u)
#define TOGGLE_DISPLAY_IN_CYL_UNITS (option_mask32 ^= OPT_u)
#define SUPPORT_DISKLABELS (0 \
@@ -1506,7 +1511,6 @@ choose_free_primary_partition(void)
return input_partition_number(/*warn*/ 0, 4);
}
-
static void
change_units(void)
{
@@ -2659,7 +2663,7 @@ menu(void)
puts("q\tquit without saving changes");
//deleted: puts("s\tcreate a new empty Sun disklabel"); /* sun */
puts("t\tchange a partition's system id");
- puts("u\tchange display/entry units");
+ printf("u\tchange display/entry units to %ss\n", DISPLAY_IN_CYL_UNITS ? "sector" : "cylinder");
puts("v\tverify partition table");
puts("w\twrite table to disk and exit");
# if ENABLE_FEATURE_FDISK_ADVANCED