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>
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;
return (gap > 0) ? 1 : (gap == 0) ? 0 : -1;
}
-void
+int
sgi_change_sysid(int i, int sys)
{
if (sgi_get_num_sectors(i) == 0) /* caught already before, ... */ {
printf(_("Sorry You may change the Tag of non-empty partitions.\n"));
- return;
+ return 0;
}
if (((sys != ENTIRE_DISK) && (sys != SGI_VOLHDR))
&& (sgi_get_start_sector(i)<1)) {
"Only the \"SGI volume\" entire disk section may violate this.\n"
"Type YES if you are sure about tagging this partition differently.\n"));
if (strcmp (line_ptr, _("YES\n")))
- return;
+ return 0;
}
sgilabel->partitions[i].id = SSWAP32(sys);
+ return 1;
}
/* returns partition index of first entry marked as entire disk */
extern void sgi_nolabel( void );
extern int check_sgi_label( void );
extern void sgi_list_table( int xtra );
-extern void sgi_change_sysid( int i, int sys );
+extern int sgi_change_sysid( int i, int sys );
extern unsigned int sgi_get_start_sector( int i );
extern unsigned int sgi_get_num_sectors( int i );
extern int sgi_get_sysid( int i );
part->num_sectors = 0;
}
-void sun_change_sysid(int i, __u16 sys)
+int sun_change_sysid(int i, __u16 sys)
{
struct sun_partition *part = &sunlabel->partitions[i];
struct sun_tag_flag *tag = &sunlabel->part_tags[i];
"Type YES if you're very sure you would like that partition\n"
"tagged with 82 (Linux swap): "));
if (strcmp (line_ptr, _("YES\n")))
- return;
+ return 0;
}
switch (sys) {
case SUN_TAG_SWAP:
break;
}
tag->tag = SSWAP16(sys);
+ return 1;
}
void sun_list_table(int xtra)
extern void sun_nolabel(void);
extern void create_sunlabel(void);
extern void sun_delete_partition(int i);
-extern void sun_change_sysid(int i, __u16 sys);
+extern int sun_change_sysid(int i, __u16 sys);
extern void sun_list_table(int xtra);
extern void verify_sun(void);
extern void add_sun_partition(int n, int sys);