diff options
-rw-r--r-- | fdisks/fdisk.c | 41 | ||||
-rw-r--r-- | fdisks/fdisk.h | 12 | ||||
-rw-r--r-- | fdisks/fdiskbsdlabel.c | 27 | ||||
-rw-r--r-- | fdisks/fdiskdoslabel.c | 63 | ||||
-rw-r--r-- | fdisks/fdiskdoslabel.h | 3 | ||||
-rw-r--r-- | fdisks/fdisksgilabel.c | 34 | ||||
-rw-r--r-- | fdisks/fdisksunlabel.c | 61 |
7 files changed, 120 insertions, 121 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 02b32402f..937996368 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -118,6 +118,18 @@ int nowarn = 0; /* no warnings for fdisk -l/-s */ unsigned int user_cylinders, user_heads, user_sectors; +void toggle_units(struct fdisk_context *cxt) +{ + fdisk_context_set_unit(cxt, + fdisk_context_use_cylinders(cxt) ? "sectors" : + "cylinders"); + if (fdisk_context_use_cylinders(cxt)) + fdisk_info(cxt, _("Changing display/entry units to cylinders (DEPRECATED!).")); + else + fdisk_info(cxt, _("Changing display/entry units to sectors.")); +} + + static void __attribute__ ((__noreturn__)) usage(FILE *out) { fprintf(out, _("Usage:\n" @@ -442,7 +454,7 @@ read_int_with_suffix(struct fdisk_context *cxt, /* * Cylinders */ - if (!display_in_cyl_units) + if (fdisk_context_use_cylinders(cxt)) res *= cxt->geom.heads * cxt->geom.sectors; } else if (*line_ptr && *(line_ptr + 1) == 'B' && @@ -486,7 +498,7 @@ read_int_with_suffix(struct fdisk_context *cxt, unsigned long unit; bytes = (unsigned long long) res * absolute; - unit = cxt->sector_size * units_per_sector; + unit = cxt->sector_size * fdisk_context_get_units_per_sector(cxt); bytes += unit/2; /* round */ bytes /= unit; res = bytes; @@ -590,14 +602,6 @@ not_unique: return get_partition(cxt, warn, max); } -const char * -str_units(int n) -{ - if (display_in_cyl_units) - return P_("cylinder", "cylinders", n); - return P_("sector", "sectors", n); -} - static void toggle_dos_compatibility_flag(struct fdisk_context *cxt) { struct fdisk_label *lb = fdisk_context_get_label(cxt, "dos"); @@ -687,8 +691,10 @@ list_disk_geometry(struct fdisk_context *cxt) { printf(_("%d heads, %llu sectors/track, %llu cylinders\n"), cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders); printf(_("Units = %s of %d * %ld = %ld bytes\n"), - str_units(PLURAL), - units_per_sector, cxt->sector_size, units_per_sector * cxt->sector_size); + fdisk_context_get_unit(cxt, PLURAL), + fdisk_context_get_units_per_sector(cxt), + cxt->sector_size, + fdisk_context_get_units_per_sector(cxt) * cxt->sector_size); printf(_("Sector size (logical/physical): %lu bytes / %lu bytes\n"), cxt->sector_size, cxt->phy_sector_size); @@ -981,7 +987,6 @@ static void print_partition_table_from_option(struct fdisk_context *cxt, /* * Try BSD -- TODO: move to list_table() too */ - update_units(cxt); list_disk_geometry(cxt); if (!fdisk_is_disklabel(cxt, AIX) && !fdisk_is_disklabel(cxt, MAC)) @@ -1145,7 +1150,7 @@ static void command_prompt(struct fdisk_context *cxt) change_partition_type(cxt); break; case 'u': - change_units(cxt); + toggle_units(cxt); break; case 'v': verify(cxt); @@ -1243,10 +1248,9 @@ int main(int argc, char **argv) opts = 1; break; case 'u': - display_in_cyl_units = 0; /* default */ - if (optarg && strcmp(optarg, "=cylinders") == 0) - display_in_cyl_units = !display_in_cyl_units; - else if (optarg && strcmp(optarg, "=sectors")) + if (optarg && *optarg == '=') + optarg++; + if (fdisk_context_set_unit(cxt, optarg) != 0) usage(stderr); break; case 'V': @@ -1307,7 +1311,6 @@ int main(int argc, char **argv) print_welcome(); if (!fdisk_dev_has_disklabel(cxt)) { - update_units(cxt); /* to provide compatible 'p'rint output */ fprintf(stderr, _("Device does not contain a recognized partition table\n")); fdisk_create_disklabel(cxt, NULL); diff --git a/fdisks/fdisk.h b/fdisks/fdisk.h index 627b0d91f..378f17dd3 100644 --- a/fdisks/fdisk.h +++ b/fdisks/fdisk.h @@ -32,8 +32,14 @@ #define IS_EXTENDED(i) \ ((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED) -#define cround(n) (display_in_cyl_units ? ((n)/units_per_sector)+1 : (n)) -#define scround(x) (((x)+units_per_sector-1)/units_per_sector) +extern void toggle_units(struct fdisk_context *cxt); + +static inline unsigned long +scround(struct fdisk_context *cxt, unsigned long num) +{ + unsigned long un = fdisk_context_get_units_per_sector(cxt); + return (num + un - 1) / un; +} struct partition { unsigned char boot_ind; /* 0x80 - active */ @@ -66,7 +72,6 @@ extern int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask, /* prototypes for fdisk.c */ extern char *line_ptr; -extern unsigned int display_in_cyl_units, units_per_sector; extern void fatal(struct fdisk_context *cxt, enum failure why); extern int get_partition(struct fdisk_context *cxt, int warn, int max); @@ -93,7 +98,6 @@ extern int get_partition_dflt(struct fdisk_context *cxt, int warn, int max, int #define PLURAL 0 #define SINGULAR 1 -extern const char * str_units(int); extern sector_t get_nr_sects(struct partition *p); diff --git a/fdisks/fdiskbsdlabel.c b/fdisks/fdiskbsdlabel.c index 060852bc3..69c807c36 100644 --- a/fdisks/fdiskbsdlabel.c +++ b/fdisks/fdiskbsdlabel.c @@ -105,8 +105,8 @@ static char disklabelbuffer[BSD_BBSIZE]; static struct xbsd_disklabel xbsd_dlabel; -#define bsd_cround(n) \ - (display_in_cyl_units ? ((n)/xbsd_dlabel.d_secpercyl) + 1 : (n)) +#define bsd_cround(c, n) \ + (fdisk_context_use_cylinders(c) ? ((n)/xbsd_dlabel.d_secpercyl) + 1 : (n)) /* * Test whether the whole disk has BSD disk label magic. @@ -190,19 +190,24 @@ static int xbsd_add_part (struct fdisk_context *cxt, end = xbsd_dlabel.d_secperunit - 1; #endif - snprintf (mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); - begin = read_int(cxt, bsd_cround (begin), bsd_cround (begin), bsd_cround (end), + snprintf (mesg, sizeof(mesg), _("First %s"), + fdisk_context_get_unit(cxt, SINGULAR)); + begin = read_int(cxt, bsd_cround (cxt, begin), + bsd_cround (cxt, begin), + bsd_cround (cxt, end), 0, mesg); - if (display_in_cyl_units) + if (fdisk_context_use_cylinders(cxt)) begin = (begin - 1) * xbsd_dlabel.d_secpercyl; snprintf (mesg, sizeof(mesg), _("Last %s or +size or +sizeM or +sizeK"), - str_units(SINGULAR)); - end = read_int (cxt, bsd_cround (begin), bsd_cround (end), bsd_cround (end), - bsd_cround (begin), mesg); + fdisk_context_get_unit(cxt, SINGULAR)); + end = read_int (cxt, bsd_cround (cxt, begin), + bsd_cround (cxt, end), + bsd_cround (cxt, end), + bsd_cround (cxt, begin), mesg); - if (display_in_cyl_units) + if (fdisk_context_use_cylinders(cxt)) end = end * xbsd_dlabel.d_secpercyl - 1; xbsd_dlabel.d_partitions[i].p_size = end - begin + 1; @@ -325,7 +330,7 @@ bsd_command_prompt (struct fdisk_context *cxt) xbsd_change_fstype (cxt); break; case 'u': - change_units(cxt); + toggle_units(cxt); break; case 'w': xbsd_write_disklabel (cxt); @@ -419,7 +424,7 @@ xbsd_print_disklabel (struct fdisk_context *cxt, int show_all) pp = lp->d_partitions; for (i = 0; i < lp->d_npartitions; i++, pp++) { if (pp->p_size) { - if (display_in_cyl_units && lp->d_secpercyl) { + if (fdisk_context_use_cylinders(cxt) && lp->d_secpercyl) { fprintf(f, " %c: %8ld%c %8ld%c %8ld%c ", 'a' + i, (long) pp->p_offset / lp->d_secpercyl + 1, diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c index a65466bac..1481ca2ff 100644 --- a/fdisks/fdiskdoslabel.c +++ b/fdisks/fdiskdoslabel.c @@ -50,31 +50,10 @@ sector_t extended_offset; static size_t ext_index; -unsigned int units_per_sector = 1, display_in_cyl_units = 0; - static int MBRbuffer_changed; -void update_units(struct fdisk_context *cxt) -{ - int cyl_units = cxt->geom.heads * cxt->geom.sectors; - - if (display_in_cyl_units && cyl_units) - units_per_sector = cyl_units; - else - units_per_sector = 1; /* in sectors */ -} - -void change_units(struct fdisk_context *cxt) -{ - display_in_cyl_units = !display_in_cyl_units; - update_units(cxt); - - if (display_in_cyl_units) - printf(_("Changing display/entry units to cylinders (DEPRECATED!)\n")); - else - printf(_("Changing display/entry units to sectors\n")); -} - +#define cround(c, n) (fdisk_context_use_cylinders(c) ? \ + ((n) / fdisk_context_get_units_per_sector(c)) + 1 : (n)) static void warn_alignment(struct fdisk_context *cxt) { @@ -92,7 +71,7 @@ static void warn_alignment(struct fdisk_context *cxt) "WARNING: DOS-compatible mode is deprecated. It's strongly recommended to\n" " switch off the mode (with command 'c').")); - if (display_in_cyl_units) + if (fdisk_context_use_cylinders(cxt)) fprintf(stderr, _("\n" "WARNING: cylinders as display units are deprecated. Use command 'u' to\n" " change units to sectors.\n")); @@ -453,8 +432,6 @@ static int dos_reset_alignment(struct fdisk_context *cxt) cxt->grain = cxt->sector_size; /* usually 512 */ } - /* units_per_sector has impact to deprecated DOS stuff */ - update_units(cxt); return 0; } @@ -615,7 +592,7 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype fill_bounds(cxt, first, last); if (n < 4) { start = cxt->first_lba; - if (display_in_cyl_units || !cxt->total_sectors) + if (fdisk_context_use_cylinders(cxt) || !cxt->total_sectors) limit = cxt->geom.heads * cxt->geom.sectors * cxt->geom.cylinders - 1; else limit = cxt->total_sectors - 1; @@ -632,11 +609,11 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype start = extended_offset + cxt->first_lba; limit = get_start_sect(q) + get_nr_sects(q) - 1; } - if (display_in_cyl_units) + if (fdisk_context_use_cylinders(cxt)) for (i = 0; i < cxt->label->nparts_max; i++) - first[i] = (cround(first[i]) - 1) * units_per_sector; + first[i] = (cround(cxt, first[i]) - 1) * fdisk_context_get_units_per_sector(cxt); - snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), _("First %s"), fdisk_context_get_unit(cxt, SINGULAR)); do { sector_t dflt, aligned; @@ -653,7 +630,7 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype dflt = start; if (start > limit) break; - if (start >= temp+units_per_sector && read) { + if (start >= temp+fdisk_context_get_units_per_sector(cxt) && read) { printf(_("Sector %llu is already allocated\n"), temp); temp = start; read = 0; @@ -661,10 +638,11 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype if (!read && start == temp) { sector_t i = start; - start = read_int(cxt, cround(i), cround(dflt), cround(limit), + start = read_int(cxt, cround(cxt, i), cround(cxt, dflt), + cround(cxt, limit), 0, mesg); - if (display_in_cyl_units) { - start = (start - 1) * units_per_sector; + if (fdisk_context_use_cylinders(cxt)) { + start = (start - 1) * fdisk_context_get_units_per_sector(cxt); if (start < i) start = i; } read = 1; @@ -695,20 +673,21 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype cxt->label->nparts_max--; return -ENOSPC; } - if (cround(start) == cround(limit)) { + if (cround(cxt, start) == cround(cxt, limit)) { stop = limit; } else { int is_suffix_used = 0; snprintf(mesg, sizeof(mesg), _("Last %1$s, +%2$s or +size{K,M,G}"), - str_units(SINGULAR), str_units(PLURAL)); + fdisk_context_get_unit(cxt, SINGULAR), fdisk_context_get_unit(cxt, PLURAL)); stop = read_int_with_suffix(cxt, - cround(start), cround(limit), cround(limit), - cround(start), mesg, &is_suffix_used); - if (display_in_cyl_units) { - stop = stop * units_per_sector - 1; + cround(cxt, start), cround(cxt, limit), + cround(cxt, limit), + cround(cxt, start), mesg, &is_suffix_used); + if (fdisk_context_use_cylinders(cxt)) { + stop = stop * fdisk_context_get_units_per_sector(cxt) - 1; if (stop >limit) stop = limit; } @@ -1218,8 +1197,8 @@ int dos_list_table(struct fdisk_context *cxt, partname(cxt->dev_path, i+1, w+2), /* boot flag */ !p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG ? '*' : '?', -/* start */ (unsigned long) cround(get_partition_start(pe)), -/* end */ (unsigned long) cround(get_partition_start(pe) + psects +/* start */ (unsigned long) cround(cxt, get_partition_start(pe)), +/* end */ (unsigned long) cround(cxt, get_partition_start(pe) + psects - (psects ? 1 : 0)), /* odd flag on end */ (unsigned long) pblocks, podd ? '+' : ' ', /* type id */ p->sys_ind, diff --git a/fdisks/fdiskdoslabel.h b/fdisks/fdiskdoslabel.h index dfcf6d8d1..a997be820 100644 --- a/fdisks/fdiskdoslabel.h +++ b/fdisks/fdiskdoslabel.h @@ -55,9 +55,6 @@ extern void dos_toggle_active(struct fdisk_context *cxt, int i); extern int mbr_is_valid_magic(unsigned char *b); -extern void change_units(struct fdisk_context *cxt); -extern void update_units(struct fdisk_context *cxt); /* called from sunlabel too */ - #define is_dos_compatible(_x) \ (fdisk_is_disklabel(_x, DOS) && \ fdisk_dos_is_compatible(fdisk_context_get_label(_x, NULL))) diff --git a/fdisks/fdisksgilabel.c b/fdisks/fdisksgilabel.c index 904c016b9..58f7133b8 100644 --- a/fdisks/fdisksgilabel.c +++ b/fdisks/fdisksgilabel.c @@ -201,14 +201,16 @@ sgi_list_table(struct fdisk_context *cxt, int xtra) { SSWAP16(sgiparam.pcylcount), (int) sgiparam.sparecyl, SSWAP16(sgiparam.ilfact), (char *)sgilabel, - str_units(PLURAL), units_per_sector, + fdisk_context_get_unit(cxt, PLURAL), + fdisk_context_get_units_per_sector(cxt), cxt->sector_size); } else { printf(_("\nDisk %s (SGI disk label): " "%d heads, %llu sectors, %llu cylinders\n" "Units = %s of %d * %ld bytes\n\n"), cxt->dev_path, cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders, - str_units(PLURAL), units_per_sector, + fdisk_context_get_unit(cxt, PLURAL), + fdisk_context_get_units_per_sector(cxt), cxt->sector_size); } printf(_("----- partitions -----\n" @@ -227,8 +229,8 @@ sgi_list_table(struct fdisk_context *cxt, int xtra) { /* device */ partname(cxt->dev_path, kpi, w+2), /* flags */ (sgi_get_swappartition(cxt) == (int) i) ? "swap" : /* flags */ (sgi_get_bootpartition(cxt) == (int) i) ? "boot" : " ", -/* start */ (long) scround(start), -/* end */ (long) scround(start+len)-1, +/* start */ (long) scround(cxt, start), +/* end */ (long) scround(cxt, start+len)-1, /* no odd flag on end */ (long) len, /* type id */ t->type, /* type name */ t->name); @@ -728,7 +730,8 @@ static int sgi_add_partition(struct fdisk_context *cxt, printf(_("You got a partition overlap on the disk. Fix it first!\n")); return -EINVAL; } - snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), _("First %s"), + fdisk_context_get_unit(cxt, SINGULAR)); for (;;) { if (sys == SGI_VOLUME) { last = sgi_get_lastblock(cxt); @@ -740,11 +743,13 @@ static int sgi_add_partition(struct fdisk_context *cxt, } else { first = freelist[0].first; last = freelist[0].last; - first = read_int(cxt, scround(first), scround(first), scround(last)-1, + first = read_int(cxt, scround(cxt, first), + scround(cxt, first), + scround(cxt, last) - 1, 0, mesg); } - if (display_in_cyl_units) - first *= units_per_sector; + if (fdisk_context_use_cylinders(cxt)) + first *= fdisk_context_get_units_per_sector(cxt); /*else first = first; * align to cylinder if you know how ... */ if (!last) @@ -755,11 +760,14 @@ static int sgi_add_partition(struct fdisk_context *cxt, } else break; } - snprintf(mesg, sizeof(mesg), _(" Last %s"), str_units(SINGULAR)); - last = read_int(cxt, scround(first), scround(last)-1, scround(last)-1, - scround(first), mesg)+1; - if (display_in_cyl_units) - last *= units_per_sector; + snprintf(mesg, sizeof(mesg), _(" Last %s"), + fdisk_context_get_unit(cxt, SINGULAR)); + last = read_int(cxt, scround(cxt, first), + scround(cxt, last)-1, + scround(cxt, last)-1, + scround(cxt, first), mesg)+1; + if (fdisk_context_use_cylinders(cxt)) + last *= fdisk_context_get_units_per_sector(cxt); /*else last = last; * align to cylinder if You know how ... */ if ((sys == SGI_VOLUME) && (first != 0 || last != sgi_get_lastblock(cxt))) diff --git a/fdisks/fdisksunlabel.c b/fdisks/fdisksunlabel.c index 990974808..b7c68b762 100644 --- a/fdisks/fdisksunlabel.c +++ b/fdisks/fdisksunlabel.c @@ -485,7 +485,8 @@ static int sun_add_partition( return -EINVAL; } } - snprintf(mesg, sizeof(mesg), _("First %s"), str_units(SINGULAR)); + snprintf(mesg, sizeof(mesg), _("First %s"), + fdisk_context_get_unit(cxt, SINGULAR)); for (;;) { ask = fdisk_new_ask(); if (!ask) @@ -499,9 +500,9 @@ static int sun_add_partition( fdisk_ask_number_set_default(ask, 0); /* default */ fdisk_ask_number_set_high(ask, 0); /* maximal */ } else { - fdisk_ask_number_set_low(ask, scround(start)); /* minimal */ - fdisk_ask_number_set_default(ask, scround(start)); /* default */ - fdisk_ask_number_set_high(ask, scround(stop)); /* maximal */ + fdisk_ask_number_set_low(ask, scround(cxt, start)); /* minimal */ + fdisk_ask_number_set_default(ask, scround(cxt, start)); /* default */ + fdisk_ask_number_set_high(ask, scround(cxt, stop)); /* maximal */ } rc = fdisk_do_ask(cxt, ask); first = fdisk_ask_number_get_result(ask); @@ -510,8 +511,8 @@ static int sun_add_partition( if (rc) return rc; - if (display_in_cyl_units) - first *= units_per_sector; + if (fdisk_context_use_cylinders(cxt)) + first *= fdisk_context_get_units_per_sector(cxt); else { /* Starting sector has to be properly aligned */ int cs = cxt->geom.heads * cxt->geom.sectors; @@ -561,7 +562,8 @@ and is of type `Whole disk'")); } snprintf(mesg, sizeof(mesg), _("Last %s or +%s or +size{K,M,G,T,P}"), - str_units(SINGULAR), str_units(PLURAL)); + fdisk_context_get_unit(cxt, SINGULAR), + fdisk_context_get_unit(cxt, PLURAL)); ask = fdisk_new_ask(); if (!ask) @@ -571,25 +573,26 @@ and is of type `Whole disk'")); fdisk_ask_set_type(ask, FDISK_ASKTYPE_OFFSET); if (whole_disk) { - fdisk_ask_number_set_low(ask, scround(stop2)); /* minimal */ - fdisk_ask_number_set_default(ask, scround(stop2)); /* default */ - fdisk_ask_number_set_high(ask, scround(stop2)); /* maximal */ + fdisk_ask_number_set_low(ask, scround(cxt, stop2)); /* minimal */ + fdisk_ask_number_set_default(ask, scround(cxt, stop2)); /* default */ + fdisk_ask_number_set_high(ask, scround(cxt, stop2)); /* maximal */ fdisk_ask_number_set_base(ask, 0); } else if (n == 2 && !first) { - fdisk_ask_number_set_low(ask, scround(first)); /* minimal */ - fdisk_ask_number_set_default(ask, scround(stop2)); /* default */ - fdisk_ask_number_set_high(ask, scround(stop2)); /* maximal */ - fdisk_ask_number_set_base(ask, scround(first)); + fdisk_ask_number_set_low(ask, scround(cxt, first)); /* minimal */ + fdisk_ask_number_set_default(ask, scround(cxt, stop2)); /* default */ + fdisk_ask_number_set_high(ask, scround(cxt, stop2)); /* maximal */ + fdisk_ask_number_set_base(ask, scround(cxt, first)); } else { - fdisk_ask_number_set_low(ask, scround(first)); /* minimal */ - fdisk_ask_number_set_default(ask, scround(stop)); /* default */ - fdisk_ask_number_set_high(ask, scround(stop)); /* maximal */ - fdisk_ask_number_set_base(ask, scround(first)); + fdisk_ask_number_set_low(ask, scround(cxt, first)); /* minimal */ + fdisk_ask_number_set_default(ask, scround(cxt, stop)); /* default */ + fdisk_ask_number_set_high(ask, scround(cxt, stop)); /* maximal */ + fdisk_ask_number_set_base(ask, scround(cxt, first)); } - if (display_in_cyl_units) + if (fdisk_context_use_cylinders(cxt)) fdisk_ask_number_set_unit(ask, - cxt->sector_size * units_per_sector); + cxt->sector_size * + fdisk_context_get_units_per_sector(cxt)); else fdisk_ask_number_set_unit(ask, cxt->sector_size); @@ -609,8 +612,8 @@ and is of type `Whole disk'")); _("You haven't covered the whole disk with the 3rd partition, but your value\n" "%d %s covers some other partition. Your entry has been changed\n" "to %d %s"), - scround(last), str_units(SINGULAR), - scround(stop), str_units(SINGULAR)); + scround(cxt, last), fdisk_context_get_unit(cxt, SINGULAR), + scround(cxt, stop), fdisk_context_get_unit(cxt, SINGULAR)); last = stop; } } else if (!whole_disk && last > stop) @@ -685,13 +688,15 @@ void sun_list_table(struct fdisk_context *cxt, int xtra) be16_to_cpu(sunlabel->intrlv), sunlabel->label_id, sunlabel->vtoc.volume_id, - str_units(PLURAL), units_per_sector); + fdisk_context_get_unit(cxt, PLURAL), + fdisk_context_get_units_per_sector(cxt)); else printf( _("\nDisk %s (Sun disk label): %u heads, %llu sectors, %llu cylinders\n" "Units = %s of %d * 512 bytes\n\n"), cxt->dev_path, cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders, - str_units(PLURAL), units_per_sector); + fdisk_context_get_unit(cxt, PLURAL), + fdisk_context_get_units_per_sector(cxt)); printf(_("%*s Flag Start End Blocks Id System\n"), w + 1, _("Device")); @@ -709,8 +714,8 @@ void sun_list_table(struct fdisk_context *cxt, int xtra) /* device */ partname(cxt->dev_path, i+1, w), /* flags */ be16_to_cpu(info->flags) & SUN_FLAG_UNMNT ? 'u' : ' ', be16_to_cpu(info->flags) & SUN_FLAG_RONLY ? 'r' : ' ', -/* start */ (unsigned long) scround(start), -/* end */ (unsigned long) scround(start+len), +/* start */ (unsigned long) scround(cxt, start), +/* end */ (unsigned long) scround(cxt, start+len), /* odd flag on end */ (unsigned long) len / 2, len & 1 ? '+' : ' ', /* type id */ t->type, /* type name */ t->name); @@ -892,10 +897,8 @@ static int sun_set_parttype( } -static int sun_reset_alignment(struct fdisk_context *cxt) +static int sun_reset_alignment(struct fdisk_context *cxt __attribute__((__unused__))) { - /* this is shared with DOS ... */ - update_units(cxt); return 0; } |