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 <kzak@redhat.com>
This commit is contained in:
Karel Zak 2016-03-10 12:26:43 +01:00
parent c59409b945
commit 95aae4fcee
5 changed files with 14 additions and 10 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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 <removed>: 50 MiB, 52428800 bytes, 102400 sectors
@ -33,6 +26,13 @@ Device Boot Start End Sectors Size Id Type
<removed>6 4003 5002 1000 500K 83 Linux
<removed>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.

View File

@ -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 <removed>: 50 MiB, 52428800 bytes, 102400 sectors
@ -27,6 +25,8 @@ Device Boot Start End Sectors Size Id Type
<removed>5 20481 26624 6144 3M 83 Linux
<removed>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.

View File

@ -1,4 +1,3 @@
Partition 1 does not start on physical sector boundary.
Disk <removed>: 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: <removed>
Device Boot Start End Sectors Size Id Type
<removed>1 1 102399 102399 50M ee GPT
Partition 1 does not start on physical sector boundary.