From: Karel Zak Date: Thu, 10 Mar 2016 11:26:43 +0000 (+0100) Subject: sfdisk, fdisk: add fflush() X-Git-Tag: v2.28-rc1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95aae4fcee79958f56c77b934fcbb048ae25f6fb;p=thirdparty%2Futil-linux.git sfdisk, fdisk: add fflush() Let's add fflush(stdout) before we print to stderr to make output order more deterministic. Signed-off-by: Karel Zak --- diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 3aa915b2c0..3f8769d95c 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -367,12 +367,14 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask, fputs_info(ask, stdout); break; case FDISK_ASKTYPE_WARNX: + fflush(stdout); color_scheme_fenable("warn", UL_COLOR_RED, stderr); fputs(fdisk_ask_print_get_mesg(ask), stderr); color_fdisable(stderr); fputc('\n', stderr); break; case FDISK_ASKTYPE_WARN: + fflush(stdout); color_scheme_fenable("warn", UL_COLOR_RED, stderr); fputs(fdisk_ask_print_get_mesg(ask), stderr); errno = fdisk_ask_print_get_errno(ask); diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 3dfdd9e9a2..e39037e4ec 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -172,12 +172,14 @@ static int ask_callback(struct fdisk_context *cxt __attribute__((__unused__)), fputc('\n', stdout); break; case FDISK_ASKTYPE_WARNX: + fflush(stdout); color_scheme_fenable("warn", UL_COLOR_RED, stderr); fputs(fdisk_ask_print_get_mesg(ask), stderr); color_fdisable(stderr); fputc('\n', stderr); break; case FDISK_ASKTYPE_WARN: + fflush(stdout); color_scheme_fenable("warn", UL_COLOR_RED, stderr); fputs(fdisk_ask_print_get_mesg(ask), stderr); errno = fdisk_ask_print_get_errno(ask); diff --git a/tests/expected/sfdisk/dos-explicit-size b/tests/expected/sfdisk/dos-explicit-size index d88f0b6879..9d987bdeaf 100644 --- a/tests/expected/sfdisk/dos-explicit-size +++ b/tests/expected/sfdisk/dos-explicit-size @@ -1,10 +1,3 @@ -Partition 1 does not start on physical sector boundary. -Partition 2 does not start on physical sector boundary. -Partition 3 does not start on physical sector boundary. -Partition 4 does not start on physical sector boundary. -Partition 5 does not start on physical sector boundary. -Partition 6 does not start on physical sector boundary. -Partition 7 does not start on physical sector boundary. Checking that no-one is using this disk right now ... OK Disk : 50 MiB, 52428800 bytes, 102400 sectors @@ -33,6 +26,13 @@ Device Boot Start End Sectors Size Id Type 6 4003 5002 1000 500K 83 Linux 7 5004 102399 97396 47.6M 83 Linux +Partition 1 does not start on physical sector boundary. +Partition 2 does not start on physical sector boundary. +Partition 3 does not start on physical sector boundary. +Partition 4 does not start on physical sector boundary. +Partition 5 does not start on physical sector boundary. +Partition 6 does not start on physical sector boundary. +Partition 7 does not start on physical sector boundary. The partition table has been altered. Calling ioctl() to re-read partition table. diff --git a/tests/expected/sfdisk/dos-read-dump b/tests/expected/sfdisk/dos-read-dump index 1c00be647c..e5e9f71b98 100644 --- a/tests/expected/sfdisk/dos-read-dump +++ b/tests/expected/sfdisk/dos-read-dump @@ -1,5 +1,3 @@ -Partition 5 does not start on physical sector boundary. -Partition 6 does not start on physical sector boundary. Checking that no-one is using this disk right now ... OK Disk : 50 MiB, 52428800 bytes, 102400 sectors @@ -27,6 +25,8 @@ Device Boot Start End Sectors Size Id Type 5 20481 26624 6144 3M 83 Linux 6 26626 102399 75774 37M 83 Linux +Partition 5 does not start on physical sector boundary. +Partition 6 does not start on physical sector boundary. The partition table has been altered. Calling ioctl() to re-read partition table. diff --git a/tests/expected/sfdisk/gpt-list-pmbr b/tests/expected/sfdisk/gpt-list-pmbr index 2a1b140413..13a5e69f66 100644 --- a/tests/expected/sfdisk/gpt-list-pmbr +++ b/tests/expected/sfdisk/gpt-list-pmbr @@ -1,4 +1,3 @@ -Partition 1 does not start on physical sector boundary. Disk : 50 MiB, 52428800 bytes, 102400 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes @@ -9,3 +8,4 @@ Disk identifier: Device Boot Start End Sectors Size Id Type 1 1 102399 102399 50M ee GPT +Partition 1 does not start on physical sector boundary.