diff options
author | Mike Frysinger | 2007-07-14 19:32:37 +0200 |
---|---|---|
committer | Karel Zak | 2007-07-16 23:03:45 +0200 |
commit | cc2ce9454a150fc21fa2e73723b13f7dc287325a (patch) | |
tree | 0ca7b24d1261c151ced4e7c1d47a0bb7cc5b3147 /fdisk/fdisk.c | |
parent | schedutils: fix chrt docs and pid=0 usage (diff) | |
download | kernel-qcow2-util-linux-cc2ce9454a150fc21fa2e73723b13f7dc287325a.tar.gz kernel-qcow2-util-linux-cc2ce9454a150fc21fa2e73723b13f7dc287325a.tar.xz kernel-qcow2-util-linux-cc2ce9454a150fc21fa2e73723b13f7dc287325a.zip |
fdisk: check returns in fdisk from partition changes
currently the code in fdisk which changes partition types is a bit fragile ...
it assumes the partition type succeeded instead of checking the user input or
for errors. ive tweaked the sub functions to return a value indicative of the
functions' success and fdisk now checks/reports based on that.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r-- | fdisk/fdisk.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 5010d7db3..f2faa7fbc 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -1499,17 +1499,21 @@ change_sysid(void) { if (sys == origsys) break; if (sun_label) { - sun_change_sysid(i, sys); + ptes[i].changed = sun_change_sysid(i, sys); } else if (sgi_label) { - sgi_change_sysid(i, sys); - } else + ptes[i].changed = sgi_change_sysid(i, sys); + } else { p->sys_ind = sys; - printf (_("Changed system type of partition %d " - "to %x (%s)\n"), i + 1, sys, - (temp = partition_type(sys)) ? temp : - _("Unknown")); - ptes[i].changed = 1; + ptes[i].changed = 1; + } + temp = partition_type(sys) ? : _("Unknown"); + if (ptes[i].changed) + printf (_("Changed system type of partition %d " + "to %x (%s)\n"), i + 1, sys, temp); + else + printf (_("System type of partition %d is unchanged" + "to %x (%s)\n"), i + 1, sys, temp); if (is_dos_partition(origsys) || is_dos_partition(sys)) dos_changed = 1; |